Make WordPress Core


Ignore:
Timestamp:
08/11/2021 09:06:31 AM (4 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/theme/wpThemeJsonResolver.php

    r51568 r51599  
    4343    public function filter_set_locale_to_polish() {
    4444        return 'pl_PL';
    45     }
    46 
    47     /**
    48      * @ticket 52991
    49      */
    50     public function test_fields_are_extracted() {
    51         $actual = WP_Theme_JSON_Resolver::get_fields_to_translate();
    52 
    53         $expected = array(
    54             array(
    55                 'path'    => array( 'settings', 'typography', 'fontSizes' ),
    56                 'key'     => 'name',
    57                 'context' => 'Font size name',
    58             ),
    59             array(
    60                 'path'    => array( 'settings', 'color', 'palette' ),
    61                 'key'     => 'name',
    62                 'context' => 'Color name',
    63             ),
    64             array(
    65                 'path'    => array( 'settings', 'color', 'gradients' ),
    66                 'key'     => 'name',
    67                 'context' => 'Gradient name',
    68             ),
    69             array(
    70                 'path'    => array( 'settings', 'color', 'duotone' ),
    71                 'key'     => 'name',
    72                 'context' => 'Duotone name',
    73             ),
    74             array(
    75                 'path'    => array( 'settings', 'blocks', '*', 'typography', 'fontSizes' ),
    76                 'key'     => 'name',
    77                 'context' => 'Font size name',
    78             ),
    79             array(
    80                 'path'    => array( 'settings', 'blocks', '*', 'color', 'palette' ),
    81                 'key'     => 'name',
    82                 'context' => 'Color name',
    83             ),
    84             array(
    85                 'path'    => array( 'settings', 'blocks', '*', 'color', 'gradients' ),
    86                 'key'     => 'name',
    87                 'context' => 'Gradient name',
    88             ),
    89         );
    90 
    91         $this->assertSame( $expected, $actual );
    9245    }
    9346
Note: See TracChangeset for help on using the changeset viewer.