From 1dabd8df68087cb34e86533b8118c35cad5427ad Mon Sep 17 00:00:00 2001 From: gziolo Date: Tue, 26 Apr 2022 09:50:12 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@53268 git-svn-id: http://core.svn.wordpress.org/trunk@52857 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-block-type.php | 22 ++++++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-block-type.php b/wp-includes/class-wp-block-type.php index 47e6619fe2..6902b36773 100644 --- a/wp-includes/class-wp-block-type.php +++ b/wp-includes/class-wp-block-type.php @@ -204,6 +204,16 @@ class WP_Block_Type { */ public $style = null; + /** + * Attributes supported by every block. + * + * @since 6.0.0 + * @var array + */ + const GLOBAL_ATTRIBUTES = array( + 'lock' => array( 'type' => 'object' ), + ); + /** * Constructor. * @@ -355,6 +365,18 @@ class WP_Block_Type { $args['name'] = $this->name; + // Setup attributes if needed. + if ( ! isset( $args['attributes'] ) || ! is_array( $args['attributes'] ) ) { + $args['attributes'] = array(); + } + + // Register core attributes. + foreach ( static::GLOBAL_ATTRIBUTES as $attr_key => $attr_schema ) { + if ( ! array_key_exists( $attr_key, $args['attributes'] ) ) { + $args['attributes'][ $attr_key ] = $attr_schema; + } + } + /** * Filters the arguments for registering a block type. * diff --git a/wp-includes/version.php b/wp-includes/version.php index c9743983f1..4e456c655b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-beta2-53267'; +$wp_version = '6.0-beta2-53268'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.