-
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
REST API: Adds the site reading options to the index #69106
base: trunk
Are you sure you want to change the base?
Conversation
Size Change: -9 B (0%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
Flaky tests detected in dead145. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/13214441706
|
dead145
to
0fca1cc
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 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. |
// Seems to be coming from `enableComplementaryArea`. | ||
'/wp/v2/users/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.
Had to change the order here. Now that getTemplateId
uses the REST index, the settings request is triggered a bit later.
George asked me to opine on this ticket while we were discussing another issue. I don't think this data belongs on the index as it's not something that's needed for ingesting or using the API in a logged out state. I acknowledge all of this is low risk ( I agree it would be good to have the data available for theme editors without options access, so ideally the data will go on a authenticated endpoint in a read-only format. |
The value does seem useful to me publicly. If I want to programatically link to their posts page, I think reading that value would be the best way to do it?
If this were in some other endpoint, what caps check would guard it? |
What?
Closes #68870.
PR exposes the site reading settings via the REST index, which allows low-capability users to preview and change templates.
Why?
The
/settings
endpoint requires themanage_options
capability to access the site settings and does not have a mechanism forreadonly
the settings.Until #48885 is resolved, the only option for exposing
readonly
settings is the REST API index.How
Use
getEntityRecord( state, 'root', '__unstableBase' )
to access newreadonly
settings.Note
I've not touched other places where these settings are used because it's not a matter of simple search and replace.
While not an issue for non-administrator users, some components also need to account for edited settings. Currently, that's impossible with
getEntityRecord( state, 'root', '__unstableBase' )
.Testing Instructions
P.S. You might see 403 requests for the Navigation block. That needs to be handled separately.
Testing Instructions for Keyboard
Same.
Screenshots or screencast