Repository navigation
Block Supports: Add background gradient support that can combine with background image - #11384
aaronrobertshaw wants to merge 8 commits into
Conversation
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @1178653+wordpress-develop-pr-bot[bot]@users.noreply.github.com. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
Sorry I've kept this waiting for so long. Just rediscovered after working on #12361 I can give it a test tomorrow - is there anything we're waiting on to get this? |
|
I believe everything should be good to go with this but as it has sat for a while, I'll need to give it a rebase first |
af7cdca to
626797e
Compare
|
Actually, turns out I missed updating the core function to allow combined gradients and backgrounds properly via kses. I've updated that now but the original Gutenberg PR only allowed modern color functions within gradients when combined with a background. I've tweaked that here so that it is consistent and they are supported for standalone gradients as well. This will need backporting to Gutenberg so I'll spin up a PR doing that this evening or tomorrow. |
ramonjd
left a comment
There was a problem hiding this comment.
Backport files check out against WordPress/gutenberg#75859
Test ticket annotations LGTM
I manually tested this (the latest GB release has been merged into Core already) and it's working as expected:
- existing gradients and images behave
- migrates existing
color.gradienttobackground.gradienton save - image and gradient values combined in
background-image
Tested theme.json in TT5 e.g.,
"core/group": {
"background": {
"backgroundImage": {
"url": "file:./assets/images/book-image-landing.webp"
},
"gradient": "linear-gradient(135deg,rgba(0,0,0,0.48) 1%,rgba(255,255,255,0.47) 100%)"
}
},|
I've backported to Gutenberg the changes here allowing modern color definitions within standalone gradients in WordPress/gutenberg#79791 |
|
This one good to go you reckon? |
|
I would appreciate it if you could proceed with this PR and commit it in time for the 7.1 Beta1 release on July 15. |
|
@aaronrobertshaw do you need help landing this one? |
f73f017 to
c3100dc
Compare
|
I rebased this and retested. I think it's good to go. |
… background images
… tests Add `@since 7.1.0` notes to `safecss_filter_attr()` and `wp_apply_colors_support()`, clarify the inline comment on the gradient matching in `safecss_filter_attr()`, and extend the `data_safecss_filter_attr()` provider to cover combined gradient + image values, modern colour functions, bounded nesting, and the widened single-level nested-function allowance. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
f1410ad to
13b9f5b
Compare
|
I'll go ahead and commit this today |
…g PR 79568. Assumes background gradient support from WordPress#11384. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thank you very much for picking this up and getting it committed @ramonjd 🙇 |
|
No worries. It's a long time coming, thanks for working on it and fixing it |
Trac ticket: https://core.trac.wordpress.org/ticket/64974
This PR brings the PHP changes from the following Gutenberg PR to core:
WordPress/gutenberg#75859
Description
Adds
background.gradientas a new block support, enabling blocks to combine a background gradient with a background image via comma-separatedbackground-imageCSS values (e.g.,background-image: linear-gradient(...), url(...)).Currently, the only way to apply a gradient is through
color.gradient, which renders as abackgroundCSS shorthand and conflicts with background imageproperties. By introducing
background.gradient(stored atstyle.background.gradient), gradients become part of the background style group, allowing thestyle engine to combine gradient and image values without conflict.
See: WordPress/gutenberg#32787 and WordPress/gutenberg#75859
Testing
npm run test:php -- --filter="Tests_Block_Supports_WpRenderBackgroundSupport|Tests_Block_Supports_Colors|Tests_wpStyleEngine|test_get_background_gradient|test_remove_insecure_p roperties_allows_combined|test_remove_insecure_properties_allows_background_gradient|test_get_settings_appearance_true"styles.blocks.core/group.background.gradientproperty (e.g.,"gradient": "linear-gradient(135deg, #000 0%, #fff 100%)"). Verify the gradient renders correctly on the frontend.backgroundImageon the same Group block and confirm both values combine into a singlebackground-imageCSS declaration.style.color.gradientsupport continues to work on blocks that don't opt intobackground.gradient.style.color.gradientandstyle.background.gradient— confirmbackground.gradienttakes precedence and thecolor.gradientshorthand is suppressed.