Skip to content

Commit

Permalink
Revert "Use gutenberg_extend_block_editor_styles_html"
Browse files Browse the repository at this point in the history
This reverts commit e5d91a66932576f0699ab0df2e2893594734b34a.
  • Loading branch information
oandregal committed Dec 7, 2021
1 parent 3716889 commit 48e4e1e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 0 additions & 5 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -713,17 +713,12 @@ function gutenberg_extend_block_editor_settings_with_fse_theme_flag( $settings )
function gutenberg_extend_block_editor_styles_html() {
global $pagenow;

$gs_css_vars = 'global-styles-css-custom-properties';
wp_register_style( $gs_css_vars, false, array(), true, true );
wp_add_inline_style( $gs_css_vars, wp_get_global_stylesheet( array( 'variables' ) ) );

$script_handles = array();
$style_handles = array(
'wp-block-editor',
'wp-block-library',
'wp-block-library-theme',
'wp-edit-blocks',
$gs_css_vars,
);

if ( 'widgets.php' === $pagenow || 'customize.php' === $pagenow ) {
Expand Down
12 changes: 12 additions & 0 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,16 @@ function gutenberg_global_styles_include_support_for_wp_variables( $allow_css, $
return ! ! preg_match( '/^var\(--wp-[a-zA-Z0-9\-]+\)$/', trim( $parts[1] ) );
}

/**
* Function to enqueue the CSS Custom Properties
* coming from theme.json.
*/
function gutenberg_load_css_custom_properties() {
wp_register_style( 'global-styles-css-custom-properties', false, array(), true, true );
wp_add_inline_style( 'global-styles-css-custom-properties', gutenberg_get_global_stylesheet( array( 'variables' ) ) );
wp_enqueue_style( 'global-styles-css-custom-properties' );
}

// The else clause can be removed when plugin support requires WordPress 5.8.0+.
if ( function_exists( 'get_block_editor_settings' ) ) {
add_filter( 'block_editor_settings_all', 'gutenberg_experimental_global_styles_settings', PHP_INT_MAX );
Expand All @@ -292,3 +302,5 @@ function gutenberg_global_styles_include_support_for_wp_variables( $allow_css, $
add_filter( 'force_filtered_html_on_import', 'gutenberg_global_styles_force_filtered_html_on_import_filter', 999 );
add_filter( 'safecss_filter_attr_allow_css', 'gutenberg_global_styles_include_support_for_wp_variables', 10, 2 );
// This filter needs to be executed last.

add_filter( 'enqueue_block_editor_assets', 'gutenberg_load_css_custom_properties' );

0 comments on commit 48e4e1e

Please sign in to comment.