Block bindings: Ensure block receives __default bindings when render.

Fixes an issue with the image block when using pattern overrides, where the image block with overrides enabled was not outputting all the expected image attributes. Ensures that the `process_block_bindings` method returns any updates to the block's binding metadata along with other computed attributes.

Props talldanwp, cbravobernal, santosguillamot, mukesh27, gziolo.

Fixes #62069.


Built from https://develop.svn.wordpress.org/trunk@59095


git-svn-id: http://core.svn.wordpress.org/trunk@58491 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
cbravobernal 2024-09-26 14:51:18 +00:00
parent 5e4a97f589
commit 23e8ce70f0
2 changed files with 10 additions and 1 deletions

View File

@ -237,6 +237,7 @@ class WP_Block {
*
* @since 6.5.0
* @since 6.6.0 Handle the `__default` attribute for pattern overrides.
* @since 6.7.0 Return any updated bindings metadata in the computed attributes.
*
* @return array The computed block attributes for the provided block bindings.
*/
@ -284,6 +285,14 @@ class WP_Block {
: array( 'source' => 'core/pattern-overrides' );
}
$bindings = $updated_bindings;
/*
* Update the bindings metadata of the computed attributes.
* This ensures the block receives the expanded __default binding metadata when it renders.
*/
$computed_attributes['metadata'] = array_merge(
$parsed_block['attrs']['metadata'],
array( 'bindings' => $bindings )
);
}
foreach ( $bindings as $attribute_name => $block_binding ) {

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-alpha-59094';
$wp_version = '6.7-alpha-59095';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.