Global Styles: Allow content/wide widths when unfiltered_html is not allowed #46712
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?
Follow-up of #46388.
This PR ensures that the content and wide width settings set via Global Styles are considered safe and thus output as custom properties on the body element.
Why?
Because secure
layout.contentSize
andlayout.wideSize
settings are being stripped out for users without theunfiltered_html
capability as part ofremove_insecure_settings
.How?
INDIRECT_PROPERTIES_METADATA
array introduced in Global styles: Allow indirect properties when unfiltered_html is not allowed #46388 to allow thelayout.contentSize
andlayout.wideSize
settings.remove_insecure_settings
to check theINDIRECT_PROPERTIES_METADATA
array for settings that are not included inPRESETS_METADATA
.Testing Instructions
Note: a quick way to test this PR is to place the following in
lib/init.php
in the Gutenberg plugin, rather than worrying about changing user capabilities:unfiltered_html
capability (e.g. a regular admin), you should be able to save content and wide widths in Appearance > Editor > Styles > Layout.unfiltered_html
capability (or enable the KSES filters withadd_action( 'init', 'kses_init_filters' );
) you should now still be able to save content and wide widths in Appearance > Editor > Styles > Layout.Ensure tests pass:
Screenshots or screencast