-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Backport global styles custom css changes #3896
Backport global styles custom css changes #3896
Conversation
Still draft as need to look at also bringing across changes from #3896, and also adding some tests |
@@ -106,7 +107,7 @@ function wp_get_global_stylesheet( $types = array() ) { | |||
if ( empty( $types ) && ! $supports_theme_json ) { | |||
$types = array( 'variables', 'presets', 'base-layout-styles' ); | |||
} elseif ( empty( $types ) ) { | |||
$types = array( 'variables', 'styles', 'presets' ); |
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.
So. Back at Gutenberg I prepared a PR to update the PHPDocs at WordPress/gutenberg#46817
This is being backported at #3918 though I had to remove the custom-css
bit from that PR because it had no landed yet. Perhaps it makes more sense to merged the changes at #3918 in this PR and do it altogether?
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.
Or merging #3918 fast and then rebase this one. I'm fine with whatever works best for people.
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 think it will be faster to merge #3918 (@oandregal 's PR) and rebase here, since it's still a draft.
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 the update - good call to go ahead with your PR - this one is still draft as we are still exploring a change in the custom-css load order which will affect this.
5205998
to
d8f547a
Compare
@aristath - I have updated this to match the changes merged in with WordPress/gutenberg#47396, which will affect #3925 also |
@Mamaduka have pulled across WordPress/gutenberg#47062, but some unit tests are failing on multisite which may be related to this and I ran out of time to work out why - will take another look tomorrow if you don't have time to look at it. |
@glendaviesnz, I was able to resolve failing multisite tests by granting capabilities to admin users. I added the following to if ( is_multisite() ) {
grant_super_admin( self::$admin_id );
} P.S. I can't push changes to your branch. |
0ca55f9
to
400d437
Compare
@glendaviesnz, we should probably place the |
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php
Outdated
Show resolved
Hide resolved
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.
To ensure not to forget, I'm blocking the commit of this PR until it is tested in the WP Admin area. Why? The wp_cache_*()
functions are loaded into memory or available when load-styles.php
runs. If the new wp_get_global_styles_custom_css()
runs during this cycle, a fatal error and/or unstyled admin area will happen.
Testing instructions are found here #3712 (comment).
This test is mandatory before committing. Else it could break wp.org.
Also testing in the WP admin area to determine if a fatal error or breaks in CSS happen from not having wp_cache_*()
functions available when load-styles.php
runs. See the testing instructions here for this necessary test. I'll
Co-authored-by: Tonya Mork <tonya.mork@automattic.com>
Co-authored-by: Tonya Mork <tonya.mork@automattic.com>
Co-authored-by: Tonya Mork <tonya.mork@automattic.com>
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.
@glendaviesnz Mostly looks solid to me, just a few points of feedback. One thing is potentially more critical and should be considered for a backward compatible solution (from an end user perspective).
Co-authored-by: Tonya Mork <tonya.mork@automattic.com>
Thanks @felixarntz and @hellofromtonya for the detailed feedback! |
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.
Sorry, I reviewed this a couple of days ago, but didn't finish.
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php
Outdated
Show resolved
Hide resolved
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.
@glendaviesnz Code-wise this looks good to go from my perspective.
The only blocking thing from my perspective is what @hellofromtonya shared in #3896 (review). We need to test that this does not interfere with the load-styles.php
request, prior to commit.
Looking at the code paths, I believe it does not, but we should double-check by following the test methodology linked in @hellofromtonya's comment.
@hellofromtonya I have run the suggested tests, re Step 1: Added the following constants to wp-config.php:
Step 2: Applied this PR
Step 4: Logged in and opened the WP Admin area. ✅ No fatal error occured |
Testing has confirmed no impact to load-styles.php. Dismissing this blocking review as it's no longer necessary.
* | ||
* @since 6.2.0 | ||
* | ||
* @return string |
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.
* @return string | |
* @return string The 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.
@hellofromtonya Addressed this as part of follow up 2cf1b08.
src/wp-includes/block-editor.php
Outdated
@@ -408,6 +408,12 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex | |||
$block_classes['css'] = $actual_css; | |||
$global_styles[] = $block_classes; | |||
} | |||
// Add the custom CSS as separate style sheet so any invalid CSS entered by users does not break other 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.
The comment is too long on one line.
// Add the custom CSS as separate style sheet so any invalid CSS entered by users does not break other global styles. | |
/* | |
* Add the custom CSS as separate style sheet so any invalid CSS entered | |
* by users does not break other global styles. | |
*/ |
Helps to improve readability.
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.
Two things:
- I think it needs an "a" before the word "separate".
- Also, isn't "style sheet" one word, e.g. stylesheet?
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 can take care of committing this and address this feedback prior to the commit.
I think (correct me if I'm wrong) this PR is good shape for commit.
Is there anything else pending before commit? @glendaviesnz @dream-encode @felixarntz? |
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.
Tiny, semantic suggestions, this this looks ready to me.
src/wp-includes/block-editor.php
Outdated
@@ -408,6 +408,12 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex | |||
$block_classes['css'] = $actual_css; | |||
$global_styles[] = $block_classes; | |||
} | |||
// Add the custom CSS as separate style sheet so any invalid CSS entered by users does not break other 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.
Two things:
- I think it needs an "a" before the word "separate".
- Also, isn't "style sheet" one word, e.g. stylesheet?
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.
Ready to go. Felix will take care of David's review during commit. 👍 from me
Committed in https://core.trac.wordpress.org/changeset/55192 |
Thanks @felixarntz, @hellofromtonya and @dream-encode ! |
Trac ticket: https://core.trac.wordpress.org/ticket/57536
Combines changes from WordPress/gutenberg#46141 & WordPress/gutenberg#47396
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.