-
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: Use bundled files for enqueuing global styles #50310
Conversation
Hey, @oandregal What do you think about these "permanent" overrides for settings that need to use bundled |
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 getting this started! It not working for me yet with the testing steps I outlined in the other PR, but I think this is a good approach in general, at least while global styles and design tools are still under active development.
6a605a0
to
eec751a
Compare
@tellthemachines, I think I got all the parts ported into the new system. Overriding the |
Yeah, this is annoying. As long as the underlying classes receive changes, the public API needs to point at them in the plugin. I'd think it's best to make them "evergreen" (so they'd sit in |
I agree. Keeping this code in One more thing. Should I also move |
No, they need to be different from core. Would you be up to prepare small PRs that migrate each method separately? Otherwise, it's a big PR with a lot of changes that are difficult to match to each other. If it's just moving methods around, things are easy to spot. |
I would, but all the changes in this PR are needed to fix the regression reported by @tellthemachines - #50079 (comment). I've not touched the methods; I just moved them. The changes that could use a detailed review are concentrated in |
|
||
/* | ||
* For the remaining types (presets, styles), we do consider origins: | ||
if ( ! function_exists( 'wp_get_global_styles_custom_css' ) ) { |
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 was expecting that the only change here would be to move some methods from this file to lib/get-global-styles-and-settings.php
.
As far as I've checked, we should move gutenberg_get_global_styles_custom_css
, gutenberg_get_global_stylesheet
, gutenberg_get_global_settings
, _gutenberg_clean_theme_json_caches
, _gutenberg_add_non_persistent_theme_json_cache_group
.
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 moved everything besides _gutenberg_add_non_persistent_theme_json_cache_group
. The cache group would be the same, so there's no need to keep that function after 6.2.
@oandregal, I addressed the feedback, and PR is ready for another review. |
0d48ea4
to
f95f040
Compare
Flaky tests detected in f95f040. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4928503293
|
Hi, @tellthemachines Did you get a chance to test the fix? |
@Mamaduka I won't be able to do a full code review this week, but I've just tested the latest state of this branch and it's now working correctly. I checked the spacing styles within flow/constrained layouts and also the experimental grid styles, and both are as expected ✅ |
Not a problem. I just want to be sure that PR fixes the regression. Thanks for testing! |
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 addressing this @Mamaduka 👍
It's always a pleasure to find a bug already has a fix up for review!
It turns out #50079 also caused the custom selectors API to be missed. This PR fixes that issue.
The code changes LGTM but it might be best to wait on a final review from @tellthemachines to make sure everything has been covered from their end.
* | ||
* @access private | ||
*/ | ||
function _gutenberg_clean_theme_json_caches() { |
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.
This has been moved to lib/global-styles-and-settings.php
verbatim.
@@ -17,13 +17,6 @@ | |||
* @package gutenberg | |||
*/ | |||
|
|||
/** |
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.
This has been moved to lib/global-styles-and-settings.php
verbatim. The comment no longer makes sense as core already uses the proper function as a callback.
* | ||
* @since 6.2.0 | ||
*/ | ||
function gutenberg_enqueue_global_styles_custom_css() { |
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.
The function and the filter has been moved to lib/script-loader.php
verbatim.
* | ||
* @return void | ||
*/ | ||
function gutenberg_add_global_styles_for_blocks() { |
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.
This brings back this function, that had been removed in #50079
* | ||
* @return void | ||
*/ | ||
function gutenberg_enqueue_global_styles() { |
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.
This brings this function back after having being removed at #50079
* | ||
* @since 5.9.0 | ||
*/ | ||
function gutenberg_enqueue_global_styles_css_custom_properties() { |
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.
This brings back a function that I haven't seen at #50079 though it still makes sense to me.
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 this solves the issues brought by others. The code changes make sense to me: either move things around or add back things (added comments for each function trying to document what changes).
Thanks, @oandregal! I’ll merge this to fix the regressions. Happy to follow up in case I missed something. |
@fabiankaegy, the #50079 will ship with Gutenberg 15.8; I think it makes sense to cherry-pick this PR and avoid regressions in the release. |
I just cherry-picked this PR to the release/15.8 branch to get it included in the next release: f7d2fbd |
* Plugin: Use bundled files for enqueuing global styles * Override the '__experimentalFeatures' * Recreate global styles for block editors * Move global styles custom CSS handlers * Move _gutenberg_clean_theme_json_caches * Override global styles custom CSS properties
} | ||
} | ||
|
||
$settings['styles'] = array_merge( $global_styles, get_block_editor_theme_styles() ); |
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.
It seems this broke duotone filters which rely on updating $settings['styles']
in the same hook. Is there a reason that this hook needs to run at PHP_INT_MAX
priority?
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.
Is there a reason that this hook needs to run at PHP_INT_MAX priority?
That's what the plugin always used for block setting overrides. I guess to prevent other plugins from overriding new feature settings.
I personally don't like the use of PHP_INT_MAX
; it prevents extensibility.
Can you point me to where the Duotone filters are located? Happy to help with the fix.
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.
That's what the plugin always used for block setting overrides.
Ah, it just appended to the styles rather than replacing them before.
Can you point me to where the Duotone filters are located?
The duotone hook is here
gutenberg/lib/block-supports/duotone.php
Line 54 in b057776
add_filter( 'block_editor_settings_all', array( 'WP_Duotone_Gutenberg', 'add_editor_settings' ), 10 ); |
Happy to help with the fix.
Thanks! I'll probably push up a PR sometime today and add you as a reviewer. It sounds like it should be safe to lower the priority to allow for the extensibility that now comes from within the plugin.
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.
@oandregal, any thoughts on lowering the priority for the plugin overrides?
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.
Opened #50760. I found and fixed a few other things when I was digging through all of the code that used the same hook.
What?
Regression after #50079 (comment)
PR adds a script loader not tied to the specific WP version to override global styles enqueued by core. The new one will use the
WP_Theme_JSON
classes bundled with the plugin.Why?
Bundled
WP_Theme_JSON
files should provide some of the settings for global styles.How?
Testing Instructions
#50079 (comment)