Skip to content

Conversation

@n7studios
Copy link
Contributor

@n7studios n7studios commented Jul 3, 2025

Summary

For blocks (broadcasts, form trigger, product button), uses WordPress' get_block_wrapper_attributes method to define the block's class attributes automatically, based on a number of built-in block editor properties (text, link and background color). WordPress will automagically build CSS styles specific to each block based on these properties, removing the need for inline styles.

Previously, code would manually build a _css_classes key in the block's attributes, outputting in the class attribute. This is inflexible for adding support for built-in block properties in the future (such as margin, padding and block spacing, which builds on this PR here).

Inline styles are still added to shortcodes, Elementor widgets and Divi modules, as these aren't part of the block editor.

This opens up supporting additional native block properties, such as margin and padding, added in this PR.

Testing

Existing tests pass. Confirmed no regressions in output between main branch and this PR, as well as confirming output the same for both blocks and shortcodes:

Blocks:
Screenshot 2025-07-03 at 20 29 52

Shortcodes:
Screenshot 2025-07-03 at 20 29 55

Tests testBroadcastsBlockParameterEscaping, testFormTriggerBlockParameterEscaping and testProductBlockParameterEscaping are removed, as inline styles on blocks are no longer needed. Parameter escaping tests for styles on e.g. shortcodes remain.

Checklist

@n7studios n7studios self-assigned this Jul 3, 2025
@github-actions
Copy link

github-actions bot commented Jul 5, 2025

WordPress Playground

🚀 Your PR has been built and is ready for testing in WordPress Playground!

Click here to test your changes in WordPress Playground

@Kit Kit deleted a comment from github-actions bot Jul 7, 2025
@Kit Kit deleted a comment from github-actions bot Jul 7, 2025
@Kit Kit deleted a comment from github-actions bot Jul 7, 2025
@Kit Kit deleted a comment from github-actions bot Jul 7, 2025
@Kit Kit deleted a comment from github-actions bot Jul 7, 2025
@Kit Kit deleted a comment from github-actions bot Jul 7, 2025
@Kit Kit deleted a comment from github-actions bot Jul 7, 2025
@Kit Kit deleted a comment from github-actions bot Jul 7, 2025
@Kit Kit deleted a comment from github-actions bot Jul 7, 2025
@Kit Kit deleted a comment from github-actions bot Jul 7, 2025
This ensures the preview matches the output of the page
@n7studios n7studios marked this pull request as ready for review July 7, 2025 09:02
@n7studios n7studios requested review from a team, corydhmiller and noelherrick and removed request for a team July 7, 2025 09:03
n7studios added 5 commits July 9, 2025 14:45
`visualizers` aren’t needed in the block editor.
`fontSize` belongs within `typography`
Blocks: Add Typography Support
@n7studios n7studios merged commit 15f520a into main Jul 10, 2025
@n7studios n7studios deleted the use-get-block-wrapper-attributes branch July 12, 2025 03:03
@n7studios n7studios mentioned this pull request Jul 12, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants