Make WordPress Core


Ignore:
Timestamp:
06/24/2024 08:49:52 AM (17 months ago)
Author:
oandregal
Message:

Section styles: improve performance and conceptual consistency.

These changes involve:

  • Move shared variation definitions from styles.blocks.variations to styles.variations
  • Remove blockTypes from styles.variations.
  • Do not register shared variations from theme style variation or primary theme.json files.
  • Move the merging of theme.json data into the WP_Theme_JSON_Resolver and WP_Theme_JSON classes.

These changes improve performance and are more future-proof API wise.
See conversation at https://github.com/WordPress/gutenberg/issues/62686

Props aaronrobertshaw, oandregal, andrewserong, joemcgill, talldanwp, andrewserong, ramonopoly, richtabor, youknowriad.

See #61312, #61451.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/block-supports/block-style-variations.php

    r58429 r58466  
    6363     * @ticket 61312
    6464     * @ticket 61440
     65     * @ticket 61451
    6566     */
    6667    public function test_add_registered_block_styles_to_theme_data() {
    6768        switch_theme( 'block-theme' );
    68 
    69         // Register theme-defined variations.
    70         WP_Theme_JSON_Resolver::get_theme_data();
    71         // Register user-defined variations.
    72         WP_Theme_JSON_Resolver::get_user_data();
    7369
    7470        $variation_styles_data = array(
     
    126122        $expected     = array(
    127123            'variations' => array(
    128                 // @ticket 61440
    129                 'WithSlug'                => array(
    130                     'color' => array(
    131                         'background' => 'aliceblue',
    132                         'text'       => 'midnightblue',
    133                     ),
    134                 ),
    135                 'my-variation'            => $variation_styles_data,
    136124
    137125                /*
     
    152140                    ),
    153141                ),
     142
     143                /*
     144                 * Manually registered variations.
     145                 * @ticket 61440
     146                 */
     147                'WithSlug'                => array(
     148                    'color' => array(
     149                        'background' => 'aliceblue',
     150                        'text'       => 'midnightblue',
     151                    ),
     152                ),
     153                'my-variation'            => $variation_styles_data,
    154154            ),
    155155        );
     
    158158        unregister_block_style( 'core/group', 'WithSlug' );
    159159
    160         $this->assertSameSetsWithIndex( $expected, $group_styles );
     160        $this->assertSameSetsWithIndex( $expected, $group_styles, 'Variation data does not match' );
    161161    }
    162162}
Note: See TracChangeset for help on using the changeset viewer.