Repository navigation
Background: Add a PHP helper for block support classes and styles - #84209
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: 0 B Total Size: 8.61 MB
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome 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. Actions are reachable via RIGHT/LEFT arrow keys in
|
3e80bc4 to
e2d29dc
Compare
98b4dba to
3848408
Compare
d2d345d to
493a0bc
Compare
493a0bc to
52404fb
Compare
9610ccd to
5e11cb4
Compare
5e11cb4 to
701ca1a
Compare
andrewserong
left a comment
There was a problem hiding this comment.
All smoke-testing nicely for me in the editor and site frontend!
Tiny nits:
- Same as in #84208 (review) should we move to the 7.3 directory?
- In #84208 there were also tests for the icon and post navigation link blocks. Worth doing here, too?
LGTM! 🚀
f5ad449 to
52c8b3c
Compare
|
Thanks for testing @andrewserong 👍
Yep, done. Same across all five PRs and the Core backport.
Good call, I've added tests for both. I've also tidied up the helper's naming and test docblocks to match the other helpers, and rebased on trunk. PHPStan landed this week and doesn't know the new helper yet so I've added a temp baseline for that as well. |
adc97c0 to
72f0cbd
Compare
0b17dc4 to
f51bedf
Compare
Return early when the block attributes are not an array, like the colour helper. Point the text clip comments at the helper and give the unset() guard its reason. Drop tests that repeat block support coverage or lock in PHP-only behaviour, and keep one Button test proving it ignores the clip.
The block library calls wp_get_background_classes_and_styles(), which the build prefixes to gutenberg_get_background_classes_and_styles() for the plugin, but which PHPStan resolves from the WordPress stubs. The stubs were generated from core trunk, which lacks the function, so its calls were baselined as not found. Generate the stubs from wordpress-develop PR 14094, which backports the helper, and drop the four baselined errors. Regenerate them from trunk once the backport is committed. Co-Authored-By: Claude Opus 5.5 (medium effort) <noreply@anthropic.com> Claude-Code-Session-Id: cfcf15e8-ccc1-4d78-a7c9-51f73e8e4b92
This reverts commit 4121c27.
…nction until the stubs include it
f51bedf to
394d2b4
Compare
Follows up on #83122.
Core backport: wordpress-develop#14094.
Related:
What?
Adds a PHP helper that turns background attributes into classes and inline styles, like the JS
getBackgroundClassesAndStyles().Why?
Five blocks copied the background block support's image defaults and
has-backgroundrule, and the copies had started to drift. Button had the first copy. Four blocks that merged since added their own:Tab List already uses the JS helper.
How?
The helper only builds output. Callers pass what they support.
cover, and a centred position forcontainhas-background: for an image or gradient not clipped to textprefixFunctionsNo style changes for values the editor saves.
has-backgroundcan sit in a different place in the class list.PHPStan's WordPress stubs are built from Core trunk, which won't have this helper until wordpress-develop#14094 lands. So this PR adds a temporary baseline entry for it. PHPStan will flag the entry for removal once the stubs move to a Core trunk with the helper.
Testing Instructions
containbackground image and a gradient.has-background.Use of AI Tools
Implemented and tested by a Claude Code agent.