diff --git a/src/wp-content/themes/twentytwelve/css/editor-blocks.css b/src/wp-content/themes/twentytwelve/css/editor-blocks.css index d9efec32d59b7..29eb1f7ede596 100644 --- a/src/wp-content/themes/twentytwelve/css/editor-blocks.css +++ b/src/wp-content/themes/twentytwelve/css/editor-blocks.css @@ -369,6 +369,7 @@ p.has-drop-cap:not(:focus)::first-letter { background-image: -o-linear-gradient(top, #f4f4f4, #e6e6e6); background-image: linear-gradient(to bottom, #f4f4f4, #e6e6e6); background-repeat: repeat-x; + color: #7c7c7c; } /* Separator */ diff --git a/src/wp-content/themes/twentytwenty/assets/css/editor-style-block-rtl.css b/src/wp-content/themes/twentytwenty/assets/css/editor-style-block-rtl.css index 063075bf1ab31..2c3192b00fcd1 100644 --- a/src/wp-content/themes/twentytwenty/assets/css/editor-style-block-rtl.css +++ b/src/wp-content/themes/twentytwenty/assets/css/editor-style-block-rtl.css @@ -920,8 +920,8 @@ hr.wp-block-separator.is-style-dots::before { /* Block: Button ----------------------------- */ -.editor-styles-wrapper .wp-block-button__link, -.editor-styles-wrapper .wp-block-file__button { +:root .editor-styles-wrapper .wp-block-button__link, +:root .editor-styles-wrapper .wp-block-file__button { background: #cd2653; border-radius: 0; color: #fff; @@ -937,6 +937,11 @@ hr.wp-block-separator.is-style-dots::before { line-height: 1.1; } +.editor-styles-wrapper .wp-block-button__link:hover, +.editor-styles-wrapper .wp-block-file__button:hover { + text-decoration: underline; +} + /* BUTTON STYLE: OUTLINE */ .editor-styles-wrapper .is-style-outline .wp-block-button__link, @@ -1301,8 +1306,8 @@ hr.wp-block-separator.is-style-dots::before { /* BLOCK: BUTTON */ - .editor-styles-wrapper .wp-block-button__link, - .editor-styles-wrapper .wp-block-file__button { + :root .editor-styles-wrapper .wp-block-button__link, + :root .editor-styles-wrapper .wp-block-file__button { font-size: 17px; } diff --git a/src/wp-content/themes/twentytwenty/assets/css/editor-style-block.css b/src/wp-content/themes/twentytwenty/assets/css/editor-style-block.css index 8b62985520683..18e83281076db 100644 --- a/src/wp-content/themes/twentytwenty/assets/css/editor-style-block.css +++ b/src/wp-content/themes/twentytwenty/assets/css/editor-style-block.css @@ -924,8 +924,8 @@ hr.wp-block-separator.is-style-dots::before { /* Block: Button ----------------------------- */ -.editor-styles-wrapper .wp-block-button__link, -.editor-styles-wrapper .wp-block-file__button { +:root .editor-styles-wrapper .wp-block-button__link, +:root .editor-styles-wrapper .wp-block-file__button { background: #cd2653; border-radius: 0; color: #fff; @@ -941,6 +941,11 @@ hr.wp-block-separator.is-style-dots::before { line-height: 1.1; } +.editor-styles-wrapper .wp-block-button__link:hover, +.editor-styles-wrapper .wp-block-file__button:hover { + text-decoration: underline; +} + /* BUTTON STYLE: OUTLINE */ .editor-styles-wrapper .is-style-outline .wp-block-button__link, @@ -1305,8 +1310,8 @@ hr.wp-block-separator.is-style-dots::before { /* BLOCK: BUTTON */ - .editor-styles-wrapper .wp-block-button__link, - .editor-styles-wrapper .wp-block-file__button { + :root .editor-styles-wrapper .wp-block-button__link, + :root .editor-styles-wrapper .wp-block-file__button { font-size: 17px; } diff --git a/src/wp-includes/css/classic-themes.css b/src/wp-includes/css/classic-themes.css new file mode 100644 index 0000000000000..d77a25a3b95a4 --- /dev/null +++ b/src/wp-includes/css/classic-themes.css @@ -0,0 +1,18 @@ +/** + * These rules are needed for backwards compatibility. + * They should match the button element rules in the base theme.json file. + */ +.wp-block-button__link { + color: #ffffff; + background-color: #32373c; + border-radius: 9999px; /* 100% causes an oval, but any explicit but really high value retains the pill shape. */ + + /* This needs a low specificity so it won't override the rules from the button element if defined in theme.json. */ + box-shadow: none; + text-decoration: none; + + /* The extra 2px are added to size solids the same as the outline versions.*/ + padding: calc(0.667em + 2px) calc(1.333em + 2px); + + font-size: 1.125em; +} diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 1d69c809e0ce6..e9ca31f5f7908 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -560,7 +560,6 @@ 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' ); @@ -572,6 +571,7 @@ add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); add_filter( 'customize_controls_print_styles', 'wp_resource_hints', 1 ); add_action( 'admin_head', 'wp_check_widget_editor_deps' ); +add_filter( 'block_editor_settings_all', 'wp_add_editor_classic_theme_styles' ); // Global styles can be enqueued in both the header and the footer. See https://core.trac.wordpress.org/ticket/53494. add_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' ); diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 6f844cbc7e984..fd1bf4b6fa93b 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -3658,16 +3658,48 @@ function _wp_theme_json_webfonts_handler() { } /** - * Loads classic theme styles on classic themes. + * Loads classic theme styles on classic themes in the frontend. * * This is needed for backwards compatibility for button blocks specifically. * * @since 6.1.0 */ function wp_enqueue_classic_theme_styles() { - if ( ! wp_is_block_theme() ) { + if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) { $suffix = wp_scripts_get_suffix(); - wp_register_style( 'classic-theme-styles', "/wp-includes/css/dist/block-library/classic$suffix.css", array(), true ); + wp_register_style( 'classic-theme-styles', '/' . WPINC . "/css/classic-themes$suffix.css", array(), true ); wp_enqueue_style( 'classic-theme-styles' ); } } + +/** + * Loads classic theme styles on classic themes in the editor. + * + * This is needed for backwards compatibility for button blocks specifically. + * + * @since 6.1.0 + * + * @param array $editor_settings The array of editor settings. + * @return array A filtered array of editor settings. + */ +function wp_add_editor_classic_theme_styles( $editor_settings ) { + if ( WP_Theme_JSON_Resolver::theme_has_support() ) { + return $editor_settings; + } + $suffix = wp_scripts_get_suffix(); + $classic_theme_styles = ABSPATH . WPINC . "/css/classic-themes$suffix.css"; + + // 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. + $classic_theme_styles_settings = array( + 'css' => file_get_contents( $classic_theme_styles ), + '__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; +}