From 8fbbd54c407c3b653985a61b218afc084d3f556c Mon Sep 17 00:00:00 2001 From: youknowriad Date: Tue, 20 Oct 2020 07:54:10 +0000 Subject: [PATCH] Block Editor: Expose api_version in the block type and the REST endpoint. The new block editor included in 5.6 introduces an api_version property that indicates which block API version the block is using. This commits makes this property available on the block type and the endpoint. Props TimothyBlynJacobs, gziolo. Fixes #51529. Built from https://develop.svn.wordpress.org/trunk@49224 git-svn-id: http://core.svn.wordpress.org/trunk@48986 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/blocks.php | 1 + wp-includes/class-wp-block-type.php | 8 ++++++++ .../endpoints/class-wp-rest-block-types-controller.php | 8 ++++++++ wp-includes/version.php | 2 +- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php index 128e38a7e0..f6e023c67f 100644 --- a/wp-includes/blocks.php +++ b/wp-includes/blocks.php @@ -207,6 +207,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { 'supports' => 'supports', 'styles' => 'styles', 'example' => 'example', + 'apiVersion' => 'api_version', ); foreach ( $property_mappings as $key => $mapped_key ) { diff --git a/wp-includes/class-wp-block-type.php b/wp-includes/class-wp-block-type.php index 79b0e3e6d1..7687d2b931 100644 --- a/wp-includes/class-wp-block-type.php +++ b/wp-includes/class-wp-block-type.php @@ -16,6 +16,14 @@ */ class WP_Block_Type { + /** + * Block API version. + * + * @since 5.6.0 + * @var int + */ + public $api_version = 1; + /** * Block type key. * diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php index 5ae139991d..f34ed6ace9 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php @@ -256,6 +256,7 @@ class WP_REST_Block_Types_Controller extends WP_REST_Controller { $schema = $this->get_item_schema(); $extra_fields = array( + 'api_version', 'name', 'title', 'description', @@ -365,6 +366,13 @@ class WP_REST_Block_Types_Controller extends WP_REST_Controller { 'title' => 'block-type', 'type' => 'object', 'properties' => array( + 'api_version' => array( + 'description' => __( 'Version of block API.' ), + 'type' => 'integer', + 'default' => 1, + 'context' => array( 'embed', 'view', 'edit' ), + 'readonly' => true, + ), 'title' => array( 'description' => __( 'Title of block type.' ), 'type' => 'string', diff --git a/wp-includes/version.php b/wp-includes/version.php index 77257cbf9f..c218862d46 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-49223'; +$wp_version = '5.6-alpha-49224'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.