Make WordPress Core

Changeset 52054


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.

Location:
trunk/src
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/load-styles.php

    r51056 r52054  
    1919require ABSPATH . WPINC . '/theme.php';
    2020require ABSPATH . WPINC . '/class-wp-theme-json-resolver.php';
     21require ABSPATH . WPINC . '/global-styles-and-settings.php';
    2122require ABSPATH . WPINC . '/script-loader.php';
    2223require ABSPATH . WPINC . '/version.php';
  • 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'] ) ) {
  • trunk/src/wp-includes/script-loader.php

    r52049 r52054  
    23042304    }
    23052305
    2306     $can_use_cache = (
    2307         ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) &&
    2308         ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) &&
    2309         ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) &&
    2310         ! is_admin()
    2311     );
    2312 
    2313     $stylesheet     = null;
    2314     $transient_name = 'global_styles_' . get_stylesheet();
    2315 
    2316     if ( $can_use_cache ) {
    2317         $cache = get_transient( $transient_name );
    2318         if ( $cache ) {
    2319             $stylesheet = $cache;
    2320         }
    2321     }
    2322 
    2323     if ( null === $stylesheet ) {
    2324         $theme_json = WP_Theme_JSON_Resolver::get_merged_data();
    2325         $stylesheet = $theme_json->get_stylesheet();
    2326 
    2327         if ( $can_use_cache ) {
    2328             set_transient( $transient_name, $stylesheet, MINUTE_IN_SECONDS );
    2329         }
    2330     }
     2306    $stylesheet = wp_get_global_stylesheet();
    23312307
    23322308    if ( empty( $stylesheet ) ) {
  • trunk/src/wp-settings.php

    r52051 r52054  
    174174require ABSPATH . WPINC . '/class-wp-theme-json.php';
    175175require ABSPATH . WPINC . '/class-wp-theme-json-resolver.php';
     176require ABSPATH . WPINC . '/global-styles-and-settings.php';
    176177require ABSPATH . WPINC . '/class-wp-block-template.php';
    177178require ABSPATH . WPINC . '/block-template-utils.php';
Note: See TracChangeset for help on using the changeset viewer.