Make WordPress Core


Ignore:
Timestamp:
06/24/2024 08:49:52 AM (9 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/theme/wpThemeJson.php

    r58444 r58466  
    39323932
    39333933    /**
     3934     * @ticket 61451
     3935     */
     3936    public function test_unwraps_block_style_variations() {
     3937        register_block_style(
     3938            array( 'core/paragraph', 'core/group' ),
     3939            array(
     3940                'name'  => 'myVariation',
     3941                'label' => 'My variation',
     3942            )
     3943        );
     3944
     3945        $input = new WP_Theme_JSON(
     3946            array(
     3947                'version' => WP_Theme_JSON::LATEST_SCHEMA,
     3948                'styles'  => array(
     3949                    'variations' => array(
     3950                        'myVariation' => array(
     3951                            'color'      => array(
     3952                                'background' => 'topLevel',
     3953                                'gradient'   => 'topLevel',
     3954                            ),
     3955                            'typography' => array(
     3956                                'fontFamily' => 'topLevel',
     3957                            ),
     3958                        ),
     3959                    ),
     3960                    'blocks'     => array(
     3961                        'core/paragraph' => array(
     3962                            'variations' => array(
     3963                                'myVariation' => array(
     3964                                    'color'   => array(
     3965                                        'background' => 'blockLevel',
     3966                                        'text'       => 'blockLevel',
     3967                                    ),
     3968                                    'outline' => array(
     3969                                        'offset' => 'blockLevel',
     3970                                    ),
     3971                                ),
     3972                            ),
     3973                        ),
     3974                    ),
     3975                ),
     3976            )
     3977        );
     3978
     3979        $expected = array(
     3980            'version' => WP_Theme_JSON::LATEST_SCHEMA,
     3981            'styles'  => array(
     3982                'blocks' => array(
     3983                    'core/paragraph' => array(
     3984                        'variations' => array(
     3985                            'myVariation' => array(
     3986                                'color'      => array(
     3987                                    'background' => 'blockLevel',
     3988                                    'gradient'   => 'topLevel',
     3989                                    'text'       => 'blockLevel',
     3990                                ),
     3991                                'typography' => array(
     3992                                    'fontFamily' => 'topLevel',
     3993                                ),
     3994                                'outline'    => array(
     3995                                    'offset' => 'blockLevel',
     3996                                ),
     3997                            ),
     3998                        ),
     3999                    ),
     4000                    'core/group'     => array(
     4001                        'variations' => array(
     4002                            'myVariation' => array(
     4003                                'color'      => array(
     4004                                    'background' => 'topLevel',
     4005                                    'gradient'   => 'topLevel',
     4006                                ),
     4007                                'typography' => array(
     4008                                    'fontFamily' => 'topLevel',
     4009                                ),
     4010                            ),
     4011                        ),
     4012                    ),
     4013                ),
     4014            ),
     4015        );
     4016        $this->assertSameSetsWithIndex( $expected, $input->get_raw_data(), 'Unwrapped block style variations do not match' );
     4017    }
     4018
     4019    /**
    39344020     * @ticket 57583
    39354021     *
Note: See TracChangeset for help on using the changeset viewer.