Make WordPress Core


Ignore:
Timestamp:
06/24/2024 08:49:52 AM (13 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/rest-api/rest-global-styles-controller.php

    r58394 r58466  
    610610     * @covers WP_REST_Global_Styles_Controller_Gutenberg::update_item
    611611     * @ticket 61312
     612     * @ticket 61451
    612613     */
    613614    public function test_update_item_with_custom_block_style_variations() {
     
    616617            grant_super_admin( self::$admin_id );
    617618        }
     619
     620        /*
     621         * For variations to be resolved they have to have been registered
     622         * via either a theme.json partial or through the WP_Block_Styles_Registry.
     623         */
     624        register_block_style(
     625            'core/group',
     626            array(
     627                'name'  => 'fromThemeStyleVariation',
     628                'label' => 'From Theme Style Variation',
     629            )
     630        );
    618631
    619632        $group_variations = array(
     
    630643            array(
    631644                'styles' => array(
    632                     'blocks' => array(
    633                         'variations' => array(
    634                             'fromThemeStyleVariation' => array(
    635                                 'blockTypes' => array( 'core/group', 'core/columns' ),
    636                                 'color'      => array(
    637                                     'background' => '#000000',
    638                                     'text'       => '#ffffff',
    639                                 ),
     645                    'variations' => array(
     646                        'fromThemeStyleVariation' => array(
     647                            'blockTypes' => array( 'core/group', 'core/columns' ),
     648                            'color'      => array(
     649                                'background' => '#000000',
     650                                'text'       => '#ffffff',
    640651                            ),
    641652                        ),
     653                    ),
     654                    'blocks'     => array(
    642655                        'core/group' => array(
    643656                            'variations' => $group_variations,
Note: See TracChangeset for help on using the changeset viewer.