Make WordPress Core


Ignore:
Timestamp:
11/08/2021 09:44:12 PM (3 years ago)
Author:
jorgefilipecosta
Message:

Add: Public functions for interacting with global styles & settings.

This commit ports the public functions to interact with the global styles & settings.

See #54336.
Props oandregal.

File:
1 edited

Legend:

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

    r52049 r52054  
    304304    );
    305305
    306     $theme_json = WP_Theme_JSON_Resolver::get_merged_data();
     306    $presets = array(
     307        array(
     308            'css'                     => 'variables',
     309            '__unstableType'          => 'presets',
     310            '__experimentalNoWrapper' => true,
     311        ),
     312        array(
     313            'css'            => 'presets',
     314            '__unstableType' => 'presets',
     315        ),
     316    );
     317    foreach ( $presets as $preset_style ) {
     318        $actual_css = wp_get_global_stylesheet( array( $preset_style['css'] ) );
     319        if ( '' !== $actual_css ) {
     320            $preset_style['css']         = $actual_css;
     321            $editor_settings['styles'][] = $preset_style;
     322        }
     323    }
    307324
    308325    if ( WP_Theme_JSON_Resolver::theme_has_support() ) {
    309         $editor_settings['styles'][] = array(
    310             'css'            => $theme_json->get_stylesheet( array( 'styles', 'presets' ) ),
    311             '__unstableType' => 'globalStyles',
     326        $block_classes = array(
     327            'css'            => 'styles',
     328            '__unstableType' => 'theme',
    312329        );
    313         $editor_settings['styles'][] = array(
    314             'css'                     => $theme_json->get_stylesheet( array( 'variables' ) ),
    315             '__experimentalNoWrapper' => true,
    316             '__unstableType'          => 'globalStyles',
    317         );
    318     }
    319 
    320     $editor_settings['__experimentalFeatures'] = $theme_json->get_settings();
     330        $actual_css    = wp_get_global_stylesheet( array( $block_classes['css'] ) );
     331        if ( '' !== $actual_css ) {
     332            $block_classes['css'] = $actual_css;
     333            $editor_settings['styles'][] = $block_classes;
     334        }
     335    }
     336
     337    $editor_settings['__experimentalFeatures'] = wp_get_global_settings();
    321338    // These settings may need to be updated based on data coming from theme.json sources.
    322339    if ( isset( $editor_settings['__experimentalFeatures']['color']['palette'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.