diff --git a/wp-includes/block-template-utils.php b/wp-includes/block-template-utils.php index b953993b67..8efb03be1a 100644 --- a/wp-includes/block-template-utils.php +++ b/wp-includes/block-template-utils.php @@ -598,8 +598,8 @@ function _build_block_template_result_from_file( $template_file, $template_type $after_block_visitor = null; $hooked_blocks = get_hooked_blocks(); if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) { - $before_block_visitor = make_before_block_visitor( $hooked_blocks, $template ); - $after_block_visitor = make_after_block_visitor( $hooked_blocks, $template ); + $before_block_visitor = make_before_block_visitor( $hooked_blocks, $template, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' ); + $after_block_visitor = make_after_block_visitor( $hooked_blocks, $template, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' ); } $blocks = parse_blocks( $template->content ); $template->content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor ); @@ -984,8 +984,8 @@ function _build_block_template_result_from_post( $post ) { $hooked_blocks = get_hooked_blocks(); if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) { - $before_block_visitor = make_before_block_visitor( $hooked_blocks, $template ); - $after_block_visitor = make_after_block_visitor( $hooked_blocks, $template ); + $before_block_visitor = make_before_block_visitor( $hooked_blocks, $template, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' ); + $after_block_visitor = make_after_block_visitor( $hooked_blocks, $template, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' ); $blocks = parse_blocks( $template->content ); $template->content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor ); } diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php index 986af9a865..6727298d75 100644 --- a/wp-includes/blocks.php +++ b/wp-includes/blocks.php @@ -858,11 +858,11 @@ function get_hooked_blocks() { * @since 6.5.0 * @access private * - * @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 array $hooked_blocks An array of hooked block types, grouped by anchor block and relative position. - * @param WP_Block_Template|array $context The block template, template part, or pattern that the anchor block belongs to. + * @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 array $hooked_blocks An array of hooked block types, grouped by anchor block and relative position. + * @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, $hooked_blocks, $context ) { @@ -949,12 +949,12 @@ function insert_hooked_blocks( &$parsed_anchor_block, $relative_position, $hooke * @since 6.5.0 * @access private * - * @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 array $hooked_blocks An array of hooked block types, grouped by anchor block and relative position. - * @param WP_Block_Template|array $context The block template, template part, or pattern that the anchor block belongs to. - * @return string An empty string. + * @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 array $hooked_blocks An array of hooked block types, grouped by anchor block and relative position. + * @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, $hooked_blocks, $context ) { $anchor_block_type = $parsed_anchor_block['blockName']; @@ -1002,6 +1002,29 @@ function set_ignored_hooked_blocks_metadata( &$parsed_anchor_block, $relative_po return ''; } +/** + * Returns the markup for blocks hooked to the given anchor block in a specific relative position and then + * adds a list of hooked block types to an anchor block's ignored hooked block types. + * + * This function is meant for internal use only. + * + * @since 6.6.0 + * @access private + * + * @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 array $hooked_blocks An array of hooked block types, grouped by anchor block and relative position. + * @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_and_set_ignored_hooked_blocks_metadata( &$parsed_anchor_block, $relative_position, $hooked_blocks, $context ) { + $markup = insert_hooked_blocks( $parsed_anchor_block, $relative_position, $hooked_blocks, $context ); + $markup .= set_ignored_hooked_blocks_metadata( $parsed_anchor_block, $relative_position, $hooked_blocks, $context ); + + return $markup; +} + /** * Returns a function that injects the theme attribute into, and hooked blocks before, a given block. * diff --git a/wp-includes/class-wp-block-patterns-registry.php b/wp-includes/class-wp-block-patterns-registry.php index bee9746da3..6317bc81e5 100644 --- a/wp-includes/class-wp-block-patterns-registry.php +++ b/wp-includes/class-wp-block-patterns-registry.php @@ -174,8 +174,8 @@ final class WP_Block_Patterns_Registry { $before_block_visitor = '_inject_theme_attribute_in_template_part_block'; $after_block_visitor = null; if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) { - $before_block_visitor = make_before_block_visitor( $hooked_blocks, $pattern ); - $after_block_visitor = make_after_block_visitor( $hooked_blocks, $pattern ); + $before_block_visitor = make_before_block_visitor( $hooked_blocks, $pattern, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' ); + $after_block_visitor = make_after_block_visitor( $hooked_blocks, $pattern, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' ); } $blocks = parse_blocks( $content ); $content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor ); diff --git a/wp-includes/version.php b/wp-includes/version.php index e190b872dc..abbffed350 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-alpha-58185'; +$wp_version = '6.6-alpha-58186'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.