Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions lib/compat/wordpress-6.1/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,11 @@ function gutenberg_enqueue_global_styles() {
add_action( 'wp_footer', 'gutenberg_enqueue_global_styles', 1 );
add_action( 'wp_enqueue_scripts', 'gutenberg_enqueue_stored_styles' );
add_action( 'wp_footer', 'gutenberg_enqueue_stored_styles', 1 );

function gutenberg_enqueue_classic_theme_styles() {
if ( ! wp_is_block_theme() ) {
wp_register_style( 'classic-theme-styles', gutenberg_url( 'build/block-library/classic.css' ), array(), true );
wp_enqueue_style( 'classic-theme-styles' );
}
}
add_action( 'after_setup_theme', 'gutenberg_enqueue_classic_theme_styles' );
Copy link
Member

@ramonjd ramonjd Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hook throws the following notice for me:

Notice: Function wp_register_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the classic-theme-styles handle. 

I've tested the following –

add_action( 'wp_enqueue_scripts', 'gutenberg_enqueue_classic_theme_styles' );

add_action( 'init', 'gutenberg_enqueue_classic_theme_styles' );

– and both work. Not sure which is better. I suppose I'd lean towards wp_enqueue_scripts since it's how we enqueue the other styles?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure which is better. I suppose I'd lean towards wp_enqueue_scripts since it's how we enqueue the other styles?

Yes, wp_enqueue_scripts would be the right hook to use in this scenario 👍

15 changes: 15 additions & 0 deletions packages/block-library/src/classic.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// These rules are needed for backwards compatibility.
.wp-block-button__link {
color: $white;
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;
}