Editor: Add block bindings support for a `__default` attribute for pattern overrides.
Adds handling for a `__default` block binding attribute for pattern overrides that dynamically adds support for all supported block binding attributes. Props talldanwp, petitphp, mukesh27, isabel_brison, kevin940726. Fixes #61333. Built from https://develop.svn.wordpress.org/trunk@58289 git-svn-id: http://core.svn.wordpress.org/trunk@57749 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e9b86ce6d0
commit
d7372c79fc
|
@ -236,6 +236,7 @@ class WP_Block {
|
|||
* block with the values of the `text_custom_field` and `url_custom_field` post meta.
|
||||
*
|
||||
* @since 6.5.0
|
||||
* @since 6.6.0 Handle the `__default` attribute for pattern overrides.
|
||||
*
|
||||
* @return array The computed block attributes for the provided block bindings.
|
||||
*/
|
||||
|
@ -259,7 +260,33 @@ class WP_Block {
|
|||
return $computed_attributes;
|
||||
}
|
||||
|
||||
foreach ( $parsed_block['attrs']['metadata']['bindings'] as $attribute_name => $block_binding ) {
|
||||
$bindings = $parsed_block['attrs']['metadata']['bindings'];
|
||||
|
||||
/*
|
||||
* If the default binding is set for pattern overrides, replace it
|
||||
* with a pattern override binding for all supported attributes.
|
||||
*/
|
||||
if (
|
||||
isset( $bindings['__default']['source'] ) &&
|
||||
'core/pattern-overrides' === $bindings['__default']['source']
|
||||
) {
|
||||
$updated_bindings = array();
|
||||
|
||||
/*
|
||||
* Build a binding array of all supported attributes.
|
||||
* Note that this also omits the `__default` attribute from the
|
||||
* resulting array.
|
||||
*/
|
||||
foreach ( $supported_block_attributes[ $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' );
|
||||
}
|
||||
$bindings = $updated_bindings;
|
||||
}
|
||||
|
||||
foreach ( $bindings as $attribute_name => $block_binding ) {
|
||||
// If the attribute is not in the supported list, process next attribute.
|
||||
if ( ! in_array( $attribute_name, $supported_block_attributes[ $this->name ], true ) ) {
|
||||
continue;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.6-alpha-58288';
|
||||
$wp_version = '6.6-alpha-58289';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue