Make WordPress Core


Ignore:
Timestamp:
05/24/2021 05:38:59 PM (5 years ago)
Author:
jorgefilipecosta
Message:

Block Editor: Add Global Styles support using theme.json file.

This is the second piece of landing the theme.json processing in WordPress core.
It includes the mechanism that outputs the CSS styles of a theme.json file.

Props nosolosw, youknowriad.
See #53175.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-editor.php

    r50963 r50973  
    244244        );
    245245
    246         $editor_settings['__experimentalFeatures'] = WP_Theme_JSON_Resolver::get_merged_data( $editor_settings )->get_settings();
    247 
     246        $theme_json = WP_Theme_JSON_Resolver::get_merged_data( $editor_settings );
     247
     248        if ( WP_Theme_JSON_Resolver::theme_has_support() ) {
     249                $editor_settings['styles'][] = array( 'css' => $theme_json->get_stylesheet( 'block_styles' ) );
     250                $editor_settings['styles'][] = array(
     251                        'css'                     => $theme_json->get_stylesheet( 'css_variables' ),
     252                        '__experimentalNoWrapper' => true,
     253                );
     254        }
     255
     256        $editor_settings['__experimentalFeatures'] = $theme_json->get_settings();
    248257        // These settings may need to be updated based on data coming from theme.json sources.
    249258        if ( isset( $editor_settings['__experimentalFeatures']['color']['palette'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.