-
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
Font face permissions #58957
Closed
Closed
Font face permissions #58957
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e330e88
JS Hacks.
peterwilsoncc d7a4109
Caps
peterwilsoncc c5de6f9
Map the meta cap.
peterwilsoncc 5a2d68d
Remove non-primitive cap.
peterwilsoncc 3b02141
Docblock.
peterwilsoncc 7523556
One day I will remember this.
peterwilsoncc 67ec28b
I think canUser is more correct than useResourcePermissions.
peterwilsoncc b009f9d
Use seperate permissions for installing and deleting.
peterwilsoncc 659fee7
Use canUser rather than useResourcePermissions.
peterwilsoncc bd51863
Use new cap for all delete permission checks.
peterwilsoncc 428ef1f
Use faux primitive cap rather than meta cap.
peterwilsoncc d1933ab
Include resource ID when checking delete permissions.
peterwilsoncc 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -32,14 +32,14 @@ function gutenberg_create_initial_post_types() { | |||||
'capabilities' => array( | ||||||
'read' => 'edit_theme_options', | ||||||
'read_private_posts' => 'edit_theme_options', | ||||||
'create_posts' => 'edit_theme_options', | ||||||
'create_posts' => 'install_font_faces', | ||||||
'publish_posts' => 'edit_theme_options', | ||||||
'edit_posts' => 'edit_theme_options', | ||||||
'edit_others_posts' => 'edit_theme_options', | ||||||
'edit_published_posts' => 'edit_theme_options', | ||||||
'delete_posts' => 'edit_theme_options', | ||||||
'delete_others_posts' => 'edit_theme_options', | ||||||
'delete_published_posts' => 'edit_theme_options', | ||||||
'delete_posts' => 'delete_font_faces', | ||||||
'delete_others_posts' => 'delete_font_faces', | ||||||
'delete_published_posts' => 'delete_font_faces', | ||||||
), | ||||||
'map_meta_cap' => true, | ||||||
'query_var' => false, | ||||||
|
@@ -64,14 +64,14 @@ function gutenberg_create_initial_post_types() { | |||||
'capabilities' => array( | ||||||
'read' => 'edit_theme_options', | ||||||
'read_private_posts' => 'edit_theme_options', | ||||||
'create_posts' => 'edit_theme_options', | ||||||
'create_posts' => 'install_font_faces', | ||||||
'publish_posts' => 'edit_theme_options', | ||||||
'edit_posts' => 'edit_theme_options', | ||||||
'edit_others_posts' => 'edit_theme_options', | ||||||
'edit_published_posts' => 'edit_theme_options', | ||||||
'delete_posts' => 'edit_theme_options', | ||||||
'delete_others_posts' => 'edit_theme_options', | ||||||
'delete_published_posts' => 'edit_theme_options', | ||||||
'delete_posts' => 'delete_font_faces', | ||||||
'delete_others_posts' => 'delete_font_faces', | ||||||
'delete_published_posts' => 'delete_font_faces', | ||||||
), | ||||||
'map_meta_cap' => true, | ||||||
'query_var' => false, | ||||||
|
@@ -84,6 +84,32 @@ function gutenberg_create_initial_post_types() { | |||||
); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Filters the user capabilities to grant the font family capabilities as necessary. | ||||||
* | ||||||
* Files must be modifiable to grant these capabilities and the user must als | ||||||
* have the `edit_theme_options` capability. | ||||||
* | ||||||
* These are created as faux primitive capabilities to allow for the use | ||||||
* if the delete_post meta capability. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* | ||||||
* @param bool[] $allcaps An array of all the user's capabilities. | ||||||
* @return bool[] Filtered array of the user's capabilities. | ||||||
*/ | ||||||
function gutenberg_maybe_grant_font_family_caps( $allcaps ) { | ||||||
if ( ! wp_is_file_mod_allowed( 'can_modify_font_faces' ) ) { | ||||||
return $allcaps; | ||||||
} | ||||||
|
||||||
if ( ! empty( $allcaps['edit_theme_options'] ) ) { | ||||||
$allcaps['install_font_faces'] = true; | ||||||
$allcaps['delete_font_faces'] = true; | ||||||
} | ||||||
|
||||||
return $allcaps; | ||||||
} | ||||||
add_filter( 'user_has_cap', 'gutenberg_maybe_grant_font_family_caps' ); | ||||||
|
||||||
/** | ||||||
* Initializes REST routes. | ||||||
* | ||||||
|
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.