Make WordPress Core


Ignore:
Timestamp:
04/26/2022 09:48:20 AM (4 years ago)
Author:
gziolo
Message:

Editor: Register 'lock' attribute for every block on the server

Backports changes from https://github.com/WordPress/gutenberg/pull/40468.

The lock attribute needs to be supported by every block, but currently, it is only done on the client site. As a result, it was causing block rendered API requests to fail when blocks are locked.

Props mamaduka, peterwilsoncc.
See #55567.

File:
1 edited

Legend:

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

    r53084 r53268  
    204204     */
    205205    public $style = null;
     206
     207    /**
     208     * Attributes supported by every block.
     209     *
     210     * @since 6.0.0
     211     * @var array
     212     */
     213    const GLOBAL_ATTRIBUTES = array(
     214        'lock' => array( 'type' => 'object' ),
     215    );
    206216
    207217    /**
     
    356366        $args['name'] = $this->name;
    357367
     368        // Setup attributes if needed.
     369        if ( ! isset( $args['attributes'] ) || ! is_array( $args['attributes'] ) ) {
     370            $args['attributes'] = array();
     371        }
     372
     373        // Register core attributes.
     374        foreach ( static::GLOBAL_ATTRIBUTES as $attr_key => $attr_schema ) {
     375            if ( ! array_key_exists( $attr_key, $args['attributes'] ) ) {
     376                $args['attributes'][ $attr_key ] = $attr_schema;
     377            }
     378        }
     379
    358380        /**
    359381         * Filters the arguments for registering a block type.
Note: See TracChangeset for help on using the changeset viewer.