Blocks: Add support for variations in block.json` file

We integrated variations with block types and the corresponding REST API endpoint in #52688. It's a follow-up patch to add missing support to the `block.json` metadata file when using `register_block_type`.

Some fields for variations are translatable.Therefore, i18n schema was copied over from Gutenberg: https://github.com/WordPress/gutenberg/blob/trunk/packages/blocks/src/api/i18n-block.json. The accompanying implementation was adapted as `translate_settings_using_i18n_schema`.

Props: gwwar, swissspidy, schlessera, jorgefilipecosta.
Fixes #53238.



git-svn-id: https://develop.svn.wordpress.org/trunk@51599 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Greg Ziółkowski
2021-08-11 09:06:31 +00:00
parent 9b565f7907
commit d9599addd1
11 changed files with 326 additions and 244 deletions

View File

@@ -1037,6 +1037,31 @@ class Tests_Functions extends WP_UnitTestCase {
$this->assertFalse( $json );
}
/**
* @ticket 53238
*/
function test_wp_json_file_decode() {
$result = wp_json_file_decode(
DIR_TESTDATA . '/blocks/notice/block.json'
);
$this->assertIsObject( $result );
$this->assertSame( 'tests/notice', $result->name );
}
/**
* @ticket 53238
*/
function test_wp_json_file_decode_associative_array() {
$result = wp_json_file_decode(
DIR_TESTDATA . '/blocks/notice/block.json',
array( 'associative' => true )
);
$this->assertIsArray( $result );
$this->assertSame( 'tests/notice', $result['name'] );
}
/**
* @ticket 36054
* @dataProvider datetime_provider