Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/compat/wordpress-6.1/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}
Expand All @@ -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;
}

Expand All @@ -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' );