Skip to content

Commit

Permalink
Editor: Reintroduce styles that were removed for classic themes.
Browse files Browse the repository at this point in the history
After block CSS was merged with `theme.json` styles in [WordPress/gutenberg#34180 Gutenberg PR #34180], this removed some existing, default styling for some elements, including buttons.  This change re-adds the removed styles by enqueueing `classic.css` for classic themes.

Merges [WordPress/gutenberg#44334 Gutenberg PR #44334] into trunk.

Follow-up to [54257].

Props scruffian, oandregal, ramonopoly, aristath, andrewserong, get_dave, bernhard-reiter.
See #56467.

git-svn-id: https://develop.svn.wordpress.org/trunk@54358 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
dream-encode committed Sep 29, 2022
1 parent c861d58 commit 81d5f40
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/wp-includes/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,10 @@

add_action( 'wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
add_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
add_action( 'wp_enqueue_scripts', 'wp_enqueue_classic_theme_styles' );
add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
add_action( 'admin_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
add_action( 'admin_enqueue_scripts', 'wp_enqueue_classic_theme_styles' );
add_action( 'enqueue_block_assets', 'wp_enqueue_registered_block_scripts_and_styles' );
add_action( 'enqueue_block_assets', 'enqueue_block_styles_assets', 30 );
add_action( 'enqueue_block_editor_assets', 'wp_enqueue_registered_block_scripts_and_styles' );
Expand Down
13 changes: 13 additions & 0 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3640,3 +3640,16 @@ function _wp_theme_json_webfonts_handler() {
add_action( 'wp_enqueue_scripts', $fn_generate_and_enqueue_styles );
add_action( 'admin_init', $fn_generate_and_enqueue_editor_styles );
}

/**
* Loads classic theme styles on classic themes.
*
* This is needed for backwards compatibility for button blocks specifically.
*/
function wp_enqueue_classic_theme_styles() {
if ( ! wp_is_block_theme() ) {
$suffix = wp_scripts_get_suffix();
wp_register_style( 'classic-theme-styles', "/wp-includes/css/dist/block-library/classic$suffix.css", array(), true );
wp_enqueue_style( 'classic-theme-styles' );
}
}

0 comments on commit 81d5f40

Please sign in to comment.