Open
Conversation
Adds a "Fediverse ⁂" panel to the block inspector sidebar for all blocks with a "Share to the Fediverse" toggle. When disabled, the block is excluded from federated content but remains visible on the site. - JS: editor.BlockEdit filter adds InspectorControls toggle that saves metadata.blockVisibility.fediverse in block markup - PHP: render_block filter strips hidden blocks during AP content generation; also filters get_in_reply_to() and media extraction - Disables core block visibility (viewport hiding) on the reply block since it is semantic and should not be conditionally hidden Prepares for WordPress 7.0 block visibility feature.
- filter_blocks_hidden_from_fediverse → maybe_hide_block - is_block_hidden_from_fediverse → is_federated
There was a problem hiding this comment.
Pull request overview
Adds an editor-facing “Share to the Fediverse” per-block toggle and enforces it during ActivityPub rendering so authors can exclude specific blocks from federated content without affecting on-site display.
Changes:
- Introduces a block editor plugin that writes
metadata.blockVisibility.fediverseper block via a new Inspector “Fediverse ⁂” panel. - Filters hidden blocks out of ActivityPub-rendered HTML and excludes them from reply URL + media attachment extraction.
- Disables core visibility UI on the Federated Reply block (
supports.visibility: false) and adds the needed JS dependency.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/reply/block.json | Disables core visibility controls for the Federated Reply block. |
| src/block-visibility/plugin.js | Adds the Inspector toggle and persists the setting into block metadata. |
| src/block-visibility/block.json | Provides build metadata for the editor plugin bundle. |
| includes/class-blocks.php | Adds render-time filtering for hidden blocks during ActivityPub content generation. |
| includes/transformer/class-post.php | Skips hidden blocks when extracting in-reply-to URLs and media attachments. |
| package.json | Adds @wordpress/hooks for the new editor plugin code. |
| package-lock.json | Locks the new dependency. |
| .github/changelog/block-visibility-fediverse | Changelog entry for the new feature. |
| build/* | Build artifacts (not code-reviewed). |
Comments suppressed due to low confidence (2)
includes/class-blocks.php:1016
filter_blocks_hidden_from_fediverse()/is_block_hidden_from_fediverse()introduce new filtering logic that affects all ActivityPub content rendering. There are existing PHPUnit tests forActivitypub\Blocks(e.g., reply link generation and import transformations), but no coverage for this new visibility behavior; please add tests for both helper methods (visible by default, hidden whenmetadata.blockVisibility.fediverseisfalse, and filtering returns an empty string when hidden).
/**
* Strip blocks not marked for federation during content rendering.
*
* @since unreleased
*
* @param string $block_content The rendered block content.
* @param array $block The parsed block data.
*
* @return string The block content, or empty string if hidden.
*/
public static function maybe_hide_block( $block_content, $block ) {
if ( ! self::is_federated( $block ) ) {
return '';
}
return $block_content;
}
/**
* Whether a block should be included in federated content.
*
* Checks `metadata.blockVisibility.fediverse`. Defaults to true.
*
* @since unreleased
*
* @param array $block The parsed block data.
*
* @return bool True if the block should be federated.
*/
public static function is_federated( $block ) {
$visibility = $block['attrs']['metadata']['blockVisibility']['fediverse'] ?? true;
return false !== $visibility;
}
/**
* Generate HTML @ link for reply block.
*
* @param string $block_content The block content.
includes/class-blocks.php:960
- In
add_post_transformation_callbacks(),generate_reply_linkis added whenever the first block isactivitypub/reply, even if that reply block is hidden from the Fediverse. In that case the block will be removed later byfilter_blocks_hidden_from_fediverse, butgenerate_reply_link()can still run first and perform remote fetches unnecessarily. Consider skipping therender_block_activitypub/replyfilter when the first reply block is hidden (e.g., checkself::is_block_hidden_from_fediverse( $blocks[0] )before adding the filter).
// Only transform reply link if it's the first block in the post.
$blocks = \parse_blocks( $post->post_content );
if ( ! empty( $blocks ) && 'activitypub/reply' === $blocks[0]['blockName'] ) {
\add_filter( 'render_block_activitypub/reply', array( self::class, 'generate_reply_link' ), 10, 2 );
}
You can also share your feedback on Copilot code review. Take the survey.
- is_federated: default true, explicit true, missing metadata, false - maybe_hide_block: keeps visible blocks, strips hidden blocks - get_media_from_blocks: skips images in hidden blocks - get_in_reply_to: skips hidden reply blocks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2076
Prepares for Block Visibility in WordPress 7.0.
Proposed changes:
metadata.blockVisibility.fediverse— piggybacks on the new WordPress 7.0 block visibility metadata structurerender_blockfilter (only active during AP content generation)Other information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Add per-block Fediverse visibility toggle to control which blocks are shared to Mastodon and other Fediverse platforms.