Make WordPress Core


Ignore:
Timestamp:
06/24/2024 08:49:52 AM (10 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/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php

    r58429 r58466  
    266266            }
    267267
    268             // Register theme-defined variations.
    269             WP_Theme_JSON_Resolver::get_theme_data();
    270 
    271             // Register user-defined variations.
    272             if ( ! empty( $config['styles']['blocks']['variations'] ) ) {
    273                 wp_register_block_style_variations_from_theme_json_data( $config['styles']['blocks']['variations'] );
    274             }
     268            // Register theme-defined variations e.g. from block style variation partials under `/styles`.
     269            $variations = WP_Theme_JSON_Resolver::get_style_variations( 'block' );
     270            wp_register_block_style_variations_from_theme_json_partials( $variations );
    275271
    276272            if ( isset( $request['settings'] ) ) {
     
    636632
    637633        $response   = array();
     634
     635        // Register theme-defined variations e.g. from block style variation partials under `/styles`.
     636        $partials = WP_Theme_JSON_Resolver::get_style_variations( 'block' );
     637        wp_register_block_style_variations_from_theme_json_partials( $partials );
     638
    638639        $variations = WP_Theme_JSON_Resolver::get_style_variations();
    639 
    640640        foreach ( $variations as $variation ) {
    641641            $variation_theme_json = new WP_Theme_JSON( $variation );
Note: See TracChangeset for help on using the changeset viewer.