Skip to content

Commit

Permalink
Deprecate param in insert_hooked_blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcafferkey committed Jun 26, 2024
1 parent dda337c commit 98ced4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 6 additions & 3 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,10 @@ function get_hooked_blocks_by_anchor_block( $anchor_block_type, $relative_positi
* @param WP_Block_Template|WP_Post|array $context The block template, template part, or pattern that the anchor block belongs to.
* @return string
*/
function insert_hooked_blocks( &$parsed_anchor_block, $relative_position, $context ) {
function insert_hooked_blocks( &$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 );

Expand Down Expand Up @@ -1176,8 +1179,8 @@ function insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata( &$parsed_a
_deprecated_function( __FUNCTION__, '6.7.0' );
}

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

return $markup;
}
Expand Down
12 changes: 6 additions & 6 deletions tests/phpunit/tests/blocks/insertHookedBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function test_insert_hooked_blocks_returns_correct_markup() {
'blockName' => self::ANCHOR_BLOCK_TYPE,
);

$actual = insert_hooked_blocks( $anchor_block, 'after', array() );
$actual = insert_hooked_blocks( $anchor_block, 'after', null, array() );
$this->assertSame(
'<!-- wp:' . self::HOOKED_BLOCK_TYPE . ' /-->',
$actual,
Expand All @@ -93,7 +93,7 @@ public function test_insert_hooked_blocks_if_block_is_ignored() {
),
);

$actual = insert_hooked_blocks( $anchor_block, 'after', array() );
$actual = insert_hooked_blocks( $anchor_block, 'after', null, array() );
$this->assertSame(
'',
$actual,
Expand All @@ -118,7 +118,7 @@ public function test_insert_hooked_blocks_if_other_block_is_ignored() {
),
);

$actual = insert_hooked_blocks( $anchor_block, 'before', array() );
$actual = insert_hooked_blocks( $anchor_block, 'before', null, array() );
$this->assertSame(
'<!-- wp:' . self::OTHER_HOOKED_BLOCK_TYPE . ' /-->',
$actual,
Expand Down Expand Up @@ -159,7 +159,7 @@ public function test_insert_hooked_blocks_filter_can_set_attributes() {
return $parsed_hooked_block;
};
add_filter( 'hooked_block_' . self::HOOKED_BLOCK_TYPE, $filter, 10, 4 );
$actual = insert_hooked_blocks( $anchor_block, 'after', array() );
$actual = insert_hooked_blocks( $anchor_block, 'after', null, array() );
remove_filter( 'hooked_block_' . self::HOOKED_BLOCK_TYPE, $filter );

$this->assertSame(
Expand Down Expand Up @@ -205,7 +205,7 @@ public function test_insert_hooked_blocks_filter_can_wrap_block() {
);
};
add_filter( 'hooked_block_' . self::HOOKED_BLOCK_TYPE, $filter, 10, 3 );
$actual = insert_hooked_blocks( $anchor_block, 'after', array() );
$actual = insert_hooked_blocks( $anchor_block, 'after', null, array() );
remove_filter( 'hooked_block_' . self::HOOKED_BLOCK_TYPE, $filter );

$this->assertSame(
Expand Down Expand Up @@ -247,7 +247,7 @@ public function test_insert_hooked_blocks_filter_can_suppress_hooked_block() {
return $parsed_hooked_block;
};
add_filter( 'hooked_block_' . self::HOOKED_BLOCK_TYPE, $filter, 10, 4 );
$actual = insert_hooked_blocks( $anchor_block, 'after', array() );
$actual = insert_hooked_blocks( $anchor_block, 'after', null, array() );
remove_filter( 'hooked_block_' . self::HOOKED_BLOCK_TYPE, $filter );

$this->assertSame( '', $actual, "No markup should've been generated for hooked block suppressed by filter." );
Expand Down

0 comments on commit 98ced4b

Please sign in to comment.