Skip to content

Commit

Permalink
Patterns" Update the bindings attribs of blocks added during experime…
Browse files Browse the repository at this point in the history
…ntal phase (#58483)

* Update the bindings attribs of blocks added during pattern overrides experimental phase

* Update all the binding attributes

* Minor optimization / code quality change

---------

Co-authored-by: Daniel Richards <[email protected]>
  • Loading branch information
glendaviesnz and talldan authored Jan 31, 2024
1 parent 82e22bf commit 702826e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/blocks/src/api/parser/convert-legacy-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,33 @@ export function convertLegacyBlockNameAndAttributes( name, attributes ) {
newAttributes.legacy = true;
}

// Convert pattern overrides added during experimental phase.
// Only four blocks were supported initially.
// These checks can be removed in WordPress 6.6.
if (
newAttributes.metadata?.bindings &&
( name === 'core/paragraph' ||
name === 'core/heading' ||
name === 'core/image' ||
name === 'core/button' )
) {
const bindings = [
'content',
'url',
'title',
'alt',
'text',
'linkTarget',
];
bindings.forEach( ( binding ) => {
if (
newAttributes.metadata.bindings[ binding ]?.source?.name ===
'pattern_attributes'
) {
newAttributes.metadata.bindings[ binding ].source =
'core/pattern-overrides';
}
} );
}
return [ name, newAttributes ];
}

0 comments on commit 702826e

Please sign in to comment.