-
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
Global styles: preload user global styles based on user caps #66541
Global styles: preload user global styles based on user caps #66541
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
a0d5912
to
4dfc9bb
Compare
a53ebf8
to
ead5d8b
Compare
Flaky tests detected in bace479. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11585143275
|
52173f5
to
58aa39f
Compare
@@ -60,6 +59,7 @@ function gutenberg_block_editor_preload_paths_6_7( $paths, $context ) { | |||
$paths[] = array( '/wp/v2/global-styles/' . $global_styles_id, 'OPTIONS' ); | |||
|
|||
// Remove duplicate or unnecessary global styles paths. | |||
$excluded_paths = array(); |
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.
Unrelated, but just moving var assignment closer to where it's being used, inside the block.
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 on these @ramonjd 👍
This is testing as advertised for me.
✅ Admin user: global styles paths aren't requested client side, they're preloaded in both editors using edit
context
✅ Non-admin user: global styles paths are preloaded as advertised using view
context
✅ Previous feedback has been addressed
✅ Code changes look ok to me
I'm happy if Ella's happy with this 🙂
I'll be offline for a few days so in case it helps keeping this moving I'll drop an approval on it now.
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.
Sure, looks good! Would love some links in inline comments. :)
Thanks a lot for the quick reviews, folks! 🙇🏻 |
Size Change: 0 B Total Size: 1.81 MB ℹ️ View Unchanged
|
Fails are due to |
33bf722
to
6188e2c
Compare
…aps to prevent clientside request in post editor. Add explanatory comments in relevant files.
6188e2c
to
c7731bf
Compare
Oh! It needed a rebase after #66488 should be good now. |
…ss#66541) This commit preloads '/wp/v2/global-styles/' . $global_styles_id with a context corresponding to user caps, that is, edit for users that can edit global styles, and view for everyone else. Preloading the global styles endpoint according to role context means that admins and non admins, e.g., editors, avoid clientside requests. Co-authored-by: ramonjd <[email protected]> Co-authored-by: ellatrix <[email protected]> Co-authored-by: aaronrobertshaw <[email protected]>
What?
Follow up to:
This PR preloads
'/wp/v2/global-styles/' . $global_styles_id
with a context corresponding to user caps, that is,edit
for users that can edit global styles, andview
for everyone else.Why?
Preloading the global styles endpoint according to role context means that admins and non admins, e.g., editors, avoid clientside requests.
Different clientside requests fire for each.
How?
Use
current_user_can( 'edit_theme_options' )
to test for global styles edit caps. This matches post type caps.Testing Instructions
global-styles
endpoints aren't fetched client side, but are, rather, preloaded via rest_preload_api_requestFor admins in the POST and SITE editors the following URLS should be preloaded:
For editors in the POST editor: