-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
__default
binding for pattern overrides (#60694)
Co-authored-by: kevin940726 <[email protected]> Co-authored-by: talldan <[email protected]> Co-authored-by: mcsf <[email protected]> Co-authored-by: gziolo <[email protected]> Co-authored-by: SantosGuillamot <[email protected]> Co-authored-by: youknowriad <[email protected]>
- Loading branch information
1 parent
fcedde8
commit db66bc9
Showing
11 changed files
with
245 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
https://github.com/WordPress/wordpress-develop/pull/6694 | ||
|
||
* https://github.com/WordPress/gutenberg/pull/60694 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* Temporary compatibility shims for block APIs present in Gutenberg. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Replace the `__default` block bindings attribute with the full list of supported | ||
* attribute names for pattern overrides. | ||
* | ||
* @param array $parsed_block The full block, including name and attributes. | ||
* | ||
* @return string The parsed block with default binding replace. | ||
*/ | ||
function gutenberg_replace_pattern_override_default_binding( $parsed_block ) { | ||
$supported_block_attrs = array( | ||
'core/paragraph' => array( 'content' ), | ||
'core/heading' => array( 'content' ), | ||
'core/image' => array( 'id', 'url', 'title', 'alt' ), | ||
'core/button' => array( 'url', 'text', 'linkTarget', 'rel' ), | ||
); | ||
|
||
$bindings = $parsed_block['attrs']['metadata']['bindings'] ?? array(); | ||
if ( | ||
isset( $bindings['__default']['source'] ) && | ||
'core/pattern-overrides' === $bindings['__default']['source'] | ||
) { | ||
$updated_bindings = array(); | ||
|
||
// Build an binding array of all supported attributes. | ||
// Note that this also omits the `__default` attribute from the | ||
// resulting array. | ||
foreach ( $supported_block_attrs[ $parsed_block['blockName'] ] as $attribute_name ) { | ||
// Retain any non-pattern override bindings that might be present. | ||
$updated_bindings[ $attribute_name ] = isset( $bindings[ $attribute_name ] ) | ||
? $bindings[ $attribute_name ] | ||
: array( 'source' => 'core/pattern-overrides' ); | ||
} | ||
$parsed_block['attrs']['metadata']['bindings'] = $updated_bindings; | ||
} | ||
|
||
return $parsed_block; | ||
} | ||
|
||
add_filter( 'render_block_data', 'gutenberg_replace_pattern_override_default_binding', 10, 1 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
db66bc9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in db66bc9.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9319763760
📝 Reported issues:
/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js