From 2c2b5d0cfdd1036a57e8c3c50f0be32708546bfb Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Mon, 18 Apr 2022 17:10:17 +0000 Subject: [PATCH] Block editor: Prevent styles from being added in the site editor. The site editor, unlike other editors, generates the styles coming from global styles (presets, styles) dynamically in the client. This is because the user can modify any value that we need to consolidate (merge core, theme, and user style preferences). We don't want to have the global styles twice, as it introduces subtle bugs. Props oandregal, youknowriad. See #55567. git-svn-id: https://develop.svn.wordpress.org/trunk@53208 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/block-editor.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/block-editor.php b/src/wp-includes/block-editor.php index c9945eace9..48bf0dad38 100644 --- a/src/wp-includes/block-editor.php +++ b/src/wp-includes/block-editor.php @@ -383,10 +383,12 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex array( 'css' => 'variables', '__unstableType' => 'presets', + 'isGlobalStyles' => true, ), array( 'css' => 'presets', '__unstableType' => 'presets', + 'isGlobalStyles' => true, ), ); foreach ( $presets as $preset_style ) { @@ -401,6 +403,7 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex $block_classes = array( 'css' => 'styles', '__unstableType' => 'theme', + 'isGlobalStyles' => true, ); $actual_css = wp_get_global_stylesheet( array( $block_classes['css'] ) ); if ( '' !== $actual_css ) { @@ -628,6 +631,7 @@ function get_block_editor_theme_styles() { $styles[] = array( 'css' => wp_remote_retrieve_body( $response ), '__unstableType' => 'theme', + 'isGlobalStyles' => false, ); } } else { @@ -637,6 +641,7 @@ function get_block_editor_theme_styles() { 'css' => file_get_contents( $file ), 'baseURL' => get_theme_file_uri( $style ), '__unstableType' => 'theme', + 'isGlobalStyles' => false, ); } }