Template editor: wrong REST API permissions check #51886
Labels
Needs Testing
Needs further testing to be confirmed.
REST API Interaction
Related to REST API
[Type] Bug
An existing feature does not function as intended
Description
Related: #26573, #37126
I wrote a plugin that replaces the templates REST API controller in order to separate the capability to create new templates from the capability to edit existing templates. Below is a simplified version of what I am using:
One problem that became apparent is that the "Edit template" link in the post editor does not show up unless I allowed the user to pass the
create_item_permissions_check
in the REST API, even if they were already passing theupdate_item_permission_check
.If the user passes the
update_item_permission_check
but fails thecreate_item_permissions_check
, I expected that the "Edit template" link would still be available and only the button for creating a new one should be disabled.On the other hand, if the user passes the
create_item_permissions_check
but fails theupdate_item_permission_check
, the "Edit template" link wrongly shows and allows the template editor to be loaded, but the changes correctly can't get saved.It appears that the "Edit template" link is calling the wrong REST API permissions check.
Step-by-step reproduction instructions
return true
andreturn false
statements in the example codeScreenshots, screen recording, code snippet
No response
Environment info
Gutenberg 16.0.0
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
No
The text was updated successfully, but these errors were encountered: