Make WordPress Core


Ignore:
Timestamp:
09/26/2024 02:49:13 PM (18 months ago)
Author:
cbravobernal
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block.php

    r59080 r59095  
    238238     * @since 6.5.0
    239239     * @since 6.6.0 Handle the `__default` attribute for pattern overrides.
     240     * @since 6.7.0 Return any updated bindings metadata in the computed attributes.
    240241     *
    241242     * @return array The computed block attributes for the provided block bindings.
     
    285286            }
    286287            $bindings = $updated_bindings;
     288            /*
     289             * Update the bindings metadata of the computed attributes.
     290             * This ensures the block receives the expanded __default binding metadata when it renders.
     291             */
     292            $computed_attributes['metadata'] = array_merge(
     293                $parsed_block['attrs']['metadata'],
     294                array( 'bindings' => $bindings )
     295            );
    287296        }
    288297
Note: See TracChangeset for help on using the changeset viewer.