-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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: allow read access to users with edit_posts
capabilities
#7336
Global Styles: allow read access to users with edit_posts
capabilities
#7336
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
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.
Left some notes inline.
As the global styles are essentially public via the HTML header's <style id='global-styles-inline-css'>
element, it might be possible to use the read
capability rather than worry too much about the ability to edit post.
Although it would extend the use of read beyond the purpose currently documented so it may be a terrible idea.
src/wp-admin/edit-form-blocks.php
Outdated
@@ -123,14 +123,6 @@ static function ( $classes ) { | |||
'before' | |||
); | |||
|
|||
// Set Heartbeat interval to 10 seconds, used to refresh post locks. |
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 looks unintentional, are you able to check you forked from an up-to-date version of trunk?
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.
Oh yeah, that's not supposed to be there. I'll rebase. Thanks for the heads up.
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php
Outdated
Show resolved
Hide resolved
208cc45
to
a3078eb
Compare
@@ -632,7 +626,7 @@ public function get_theme_items( $request ) { | |||
); | |||
} | |||
|
|||
$response = array(); | |||
$response = 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.
Random space removed.
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.
Nittiest of nitty nit picks.
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php
Show resolved
Hide resolved
0f5c3e0
to
b183c97
Compare
Add edit_theme_options cap check for reading items with accompanying test coverage. t
a87926f
to
790e8d1
Compare
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 Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
These changes look good to me.
As the upstream pull request, WordPress/gutenberg#65071, includes JavaScript changes to implement the additional access I haven't been able to test that styles appear correctly when editing a post on a WordPress-Develop install.
However, I have been able to verify that the view context request does return the custom styles when logged in as a contributor.
Edit: To be clear, I can test the upstream PR and it works as expected.
This PR syncs WordPress/gutenberg#65071
What
The patch allows any role that can
to read global styles from the API and in the editor.
Why
Block style variations and other global styles are not available to non-admin editors. See WordPress/gutenberg#64755 and also read-only style book ideas in WordPress/gutenberg#41119
Furthermore, having global styles available in the post editor will, one day, allow block controls to reflect any values inherited from the theme/global styles. See: WordPress/gutenberg#64670
Testing
Manual testing in the editor is limited without package changes, however you can login using different roles (e.g., admin/editor) and try to fetch global styles in the console.
Trac ticket: https://core.trac.wordpress.org/ticket/62042
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.