Make WordPress Core


Ignore:
Timestamp:
08/11/2021 09:06:31 AM (5 years ago)
Author:
gziolo
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions.php

    r51565 r51599  
    10361036                $json = wp_json_encode( $data, 0, 1 );
    10371037                $this->assertFalse( $json );
     1038        }
     1039
     1040        /**
     1041         * @ticket 53238
     1042         */
     1043        function test_wp_json_file_decode() {
     1044                $result = wp_json_file_decode(
     1045                        DIR_TESTDATA . '/blocks/notice/block.json'
     1046                );
     1047
     1048                $this->assertIsObject( $result );
     1049                $this->assertSame( 'tests/notice', $result->name );
     1050        }
     1051
     1052        /**
     1053         * @ticket 53238
     1054         */
     1055        function test_wp_json_file_decode_associative_array() {
     1056                $result = wp_json_file_decode(
     1057                        DIR_TESTDATA . '/blocks/notice/block.json',
     1058                        array( 'associative' => true )
     1059                );
     1060
     1061                $this->assertIsArray( $result );
     1062                $this->assertSame( 'tests/notice', $result['name'] );
    10381063        }
    10391064
Note: See TracChangeset for help on using the changeset viewer.