-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin: Tweaks to accommodate latest changes in core for styles loading #31702
Conversation
@@ -170,6 +170,7 @@ function gutenberg_register_core_block_styles( $block_name ) { | |||
$editor_style_path = "build/block-library/blocks/$block_name/style-editor.css"; | |||
|
|||
if ( file_exists( gutenberg_dir_path() . $style_path ) ) { | |||
wp_deregister_style( "wp-block-{$block_name}" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deregister styles so they can be registered properly. This is needed in WP5.8, and irrelevant in previous versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gutenberg_override_style
should be a nice shortcut.
Size Change: 0 B Total Size: 1.31 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested but code-wise it looks good. This is exactly what I discussed with @aristath in the private chat.
We could optionally backport it to Gutenberg 10.6 release to ensure there are no reports related to incompatibility with WordPress core when using trunk
.
I added this to the 10.6 milestone as suggested above by @gziolo cc @vdwijngaert |
Description
A commit was backported from Gutenberg to core to allow loading separate stylesheets per-block on render - See https://core.trac.wordpress.org/changeset/50836
This PR tweaks Gutenberg to make sure nothing breaks when using WP5.8.
How has this been tested?
Tested with WordPress trunk, using the default theme, with and without this line in the theme's
functions.php
file:Also tested with a block theme with and without the filter.
Using the default theme, without the filter it loads the single
style.css
file for all blocks. With the filter, it loads separate styles.Using a block theme the separate styles get loaded properly.
Checklist:
*.native.js
files for terms that need renaming or removal).