Global Styles: Load the global styles before the theme styles in the editor.

This commit makes the site editor follow what we do in the front-end, where theme styles are loaded after global styles by default.

Props oandregal, ntsekouras.
Fixes .

git-svn-id: https://develop.svn.wordpress.org/trunk@52752 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jorge Costa 2022-02-17 14:12:59 +00:00
parent d2b385b7b8
commit dd60c77928
2 changed files with 8 additions and 6 deletions

@ -191,7 +191,6 @@ $editor_settings = array(
'titlePlaceholder' => apply_filters( 'enter_title_here', __( 'Add title' ), $post ),
'bodyPlaceholder' => $body_placeholder,
'autosaveInterval' => AUTOSAVE_INTERVAL,
'styles' => get_block_editor_theme_styles(),
'richEditingEnabled' => user_can_richedit(),
'postLock' => $lock_details,
'postLockUtils' => array(

@ -307,7 +307,8 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
$custom_settings
);
$presets = array(
$global_styles = array();
$presets = array(
array(
'css' => 'variables',
'__unstableType' => 'presets',
@ -320,8 +321,8 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
foreach ( $presets as $preset_style ) {
$actual_css = wp_get_global_stylesheet( array( $preset_style['css'] ) );
if ( '' !== $actual_css ) {
$preset_style['css'] = $actual_css;
$editor_settings['styles'][] = $preset_style;
$preset_style['css'] = $actual_css;
$global_styles[] = $preset_style;
}
}
@ -332,11 +333,13 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
);
$actual_css = wp_get_global_stylesheet( array( $block_classes['css'] ) );
if ( '' !== $actual_css ) {
$block_classes['css'] = $actual_css;
$editor_settings['styles'][] = $block_classes;
$block_classes['css'] = $actual_css;
$global_styles[] = $block_classes;
}
}
$editor_settings['styles'] = array_merge( $global_styles, get_block_editor_theme_styles() );
$editor_settings['__experimentalFeatures'] = wp_get_global_settings();
// These settings may need to be updated based on data coming from theme.json sources.
if ( isset( $editor_settings['__experimentalFeatures']['color']['palette'] ) ) {