Skip to content

Commit

Permalink
Avoid running pattern overrides migration in core (#58487)
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Jan 31, 2024
1 parent 702826e commit a341439
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions packages/blocks/src/api/parser/convert-legacy-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,33 +77,37 @@ 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';
}
} );
// The following code is only relevant for the Gutenberg plugin.
// It's a stand-alone if statement for dead-code elimination.
if ( process.env.IS_GUTENBERG_PLUGIN ) {
// 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 a341439

Please sign in to comment.