-
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
Return consolidated global styles in REST Request #31762
Conversation
Size Change: 0 B Total Size: 1.31 MB ℹ️ View Unchanged
|
Hey @nosolosw thanks for making these changes! Quick question, when I changed the default background color from {
"styles": {
"color": {
"background": "var:preset|color|red",
"text": "var(--wp--preset--color--dark-gray)"
}
}
} Is the value of the background correct |
Yeah, that's expected. That's because the user selected a "preset" color from the theme palette. The value of that can be found under |
Right, I guess I was expecting the value to be like:
Instead of
Thought it might be a parsing issue there. |
🤔 Now that I think of it: I believe we needed that format for the post editor because @jorgefilipecosta had found some issues using the CSS Custom Properties directly. I presume issues with KSES. However, we're switching away from variables in the post editor #31488 so I wonder if we can remove that format: a lot less logic, indirection, and code to maintain. It looks like in the site editor we wouldn't need to use it anyway. Jorge, do you have thoughts on this? |
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.
Tested this in various scenarios (post editor, site editor, rest) and works as expected. |
// needs the ability to create them. Hence, we pass it some data | ||
// for this: base styles (core+theme) and the ID of the user CPT. | ||
|
||
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { |
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 don't like this now. See https://github.com/WordPress/gutenberg/pull/29969/files#r631772812
Follow-up to #29969
This PR covers a new use case for settings: REST Request. The API is going to be used by the mobile apps to get access to the data. Some data it needs is the consolidated global styles from core, theme, and user.
How to test
<your_site>/wp-json/__experimental/wp-block-editor/v1/settings
and verify that you have access to all the settings (including the ones at__experimentalStyles
).Note: a quick way to test the endpoint is to add a return true; within get_items_permissions_check in the lib/class-wp-rest-block-editor-settings-controller.php file.