-
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
Try a block editor setting to limit use of custom css to unfiltered html capability #46666
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
@@ -13,6 +13,8 @@ | |||
* @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' ) ); |
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.
$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
Closed in favor of #46815 |
What?
Removes the experimental flag for Global Styles custom CSS and use the
unfiltered_html
capability to check if a user should see it in the UIWhy?
If the UI shows in the site editor for users without
unfiltered_html
then any content entered fails to save.How?
Adds a
__experimentalCanUserEditGlobalCustomCSS
block 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_css
could be used in the likes of multisite installs where admins don't haveunfiltered_html
by default.Testing Instructions
unfiltered_html
does not see the custom CSS option in global styles (you can removeunfiltered_html
for 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_html
to add/edit global stylsScreenshots or screencast
Coming next year ....