Changeset 58186
- Timestamp:
- 05/23/2024 06:33:11 PM (6 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-template-utils.php
r58084 r58186 599 599 $hooked_blocks = get_hooked_blocks(); 600 600 if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) { 601 $before_block_visitor = make_before_block_visitor( $hooked_blocks, $template );602 $after_block_visitor = make_after_block_visitor( $hooked_blocks, $template );601 $before_block_visitor = make_before_block_visitor( $hooked_blocks, $template, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' ); 602 $after_block_visitor = make_after_block_visitor( $hooked_blocks, $template, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' ); 603 603 } 604 604 $blocks = parse_blocks( $template->content ); … … 985 985 $hooked_blocks = get_hooked_blocks(); 986 986 if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) { 987 $before_block_visitor = make_before_block_visitor( $hooked_blocks, $template );988 $after_block_visitor = make_after_block_visitor( $hooked_blocks, $template );987 $before_block_visitor = make_before_block_visitor( $hooked_blocks, $template, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' ); 988 $after_block_visitor = make_after_block_visitor( $hooked_blocks, $template, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' ); 989 989 $blocks = parse_blocks( $template->content ); 990 990 $template->content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor ); -
trunk/src/wp-includes/blocks.php
r58084 r58186 859 859 * @access private 860 860 * 861 * @param array $parsed_anchor_block The anchor block, in parsed block array format.862 * @param string $relative_position The relative position of the hooked blocks.863 * Can be one of 'before', 'after', 'first_child', or 'last_child'.864 * @param array $hooked_blocks An array of hooked block types, grouped by anchor block and relative position.865 * @param WP_Block_Template| array $context The block template, template part, or pattern that the anchor block belongs to.861 * @param array $parsed_anchor_block The anchor block, in parsed block array format. 862 * @param string $relative_position The relative position of the hooked blocks. 863 * Can be one of 'before', 'after', 'first_child', or 'last_child'. 864 * @param array $hooked_blocks An array of hooked block types, grouped by anchor block and relative position. 865 * @param WP_Block_Template|WP_Post|array $context The block template, template part, or pattern that the anchor block belongs to. 866 866 * @return string 867 867 */ … … 950 950 * @access private 951 951 * 952 * @param array $parsed_anchor_block The anchor block, in parsed block array format.953 * @param string $relative_position The relative position of the hooked blocks.954 * Can be one of 'before', 'after', 'first_child', or 'last_child'.955 * @param array $hooked_blocks An array of hooked block types, grouped by anchor block and relative position.956 * @param WP_Block_Template| array $context The block template, template part, or pattern that the anchor block belongs to.957 * @return string An empty string.952 * @param array $parsed_anchor_block The anchor block, in parsed block array format. 953 * @param string $relative_position The relative position of the hooked blocks. 954 * Can be one of 'before', 'after', 'first_child', or 'last_child'. 955 * @param array $hooked_blocks An array of hooked block types, grouped by anchor block and relative position. 956 * @param WP_Block_Template|WP_Post|array $context The block template, template part, or pattern that the anchor block belongs to. 957 * @return string Empty string. 958 958 */ 959 959 function set_ignored_hooked_blocks_metadata( &$parsed_anchor_block, $relative_position, $hooked_blocks, $context ) { … … 1001 1001 // Markup for the hooked blocks has already been created (in `insert_hooked_blocks`). 1002 1002 return ''; 1003 } 1004 1005 /** 1006 * Returns the markup for blocks hooked to the given anchor block in a specific relative position and then 1007 * adds a list of hooked block types to an anchor block's ignored hooked block types. 1008 * 1009 * This function is meant for internal use only. 1010 * 1011 * @since 6.6.0 1012 * @access private 1013 * 1014 * @param array $parsed_anchor_block The anchor block, in parsed block array format. 1015 * @param string $relative_position The relative position of the hooked blocks. 1016 * Can be one of 'before', 'after', 'first_child', or 'last_child'. 1017 * @param array $hooked_blocks An array of hooked block types, grouped by anchor block and relative position. 1018 * @param WP_Block_Template|WP_Post|array $context The block template, template part, or pattern that the anchor block belongs to. 1019 * @return string 1020 */ 1021 function insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata( &$parsed_anchor_block, $relative_position, $hooked_blocks, $context ) { 1022 $markup = insert_hooked_blocks( $parsed_anchor_block, $relative_position, $hooked_blocks, $context ); 1023 $markup .= set_ignored_hooked_blocks_metadata( $parsed_anchor_block, $relative_position, $hooked_blocks, $context ); 1024 1025 return $markup; 1003 1026 } 1004 1027 -
trunk/src/wp-includes/class-wp-block-patterns-registry.php
r57731 r58186 175 175 $after_block_visitor = null; 176 176 if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) { 177 $before_block_visitor = make_before_block_visitor( $hooked_blocks, $pattern );178 $after_block_visitor = make_after_block_visitor( $hooked_blocks, $pattern );177 $before_block_visitor = make_before_block_visitor( $hooked_blocks, $pattern, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' ); 178 $after_block_visitor = make_after_block_visitor( $hooked_blocks, $pattern, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' ); 179 179 } 180 180 $blocks = parse_blocks( $content ); -
trunk/tests/phpunit/tests/blocks/getHookedBlocks.php
r57627 r58186 152 152 ); 153 153 $this->assertStringContainsString( 154 '<!-- wp:post-content {"layout":{"type":"constrained"} } /-->'154 '<!-- wp:post-content {"layout":{"type":"constrained"},"metadata":{"ignoredHookedBlocks":["tests/hooked-after"]}} /-->' 155 155 . '<!-- wp:tests/hooked-after /-->', 156 156 $template->content … … 181 181 $this->assertStringContainsString( 182 182 '<!-- wp:tests/hooked-before /-->' 183 . '<!-- wp:navigation {"layout":{"type":"flex","setCascadingProperties":true,"justifyContent":"right"} } /-->',183 . '<!-- wp:navigation {"layout":{"type":"flex","setCascadingProperties":true,"justifyContent":"right"},"metadata":{"ignoredHookedBlocks":["tests/hooked-before"]}} /-->', 184 184 $template->content 185 185 ); … … 222 222 ); 223 223 $this->assertStringContainsString( 224 '<!-- wp:comments -->'224 '<!-- wp:comments {"metadata":{"ignoredHookedBlocks":["tests/hooked-first-child"]}} -->' 225 225 . '<div class="wp-block-comments">' 226 226 . '<!-- wp:tests/hooked-first-child /-->',
Note: See TracChangeset
for help on using the changeset viewer.