Skip to content

Commit ec6ec9e

Browse files
authored
Sync with feedback from WordPress/wordpress-develop#10248 (#73570)
Co-authored-by: ramonjd <[email protected]>
1 parent f8d0933 commit ec6ec9e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/compat/wordpress-7.0/blocks.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,28 @@ function gutenberg_resolve_pattern_blocks( $blocks ) {
5252
$blocks_to_insert = parse_blocks( trim( $pattern['content'] ) );
5353

5454
/*
55-
* For single-root patterns, add the pattern name to make this a pattern instance in the editor.
56-
* If the pattern has metadata, merge it with the existing metadata.
57-
*/
55+
* For single-root patterns, add the pattern name to make this a pattern instance in the editor.
56+
* If the pattern has metadata, merge it with the existing metadata.
57+
*/
5858
if ( count( $blocks_to_insert ) === 1 ) {
5959
$block_metadata = $blocks_to_insert[0]['attrs']['metadata'] ?? array();
6060
$block_metadata['patternName'] = $slug;
6161

6262
/*
63-
* Merge pattern metadata with existing block metadata.
64-
* Pattern metadata takes precedence, but existing block metadata
65-
* is preserved as a fallback when the pattern doesn't define that field.
66-
* Only the defined fields (name, description, categories) are updated;
67-
* other metadata keys are preserved.
68-
*/
63+
* Merge pattern metadata with existing block metadata.
64+
* Pattern metadata takes precedence, but existing block metadata
65+
* is preserved as a fallback when the pattern doesn't define that field.
66+
* Only the defined fields (name, description, categories) are updated;
67+
* other metadata keys are preserved.
68+
*/
6969
foreach ( array(
7070
'name' => 'title', // 'title' is the field in the pattern object 'name' is the field in the block metadata.
7171
'description' => 'description',
7272
'categories' => 'categories',
7373
) as $key => $pattern_key ) {
7474
$value = $pattern[ $pattern_key ] ?? $block_metadata[ $key ] ?? null;
7575
if ( $value ) {
76-
$block_metadata[ $key ] = 'categories' === $key && is_array( $value )
76+
$block_metadata[ $key ] = is_array( $value )
7777
? array_map( 'sanitize_text_field', $value )
7878
: sanitize_text_field( $value );
7979
}

0 commit comments

Comments
 (0)