mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Block Bindings: Add canUpdateBlockBindings
editor setting
#7258
Closed
SantosGuillamot
wants to merge
9
commits into
WordPress:trunk
from
SantosGuillamot:add/editor-settings-to-update-bindings
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fd1f520
Add `canUpdateBlockBindings` editor setting
SantosGuillamot fd36430
Map `manage_block_bindings` cap
SantosGuillamot 1ceef06
Adapt unit test
SantosGuillamot d860fd9
Remove extra comma
SantosGuillamot 5b4c551
Try: `edit_block_binding` cap with fallback to `edit_theme_options`
SantosGuillamot ae3b1be
Change old name
SantosGuillamot a6a8d21
Address changes
SantosGuillamot 653e563
Add unit test
SantosGuillamot 5f6e484
Remove unnecessary check
SantosGuillamot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why is this a new setting and not something you access through
coreData
canUser
or something?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.
The main reason we started using a new setting was to allow users to disable this behavior with a PHP filter if wanted. And it seems there was a precedence for this with
canLockBlocks
: link.It's true that user capabilities can also be modified through a filter, so if we are able to access
edit_block_binding
in the editor somehow, we wouldn't need an editor setting.I couldn't find a way to do so, but I must say I'm not familiar with user capabilities.
I'm happy to explore other paths. Is it possible to access these user capabilities? From what I understood, canUser checks whether the user can perform the given action on the given REST resource. But that's not exactly what we need here.
Another possibility to replicate the capabilities mapping in JS, but I am not sure it makes sense and I believe users wouldn't be able to override this behavior easily.
Any thoughts are more than welcome.
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.
There are a lot of precedents for block editor settings indeed. But IMO, we should start moving away from them like I explained on my recent blog posts about Gutenberg practices.
In this case, it's a capability check and we should just have a unique way to fetch capabilities from the client. I think @Mamaduka might know better whether that's already possible or not.
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.
For clarity, I'm not saying that users shouldn't override the capability in php, I'm saying that the frontend should access the capability through the capability APIs and not block editor settings.
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.
If we can make it work this way, I agree it seems the best path forward. I will take another look, but I couldn't find a way to do that, at least with the existing APIs.
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 guess the difference with the global settings is that this endpoint is user specific. So maybe a "user settings" endpoint.
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.
Writing that, I wonder if that's just the user endpoint though :P
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.
Yeah looks like it's still GB only. We should probably merge that, I can't remember any specific reasons why we held off on it.
I'm not too fussed if it's a "preference" or a "setting". But I do think it's not a capability.
Along the lines of
wp-block-editor/v1/settings
?I think this is less of an index type of thing, since it is so spceific to Block Editor UI, and not the general capabiliites of the site.
I don't think it would be odd, IMO, for
wp-block-editor/v1/settings
to take into account the user when building the settings. It's already something that I imagine extenders are using when filtering.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.
Just to be clear, I think a block editor settings endpoint would work here. But I wonder if it's a bit shortsighted in the sense that we'll have a need for similar settings (user settings) outside the block editor. (For instance, a setting to prevent users from creating custom WP-Admin views or a setting to prevent users from using "filters" in the different admin pages, or random things like that)...
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.
Yeah we should start exploring that in more detail.