Skip to content

Commit

Permalink
Block editor: Prevent styles from being added in the site editor.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jorgefilipecosta committed Apr 18, 2022
1 parent a7b2e1b commit 2c2b5d0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/wp-includes/block-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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 ) {
Expand Down Expand Up @@ -628,6 +631,7 @@ function get_block_editor_theme_styles() {
$styles[] = array(
'css' => wp_remote_retrieve_body( $response ),
'__unstableType' => 'theme',
'isGlobalStyles' => false,
);
}
} else {
Expand All @@ -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,
);
}
}
Expand Down

0 comments on commit 2c2b5d0

Please sign in to comment.