Skip to content

Block discoverability: allow a block to be inserted even when its associated module is disabled #32401

Closed

Description

Jetpack currently loads about 70 blocks and plugins in the editor. A small portion of those blocks aren't immediately available though. If the feature is tied to a Jetpack module (as available in projects/plugins/jetpack/modules), we've typically not loaded the block until the associated module was activated.

We've typically done that by placing the code that was registering the block in files that are only loaded when the module is active, or by adding a is_module_active check`. Here is an example:

/**
* Check if the WordAds module is active.
*
* @return bool
*/
private static function is_jetpack_module_active() {
return method_exists( 'Jetpack', 'is_module_active' ) && Jetpack::is_module_active( 'wordads' );
}
/**
* Check if the site is approved for ads for WP.com Simple sites.
*
* @return bool
*/
private static function is_available() {
if ( self::is_wpcom() ) {
return has_any_blog_stickers( array( 'wordads', 'wordads-approved', 'wordads-approved-misfits' ), get_current_blog_id() );
}
return self::is_jetpack_module_active();
}
/**
* Register the WordAds block.
*/
public static function register() {
if ( self::is_available() ) {

While this make sense, it's also not ideal for site owners:

  • Someone may have heard / read about Jetpack offering a specific feature, but may not find it in their block editor because the module isn't active yet.
  • Someone may be looking for a specific block, and looking for a plugin that will help them even though they wouldn't have to look for a new plugin if they knew the Jetpack plugin that's already installed on their site offers that functionality.

Ideally, we would offer all the blocks available in Jetpack, with a prompt to activate the feature when necessary. This is something we've already implemented with the Subscriptions block:

image image

Let's aim to offer a similar experience for the other features that rely on modules, listed below.

This would also address the problem of obscure error messages when a block is used on a site where the module was disabled: #11903

Implementation

In #29044, we've introduced the useModuleStatus hook in @automattic/jetpack-shared-extension-utils, that allows us to turn a module on from the block editor. This can be used for the modules below.

While for some of those modules the change should be fairly straightforward, for others we'll need to watch out for any meta data that may be created on module activation.

Block List

Tasks

  1. [Extension] SEO [Feature] SEO Tools [Pri] Low [Type] Enhancement
    andrii-lysenko
  2. [Extension] Sharing [Feature] Sharing [Pri] Low [Type] Enhancement
    andrii-lysenko
  3. [Extension] Likes [Feature] Likes [Pri] Low [Type] Enhancement
    andrii-lysenko
  4. [Block] Contact Form [Closed] Won't Fix [Feature] Contact Form [Pri] Low [Type] Bug
    andrii-lysenko jeherve
  5. [Block] Shortlinks [Closed] Won't Fix [Feature] Shortlinks [Pri] Low [Type] Enhancement
    andrii-lysenko
  6. [Block] Ad [Feature] WordAds [Pri] Low [Type] Enhancement
    andrii-lysenko
  7. Docs RNA [Block] AI Assistant [Block] Contact Form [Feature] Contact Form [JS Package] Shared Extension Utils [Package] Forms [Package] Search [Plugin] Jetpack [Tests] Includes Tests [Type] Enhancement
    andrii-lysenko
  8. [Feature] Publicize [Package] Publicize [Package] Social [Plugin] Jetpack [Plugin] Social [Status] Blocked / Hold [Type] Enhancement
    monsieur-z

Internal references

PT: pf5801-7Q-p2

Past discussions:

  • p8oabR-DS-p2#comment-5223
  • pafL3P-78-p2
  • pafL3P-1X-p2
  • pafL3P-cP-p2
  • pafL3P-aF-p2
  • p1HpG7-5JG-p2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Customer ReportIssues or PRs that were reported via Happiness. Previously known as "Happiness Request".EpicFormerly "Primary Issue", or "Master Issue"[Focus] BlocksIssues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack[Plugin] JetpackIssues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/[Pri] Normal[Type] EnhancementChanges to an existing feature — removing, adding, or changing parts of it

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions