Skip to content
Merged
Prev Previous commit
Next Next commit
Respect ignoredHookedBlocks post meta when rendering
  • Loading branch information
ockham committed Dec 3, 2024
commit 7261f2fe77c808607e8d61d1039ddd65682529bc
10 changes: 9 additions & 1 deletion packages/block-library/src/post-content/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,19 @@ function render_block_core_post_content( $attributes, $content, $block ) {
$content .= wp_link_pages( array( 'echo' => 0 ) );
}

$ignored_hooked_blocks = get_post_meta( $post_id, '_wp_ignored_hooked_blocks', true );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trick for the first and last child of the Post Content block works like a charm!

if ( ! empty( $ignored_hooked_blocks ) ) {
$ignored_hooked_blocks = json_decode( $ignored_hooked_blocks, true );
$attributes['metadata'] = array(
'ignoredHookedBlocks' => $ignored_hooked_blocks,
);
}

// Wrap in Post Content block so the Block Hooks algorithm can insert blocks
// that are hooked as first or last child of `core/post-content`.
$content = get_comment_delimited_block_content(
'core/post-content',
$attributes, // TODO: Merge ignoredHookedBlocks from post meta.
$attributes,
$content
);

Expand Down
Loading