Make WordPress Core


Ignore:
Timestamp:
11/06/2023 02:45:28 PM (19 months ago)
Author:
Bernhard Reiter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/blocks/wpBlockType.php

    r55457 r57068  
    8181    /*
    8282     * @ticket 55567
     83     * @ticket 59797
    8384     * @covers WP_Block_Type::set_props
    8485     */
     
    8889        $this->assertSameSetsWithIndex(
    8990            array(
    90                 'lock' => array( 'type' => 'object' ),
     91                'lock'     => array( 'type' => 'object' ),
     92                'metadata' => array( 'type' => 'object' ),
    9193            ),
    9294            $block_type->attributes
     
    9698    /*
    9799     * @ticket 55567
     100     * @ticket 59797
    98101     * @covers WP_Block_Type::set_props
    99102     */
     
    103106            array(
    104107                'attributes' => array(
    105                     'lock' => array(
     108                    'lock'     => array(
    106109                        'type' => 'string',
     110                    ),
     111                    'metadata' => array(
     112                        'type' => 'number',
    107113                    ),
    108114                ),
     
    113119        $this->assertSameSetsWithIndex(
    114120            array(
    115                 'lock' => array( 'type' => 'string' ),
     121                'lock'     => array( 'type' => 'string' ),
     122                'metadata' => array( 'type' => 'number' ),
    116123            ),
    117124            $block_type->attributes
Note: See TracChangeset for help on using the changeset viewer.