From 900367bc7a153c2910c1a7977824dbeb759f5756 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Tue, 8 Jun 2021 08:14:59 +0000 Subject: [PATCH] Block Editor: Add a type property to allow Core to identify the source of the editor styles. Gutenberg plugin need to override the editor styles provided by core selectively, this added property allows it to do so without committing to a public API. Props nosolosw, jorgefilipecosta. See #53175. git-svn-id: https://develop.svn.wordpress.org/trunk@51090 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/edit-form-blocks.php | 11 +++++++---- src/wp-includes/block-editor.php | 6 +++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index 3aead40a7b..71328d0ad5 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -131,7 +131,8 @@ $available_templates = ! empty( $available_templates ) ? array_merge( // Editor Styles. $styles = array( array( - 'css' => 'body { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif }', + 'css' => 'body { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif }', + '__unstableType' => 'core', ), ); if ( $editor_styles && current_theme_supports( 'editor-styles' ) ) { @@ -140,15 +141,17 @@ if ( $editor_styles && current_theme_supports( 'editor-styles' ) ) { $response = wp_remote_get( $style ); if ( ! is_wp_error( $response ) ) { $styles[] = array( - 'css' => wp_remote_retrieve_body( $response ), + 'css' => wp_remote_retrieve_body( $response ), + '__unstableType' => 'theme', ); } } else { $file = get_theme_file_path( $style ); if ( is_file( $file ) ) { $styles[] = array( - 'css' => file_get_contents( $file ), - 'baseURL' => get_theme_file_uri( $style ), + 'css' => file_get_contents( $file ), + 'baseURL' => get_theme_file_uri( $style ), + '__unstableType' => 'theme', ); } } diff --git a/src/wp-includes/block-editor.php b/src/wp-includes/block-editor.php index 3234c4ad1f..101cc1ba71 100644 --- a/src/wp-includes/block-editor.php +++ b/src/wp-includes/block-editor.php @@ -283,10 +283,14 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex $theme_json = WP_Theme_JSON_Resolver::get_merged_data( $editor_settings ); if ( WP_Theme_JSON_Resolver::theme_has_support() ) { - $editor_settings['styles'][] = array( 'css' => $theme_json->get_stylesheet( 'block_styles' ) ); + $editor_settings['styles'][] = array( + 'css' => $theme_json->get_stylesheet( 'block_styles' ), + '__unstableType' => 'globalStyles', + ); $editor_settings['styles'][] = array( 'css' => $theme_json->get_stylesheet( 'css_variables' ), '__experimentalNoWrapper' => true, + '__unstableType' => 'globalStyles', ); }