@@ -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