Skip to content

Background Support: Allow modern color functions in standalone gradients#79791

Merged
aaronrobertshaw merged 1 commit into
trunkfrom
update/background-gradient-kses-filter
Jul 8, 2026
Merged

Background Support: Allow modern color functions in standalone gradients#79791
aaronrobertshaw merged 1 commit into
trunkfrom
update/background-gradient-kses-filter

Conversation

@aaronrobertshaw

Copy link
Copy Markdown
Contributor

What?

Brings the changes from the Core backport (WordPress/wordpress-develop#11384) back to Gutenberg, and moves the gradient KSES filter into the WordPress 7.1 compat folder.

Follow up to #75859.

Why?

The Core backport updates safecss_filter_attr() directly to allow gradient background values. This PR aligns Gutenberg with tweaks made to Core's approach and relocates the shim so it is removed automatically once these changes reach Gutenberg's minimum supported WordPress version.

How?

  • Moves the filter from lib/experimental/kses.php into lib/compat/wordpress-7.1/kses.php, so it is deleted along with that folder once 7.1 is the minimum supported version.
  • Updates the logic to match Core. It removes each gradient from the test string and re-checks the remainder, which allows gradients using functions beyond rgb() and rgba() (such as hsl(), oklch() and calc()), whether standalone or combined with a url() image.
  • Renames the function to gutenberg_allow_extended_gradient_backgrounds to reflect what it now covers.
  • Registers the filter unconditionally, like the neighbouring shim. It is a no-op on WordPress 7.1 and later, where Core handles these values natively.
  • Extends the background support tests with standalone gradient cases.

Testing Instructions

No manual testing needed. Coverage lives in the background support tests (phpunit/block-supports/background-test.php). Wait for CI and the e2e tests to pass.

@aaronrobertshaw aaronrobertshaw self-assigned this Jul 1, 2026
@aaronrobertshaw aaronrobertshaw added [Type] Code Quality Issues or PRs that relate to code quality [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core labels Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Flaky tests detected in 161758f.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/28548391374
📝 Reported issues:

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@aaronrobertshaw
aaronrobertshaw merged commit ce4d8f5 into trunk Jul 8, 2026
59 of 60 checks passed
@aaronrobertshaw
aaronrobertshaw deleted the update/background-gradient-kses-filter branch July 8, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants