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

Bring "section style" JSON partials to feature parity with WP_Block_Styles_Registry::register #63263

Open
bacoords opened this issue Jul 8, 2024 · 2 comments
Labels
[Feature] Block Style Variations Issues or PRs that are related to the style variations for blocks [Type] Enhancement A suggestion for improvement.

Comments

@bacoords
Copy link
Contributor

bacoords commented Jul 8, 2024

What problem does this address?

There are a few arguments in the WP_Block_Styles_Registry that aren't present in the new "Section Styles" feature. It would be great to bring these arguments all to parity so that "section styles" could become a 1:1 replacement for PHP/server-side registration of block styles.

What is your proposed solution?

In section styles JSON files, consider adding support for

  • style_handle - the ability to reference a CSS file registered by the theme
  • is_default - the ability to modify/set the default styles for a block

The second one in particular would be particularly handy for making themes more composable and trimming down the site of the theme.json file. All block styles could be defined as separate JSON files, blocks could share default styles if necessary, etc. (This has been replaced with #63307)

Related: https://developer.wordpress.org/reference/classes/wp_block_styles_registry/register/
Related: https://make.wordpress.org/core/2024/06/24/section-styles/

@bacoords bacoords added the [Type] Enhancement A suggestion for improvement. label Jul 8, 2024
@bph bph added the [Feature] Block Style Variations Issues or PRs that are related to the style variations for blocks label Jul 8, 2024
@bph
Copy link
Contributor

bph commented Jul 9, 2024

In my explorations, I learned that there is no such feature:

is_default - the ability to modify/set the default styles for a block

built into register_block_style.

It would be a new feature request, and tying it to the Global Styles (and theme.json) seems to be a way forward...

@bacoords
Copy link
Contributor Author

bacoords commented Jul 9, 2024

Wow thanks!

To briefly summarize that link above, the is_default parameter in WP_Block_Styles_Registry::register has never really fully been fully built out in the past. The assumption I (and I think many others) had was that it allowed you to make a new style variation and set it to load by default when adding a new block. Instead what it was meant for was styling the original "default" variation, something that's not really necessary/helpful anymore(?).

(So I agree that it makes sense to deprecate is_default if it's not working (discussed in that other thread) and remove it from the conceptual framing of block styles (see: #38890) )

It would still make sense to support style_handle in these JSON files. There's already so many different overlapping concepts (block styles, block variations, block style variations, section styles, theme style variations) that any attempt to get feature parity and consistency would be tremendously helpful to users.

I think I'd like to edit this issue to at least focus on style_handle. Since it's seems like "Section Styles" aren't going to support all styling options (see: #63273 (comment)) it's probably going to be very necessary to load custom CSS files for the foreseeable future. This saves the developer from having to add an additional PHP function to load a block style sheet that's already been defined in a JSON file.

The other issues (mentioned here: #38890 (comment) ) is the idea that block style partials could also be used to set the default styles, which I opened a new issue for here: #63307

It makes sense that these two features be considered for the next round of polish on Section Styles after 6.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Style Variations Issues or PRs that are related to the style variations for blocks [Type] Enhancement A suggestion for improvement.
2 participants