plugin updates
This commit is contained in:
@@ -158,31 +158,6 @@ final class WP_Block_Patterns_Registry {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -221,8 +196,12 @@ final class WP_Block_Patterns_Registry {
|
||||
}
|
||||
|
||||
$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 @@ final class WP_Block_Patterns_Registry {
|
||||
$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 );
|
||||
|
||||
Reference in New Issue
Block a user