Try a block editor setting to limit use of custom css to unfiltered html capability#46666
Closed
glendaviesnz wants to merge 5 commits intotrunkfrom
Closed
Try a block editor setting to limit use of custom css to unfiltered html capability#46666glendaviesnz wants to merge 5 commits intotrunkfrom
glendaviesnz wants to merge 5 commits intotrunkfrom
Conversation
|
Size Change: -252 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
…d/edit global custom css, eg. theme_edit capability probably makes sense multisite context
… unfiltered_html capability
mmtr
reviewed
Dec 23, 2022
| * @return array New block editor settings. | ||
| */ | ||
| function gutenberg_get_block_editor_settings_6_2( $settings ) { | ||
| $can_user_edit_global_custom_css = apply_filters( 'enable_global_styles_custom_css', current_user_can( 'unfiltered_html' ) ); |
Contributor
There was a problem hiding this comment.
Suggested change
| $can_user_edit_global_custom_css = apply_filters( 'enable_global_styles_custom_css', current_user_can( 'unfiltered_html' ) ); | |
| $can_user_edit_global_custom_css = apply_filters( 'enable_global_styles_custom_css', current_user_can( 'edit_css' ) ); |
I think this should check the edit_css capability by default, so it's consistent with the capability checked for the Custom CSS setting in the Customizer: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/customize/class-wp-customize-custom-css-setting.php?rev=51785#L43
Contributor
Author
|
Closed in favor of #46815 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What?
Removes the experimental flag for Global Styles custom CSS and use the
unfiltered_htmlcapability to check if a user should see it in the UIWhy?
If the UI shows in the site editor for users without
unfiltered_htmlthen any content entered fails to save.How?
Adds a
__experimentalCanUserEditGlobalCustomCSSblock editor setting which is calculated withapply_filters( 'enable_global_styles_custom_css', current_user_can( 'unfiltered_html' ) ). The use of a filter allows plugins/themes to extend the use of global custom CSS to other capabilities, eg.edit_csscould be used in the likes of multisite installs where admins don't haveunfiltered_htmlby default.Testing Instructions
unfiltered_htmldoes not see the custom CSS option in global styles (you can removeunfiltered_htmlfor all users withdefine( 'DISALLOW_UNFILTERED_HTML', true );add_filter( 'enable_global_styles_custom_css', current_user_can( 'edit_css' ) )allows a user with this capability but withoutunfiltered_htmlto add/edit global stylsScreenshots or screencast
Coming next year ....