diff --git a/lib/compat/wordpress-6.1/script-loader.php b/lib/compat/wordpress-6.1/script-loader.php index 4948882c113a88..d554dbf7faf04a 100644 --- a/lib/compat/wordpress-6.1/script-loader.php +++ b/lib/compat/wordpress-6.1/script-loader.php @@ -86,7 +86,7 @@ function gutenberg_enqueue_global_styles() { * This is needed for backwards compatibility for button blocks specifically. */ function gutenberg_enqueue_classic_theme_styles() { - if ( ! wp_is_block_theme() ) { + if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) { wp_register_style( 'classic-theme-styles', gutenberg_url( 'build/block-library/classic.css' ), array(), true ); wp_enqueue_style( 'classic-theme-styles' ); } @@ -104,7 +104,7 @@ function gutenberg_enqueue_classic_theme_styles() { * @return array A filtered array of editor settings. */ function gutenberg_add_editor_classic_theme_styles( $editor_settings ) { - if ( wp_is_block_theme() ) { + if ( WP_Theme_JSON_Resolver::theme_has_support() ) { return $editor_settings; } @@ -113,13 +113,15 @@ function gutenberg_add_editor_classic_theme_styles( $editor_settings ) { // This follows the pattern of get_block_editor_theme_styles, // but we can't use get_block_editor_theme_styles directly as it // only handles external files or theme files. - $editor_settings['styles'][] = array( + $classic_theme_styles_settings = array( 'css' => file_get_contents( $classic_theme_styles ), - 'baseURL' => get_theme_file_uri( $classic_theme_styles ), - '__unstableType' => 'theme', + '__unstableType' => 'core', 'isGlobalStyles' => false, ); + // Add these settings to the start of the array so that themes can override them. + array_unshift( $editor_settings['styles'], $classic_theme_styles_settings ); + return $editor_settings; } add_filter( 'block_editor_settings_all', 'gutenberg_add_editor_classic_theme_styles' );