Changeset 57660
- Timestamp:
- 02/20/2024 09:25:09 AM (8 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r57644 r57660 896 896 * Filters the parsed block array for a given hooked block. 897 897 * 898 * @since 6.5.0 899 * 900 * @param array $parsed_hooked_block The parsed block array for the given hooked block type. 901 * @param string $hooked_block_type The hooked block type name. 902 * @param string $relative_position The relative position of the hooked block. 903 * @param array $parsed_anchor_block The anchor block, in parsed block array format. 904 * @param WP_Block_Template|WP_Post|array $context The block template, template part, `wp_navigation` post type, 905 * or pattern that the anchor block belongs to. 906 */ 907 $parsed_hooked_block = apply_filters( 'hooked_block', $parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block, $context ); 908 909 /** 910 * Filters the parsed block array for a given hooked block. 911 * 898 912 * The dynamic portion of the hook name, `$hooked_block_type`, refers to the block type name of the specific hooked block. 899 913 * … … 901 915 * 902 916 * @param array $parsed_hooked_block The parsed block array for the given hooked block type. 917 * @param string $hooked_block_type The hooked block type name. 903 918 * @param string $relative_position The relative position of the hooked block. 904 919 * @param array $parsed_anchor_block The anchor block, in parsed block array format. … … 906 921 * or pattern that the anchor block belongs to. 907 922 */ 908 $parsed_hooked_block = apply_filters( "hooked_block_{$hooked_block_type}", $parsed_hooked_block, $ relative_position, $parsed_anchor_block, $context );909 910 // It's possible that the `hooked_block_{$hooked_block_type}` filter returned a block of a different type,911 // so we explicitlylook for the original `$hooked_block_type` in the `ignoredHookedBlocks` metadata.923 $parsed_hooked_block = apply_filters( "hooked_block_{$hooked_block_type}", $parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block, $context ); 924 925 // It's possible that the filter returned a block of a different type, so we explicitly 926 // look for the original `$hooked_block_type` in the `ignoredHookedBlocks` metadata. 912 927 if ( 913 928 ! isset( $parsed_anchor_block['attrs']['metadata']['ignoredHookedBlocks'] ) || -
trunk/tests/phpunit/tests/blocks/insertHookedBlocks.php
r57627 r57660 111 111 ); 112 112 113 $filter = function ( $parsed_hooked_block, $ relative_position, $parsed_anchor_block ) {113 $filter = function ( $parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block ) { 114 114 // Is the hooked block adjacent to the anchor block? 115 115 if ( 'before' !== $relative_position && 'after' !== $relative_position ) { … … 125 125 return $parsed_hooked_block; 126 126 }; 127 add_filter( 'hooked_block_' . self::HOOKED_BLOCK_TYPE, $filter, 10, 3);127 add_filter( 'hooked_block_' . self::HOOKED_BLOCK_TYPE, $filter, 10, 4 ); 128 128 $actual = insert_hooked_blocks( $anchor_block, 'after', self::HOOKED_BLOCKS, array() ); 129 remove_filter( 'hooked_block_' . self::HOOKED_BLOCK_TYPE, $filter , 10, 3);129 remove_filter( 'hooked_block_' . self::HOOKED_BLOCK_TYPE, $filter ); 130 130 131 131 $this->assertSame( … … 173 173 add_filter( 'hooked_block_' . self::HOOKED_BLOCK_TYPE, $filter, 10, 3 ); 174 174 $actual = insert_hooked_blocks( $anchor_block, 'after', self::HOOKED_BLOCKS, array() ); 175 remove_filter( 'hooked_block_' . self::HOOKED_BLOCK_TYPE, $filter , 10, 3);175 remove_filter( 'hooked_block_' . self::HOOKED_BLOCK_TYPE, $filter ); 176 176 177 177 $this->assertSame(
Note: See TracChangeset
for help on using the changeset viewer.