- Timestamp:
- 09/27/2024 09:18:46 AM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-block-patterns-registry.php
r58186 r59101 160 160 161 161 /** 162 * Prepares the content of a block pattern. If hooked blocks are registered, they get injected into the pattern,163 * when they met the defined criteria.164 *165 * @since 6.4.0166 *167 * @param array $pattern Registered pattern properties.168 * @param array $hooked_blocks The list of hooked blocks.169 * @return string The content of the block pattern.170 */171 private function prepare_content( $pattern, $hooked_blocks ) {172 $content = $pattern['content'];173 174 $before_block_visitor = '_inject_theme_attribute_in_template_part_block';175 $after_block_visitor = null;176 if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) {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 }180 $blocks = parse_blocks( $content );181 $content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor );182 183 return $content;184 }185 186 /**187 162 * Retrieves the content of a registered block pattern. 188 163 * … … 222 197 223 198 $pattern = $this->registered_patterns[ $pattern_name ]; 224 $pattern['content'] = $this->get_content( $pattern_name ); 225 $pattern['content'] = $this->prepare_content( $pattern, get_hooked_blocks() ); 199 $content = $this->get_content( $pattern_name ); 200 $pattern['content'] = apply_block_hooks_to_content( 201 $content, 202 $pattern, 203 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' 204 ); 226 205 227 206 return $pattern; … … 244 223 245 224 foreach ( $patterns as $index => $pattern ) { 246 $pattern['content'] = $this->get_content( $pattern['name'], $outside_init_only ); 247 $patterns[ $index ]['content'] = $this->prepare_content( $pattern, $hooked_blocks ); 225 $content = $this->get_content( $pattern['name'], $outside_init_only ); 226 $patterns[ $index ]['content'] = apply_block_hooks_to_content( 227 $content, 228 $pattern, 229 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' 230 ); 248 231 } 249 232
Note: See TracChangeset
for help on using the changeset viewer.