-
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
Site Editor: Add user capability check for the Export feature #69107
base: trunk
Are you sure you want to change the base?
Conversation
// Allows checking permissions for non-default (`/wp/v2`) namespaces | ||
// such as `/wp-block-editor/v1`. | ||
const isCustomNamespace = !! resource?.startsWith( '/' ); | ||
resourcePath = | ||
( isCustomNamespace ? resource : `/wp/v2/${ resource }` ) + | ||
( id ? '/' + id : '' ); |
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 was resolved mainly by entity resource object support, but a couple of REST APIs that use custom namespaces remain in the core. While not ideal, using an entity registry for the export endpoint doesn't make sense.
@youknowriad, @tyxla, @jsnajdr I would love to hear your thoughts on this. Should I extract it into a separate PR?
Size Change: +50 B (0%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @unsalkorkmaz. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
What?
Closes #46661.
Related https://core.trac.wordpress.org/ticket/57379.
PR adds a user capability check for the Export feature in the Site Editor. Users without export capabilities will not be able to use this feature.
How
canUser
resolve to support custom REST namespaces, such as/wp-block-editor/v1
. The logic is very basic and should be used only internally.SiteExport
component.Testing Instructions
wp-env
to run the latest WP alpha.export
cap for Administrators -wp cap remove administrator export
.wp role reset administrator
Testing Instructions for Keyboard
Same.
Screenshots or screencast