Skip to content
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

Global Styles: Allow content/wide widths when unfiltered_html is not allowed #46712

Merged
merged 2 commits into from
Dec 23, 2022

Conversation

mmtr
Copy link
Contributor

@mmtr mmtr commented Dec 21, 2022

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 and layout.wideSize settings are being stripped out for users without the unfiltered_html capability as part of remove_insecure_settings.

How?

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:

add_action( 'init', 'kses_init_filters' );
  1. With this PR applied and with a user with unfiltered_html capability (e.g. a regular admin), you should be able to save content and wide widths in Appearance > Editor > Styles > Layout.
  2. Repeating the above with a user without unfiltered_html capability (or enable the KSES filters with add_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:

npm run test:unit:php -- --filter WP_Theme_JSON_Gutenberg_Test

Screenshots or screencast

Before After
before after

@mmtr mmtr added [Type] Bug An existing feature does not function as intended Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Feature] Layout Layout block support, its UI controls, and style output. labels Dec 21, 2022
@mmtr mmtr self-assigned this Dec 21, 2022
Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spun up a multisite and created a new admin user.

On trunk my layout content/width values are not saved:
2022-12-23 12 27 44

This PR they are. YAY
2022-12-23 12 22 21

🍺

@mmtr mmtr merged commit f303663 into trunk Dec 23, 2022
@mmtr mmtr deleted the fix/saving-dimensions-global-styles-kses-filters branch December 23, 2022 09:19
@github-actions github-actions bot added this to the Gutenberg 14.9 milestone Dec 23, 2022
@andrewserong
Copy link
Contributor

Thanks for fixing this up! Nice idea turning the indirect properties into an array of arrays so that multiple values using the same CSS property is allowed 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Layout Layout block support, its UI controls, and style output. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants