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.



git-svn-id: https://develop.svn.wordpress.org/trunk@49224 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Riad Benguella
2020-10-20 07:52:06 +00:00
parent af767035e7
commit 123a965c70
6 changed files with 22 additions and 1 deletions
@@ -1,4 +1,5 @@
{
"apiVersion": 2,
"name": "my-plugin/notice",
"title": "Notice",
"category": "common",
+1
View File
@@ -285,6 +285,7 @@ class WP_Test_Block_Register extends WP_UnitTestCase {
);
$this->assertInstanceOf( 'WP_Block_Type', $result );
$this->assertSame( 2, $result->api_version );
$this->assertSame( 'my-plugin/notice', $result->name );
$this->assertSame( 'Notice', $result->title );
$this->assertSame( 'common', $result->category );
@@ -312,7 +312,8 @@ class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase {
$response = rest_get_server()->dispatch( $request );
$data = $response->get_data();
$properties = $data['schema']['properties'];
$this->assertCount( 19, $properties );
$this->assertCount( 20, $properties );
$this->assertArrayHasKey( 'api_version', $properties );
$this->assertArrayHasKey( 'title', $properties );
$this->assertArrayHasKey( 'icon', $properties );
$this->assertArrayHasKey( 'description', $properties );
@@ -431,6 +432,7 @@ class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase {
$this->assertSame( $data['is_dynamic'], $block_type->is_dynamic() );
$extra_fields = array(
'api_version',
'name',
'category',
'editor_script',