-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Script loader: remove 6.1 wp actions #44519
Conversation
Don't we still need these somewhere in order for the plugin to be compatible with previous versions of WP? |
Thanks for taking a look @tellthemachines! Sorry, I'm not sure I follow 🤔 Do you mean the wp hooks removed by
Also, I was going on the assumption that the plugin will always want to use Am I understanding things right? |
Yes, sorry, I think my yesterday evening brain was processing it the other way around 😂 So the assumption is every WP version > 6.0 will have If that's the case, we should move this to somewhere outside the |
OMG, the folder name totally went over my head. Thanks for pointing that out. I'm still living in the past 🤣 I'll update |
…kported hook callbacks for wp_enqueue_stored_styles. This prevents the callback running twice.
The following is just a brain dump in case we need to come back to it later, and it's not necessarily coherent :) TL;DR We don't need this PR as it is right now, but there might be case to remove the WP hooks later.
Yes. In fact, because, like Furthermore, it's envisaged that Gutenberg will only use the style engine's For now however, I don't think there's much of an immediate problem because we really only care about block support styles in Gutenberg. Gutenberg, when activated, re-reregisters blocks supports (overwriting Core's). Styles for Gutenberg's blocks supports are currently being generated using the style engine's Core block supports, therefore, are not registering any styles at all with the plugin activated. The worst thing that is happening is that the Catch 22In fact I think we can't call The Catch 22 will be when we start enqueuing global styles, and there's the possibility of styles being printed twice or Core and Gutenberg styles clashing. To be safe, I think we have to remove the action hooks. 🙃 So in that respect we've painted ourselves into nice little corner. Going forwardMy proposal in this PR therefore is to move Then, continue to remove the wp hooks in that file: remove_action( 'wp_enqueue_scripts', 'wp_enqueue_stored_styles' );
remove_action( 'wp_footer', 'wp_enqueue_stored_styles', 1 ); And, to ensure that we support printed out 3rd party styles registered with the Style Engine, we check for Core stores // If there are any other stores registered by themes etc., print them out.
$additional_stores = WP_Style_Engine_CSS_Rules_Store_Gutenberg::get_stores();
/*
* Since the corresponding action hook in Core is removed below,
* this function should still honour any styles stored using the Core Style Engine store.
*/
if ( class_exists( 'WP_Style_Engine_CSS_Rules_Store' ) ) {
$additional_stores = array_merge( $additional_stores, WP_Style_Engine_CSS_Rules_Store_Gutenberg::get_stores() );
} Sorry if this sounds like rubbish. I've been thinking about it for too long. cc @andrewserong for the obligatory sanity check 😄 I'm wondering if |
…t should not be versioned It is envisaged that Gutenberg will continue to use the Style Engine's `gutenberg_*` functions and `_Gutenberg` classes to aid continuou.s development.
Thanks for laying all that out @ramonjd — the logic of doing that and then removing the core hooks sounds good to me! |
880903f
to
019e1ab
Compare
Co-authored-by: Ari Stathopoulos <[email protected]>
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.
Thanks for following up @ramonjd! This is testing well for me:
✅ Still outputs styles correctly in 6.0 + Gutenberg plugin
✅ Confirmed that prior to this PR, 6.1 beta + Gutenberg plugin resulted in double "Core styles" string
✅ With this PR applied, there is only a single output 👍
Before | After |
---|---|
LGTM! ✨
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.
LGTM! 👍
What?
Now that 6.1-beta is running in development, we should remove the backported hook callbacks for
wp_enqueue_stored_styles
.Why?
This prevents the callback running twice.
How?
remove_action
YO!Testing Instructions
In trunk, you can test the before state by creating a post with some layout blocks.
Here, kind reviewer, is some test HTML
Example
In the published post's frontend HTML source, you'll see that the block supports inline CSS has two comments
Core styles: block-supports
:This means that the callback has been called twice.
Apply this PR and see that the duplicate comment is GONE BABY