Block Types: Add metadata global attribute.

Add a new global attribute (i.e. an attribute that can be added to all and any blocks) called `metadata`. This is required for use cases such as allowing the user to assign custom names to blocks, or for making Block Hooks work with user-modified templates/parts/patterns (#59646).

Props Mamaduka, gziolo, get_dave.
Fixes #59797.

git-svn-id: https://develop.svn.wordpress.org/trunk@57068 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Bernie Reiter
2023-11-06 14:45:28 +00:00
parent 69e85003d5
commit 2a93cafb52
6 changed files with 28 additions and 10 deletions

View File

@@ -242,11 +242,13 @@ class WP_Block_Type {
/**
* Attributes supported by every block.
*
* @since 6.0.0
* @since 6.0.0 Added `lock`.
* @since 6.5.0 Added `metadata`.
* @var array
*/
const GLOBAL_ATTRIBUTES = array(
'lock' => array( 'type' => 'object' ),
'lock' => array( 'type' => 'object' ),
'metadata' => array( 'type' => 'object' ),
);
/**