--- a/wp/wp-includes/class-wp-block-patterns-registry.php Fri Sep 05 18:40:08 2025 +0200
+++ b/wp/wp-includes/class-wp-block-patterns-registry.php Fri Sep 05 18:52:52 2025 +0200
@@ -159,31 +159,6 @@
}
/**
- * Prepares the content of a block pattern. If hooked blocks are registered, they get injected into the pattern,
- * when they met the defined criteria.
- *
- * @since 6.4.0
- *
- * @param array $pattern Registered pattern properties.
- * @param array $hooked_blocks The list of hooked blocks.
- * @return string The content of the block pattern.
- */
- private function prepare_content( $pattern, $hooked_blocks ) {
- $content = $pattern['content'];
-
- $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, '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 );
-
- return $content;
- }
-
- /**
* Retrieves the content of a registered block pattern.
*
* @since 6.5.0
@@ -221,8 +196,12 @@
}
$pattern = $this->registered_patterns[ $pattern_name ];
- $pattern['content'] = $this->get_content( $pattern_name );
- $pattern['content'] = $this->prepare_content( $pattern, get_hooked_blocks() );
+ $content = $this->get_content( $pattern_name );
+ $pattern['content'] = apply_block_hooks_to_content(
+ $content,
+ $pattern,
+ 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata'
+ );
return $pattern;
}
@@ -243,8 +222,12 @@
$hooked_blocks = get_hooked_blocks();
foreach ( $patterns as $index => $pattern ) {
- $pattern['content'] = $this->get_content( $pattern['name'], $outside_init_only );
- $patterns[ $index ]['content'] = $this->prepare_content( $pattern, $hooked_blocks );
+ $content = $this->get_content( $pattern['name'], $outside_init_only );
+ $patterns[ $index ]['content'] = apply_block_hooks_to_content(
+ $content,
+ $pattern,
+ 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata'
+ );
}
return array_values( $patterns );