Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Set ignoredHookedBlocks metadata
  • Loading branch information
ockham committed Nov 28, 2023
commit 552c66e63a7b6a5f3b2232dca0b76671fa157857
14 changes: 14 additions & 0 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,20 @@ function get_hooked_blocks() {
}

function get_hooked_block_markup( &$anchor_block, $hooked_block_type ) {
if (
isset( $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] ) &&
in_array( $hooked_block_type, $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] )
) {
return '';
}

// The following is only needed for the REST API endpoint.
// However, its presence does not affect the frontend.
if ( ! isset( $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] ) ) {
$anchor_block['attrs']['metadata']['ignoredHookedBlocks'] = array();
}
$anchor_block['attrs']['metadata']['ignoredHookedBlocks'][] = $hooked_block_type;

return get_comment_delimited_block_content( $hooked_block_type, array(), '' );
}

Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/blocks/getHookedBlockMarkup
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Tests_Blocks_GetHookedBlockMarkup extends WP_UnitTestCase
);

$actual = get_hooked_block_markup( $anchor_block, 'tests/hooked-block' );
$this->assertSame( array( 'tests/hooked-block' ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] );
$this->assertSame( '<!-- wp:tests/hooked-block /-->', $actual );
}
}