Skip to content

Commit

Permalink
Deprecate param in set_ignored_hooked_blocks_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcafferkey committed Jun 26, 2024
1 parent a0807c6 commit 937c667
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -993,10 +993,15 @@ function insert_hooked_blocks( &$parsed_anchor_block, $relative_position, $conte
* @param array $parsed_anchor_block The anchor block, in parsed block array format.
* @param string $relative_position The relative position of the hooked blocks.
* Can be one of 'before', 'after', 'first_child', or 'last_child'.
* @param mixed $deprecated Deprecated. Not used.
* @param WP_Block_Template|WP_Post|array $context The block template, template part, or pattern that the anchor block belongs to.
* @return string Empty string.
*/
function set_ignored_hooked_blocks_metadata( &$parsed_anchor_block, $relative_position, $context ) {
function set_ignored_hooked_blocks_metadata( &$parsed_anchor_block, $relative_position, $deprecated = null, $context ) {
if ( null !== $deprecated ) {
_deprecated_argument( __FUNCTION__, '6.7.0' );
}

$anchor_block_type = $parsed_anchor_block['blockName'];
$hooked_block_types = get_hooked_blocks_by_anchor_block( $anchor_block_type, $relative_position, $context );
if ( empty( $hooked_block_types ) ) {
Expand Down Expand Up @@ -1162,7 +1167,7 @@ function update_ignored_hooked_blocks_postmeta( $post ) {
* @param array $parsed_anchor_block The anchor block, in parsed block array format.
* @param string $relative_position The relative position of the hooked blocks.
* Can be one of 'before', 'after', 'first_child', or 'last_child'.
* @param string $deprecated Deprecated. Not used.
* @param mixed $deprecated Deprecated. Not used.
* @param WP_Block_Template|WP_Post|array $context The block template, template part, or pattern that the anchor block belongs to.
* @return string
*/
Expand All @@ -1172,7 +1177,7 @@ function insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata( &$parsed_a
}

$markup = insert_hooked_blocks( $parsed_anchor_block, $relative_position, $context );
$markup .= set_ignored_hooked_blocks_metadata( $parsed_anchor_block, $relative_position, $context );
$markup .= set_ignored_hooked_blocks_metadata( $parsed_anchor_block, $relative_position, null, $context );

return $markup;
}
Expand Down
10 changes: 5 additions & 5 deletions tests/phpunit/tests/blocks/setIgnoredHookedBlocksMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function test_set_ignored_hooked_blocks_metadata() {
)
);

set_ignored_hooked_blocks_metadata( $anchor_block, 'after', null );
set_ignored_hooked_blocks_metadata( $anchor_block, 'after', null, null );
$this->assertSame( array( 'tests/hooked-block' ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] );
}

Expand Down Expand Up @@ -90,7 +90,7 @@ public function test_set_ignored_hooked_blocks_metadata_retains_existing_items()
)
);

set_ignored_hooked_blocks_metadata( $anchor_block, 'after', null );
set_ignored_hooked_blocks_metadata( $anchor_block, 'after', null, null );
$this->assertSame(
array( 'tests/other-ignored-block', 'tests/hooked-block' ),
$anchor_block['attrs']['metadata']['ignoredHookedBlocks']
Expand All @@ -117,7 +117,7 @@ public function test_set_ignored_hooked_blocks_metadata_for_block_added_by_filte
};

add_filter( 'hooked_block_types', $filter, 10, 3 );
set_ignored_hooked_blocks_metadata( $anchor_block, 'after', null );
set_ignored_hooked_blocks_metadata( $anchor_block, 'after', null, null );
remove_filter( 'hooked_block_types', $filter, 10 );

$this->assertSame(
Expand Down Expand Up @@ -156,7 +156,7 @@ public function test_set_ignored_hooked_blocks_metadata_for_block_added_by_conte
$template = self::create_block_template_object();

add_filter( 'hooked_block_types', $filter, 10, 4 );
set_ignored_hooked_blocks_metadata( $anchor_block, 'after', $template );
set_ignored_hooked_blocks_metadata( $anchor_block, 'after', null, $template );
remove_filter( 'hooked_block_types', $filter, 10 );

$this->assertSame(
Expand Down Expand Up @@ -199,7 +199,7 @@ public function test_set_ignored_hooked_blocks_metadata_for_block_suppressed_by_
};

add_filter( 'hooked_block', $filter, 10, 4 );
set_ignored_hooked_blocks_metadata( $anchor_block, 'after', null );
set_ignored_hooked_blocks_metadata( $anchor_block, 'after', null, null );
remove_filter( 'hooked_block', $filter );

$this->assertSame( array( 'tests/hooked-block' ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] );
Expand Down

0 comments on commit 937c667

Please sign in to comment.