WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.32k stars 4.12k forks source link

Style variations: Allow child themes to exclude specific parent theme style variations #51277

Open ndiego opened 1 year ago

ndiego commented 1 year ago

What problem does this address?

If you create a child of a parent theme like TT3, the child theme will include all of the parent's style variations. For theme developers, this is not always preferred.

This issue was mentioned in https://github.com/WordPress/gutenberg/issues/45965#issuecomment-1327178803 and is related to https://github.com/WordPress/gutenberg/issues/47265. Providing a more robust way for child themes to handle the style variations of a parent theme would greatly improve the experience of building block themes that support these features.

What is your proposed solution?

Provide a method for child themes to exclude a parent's style variations.

bgardner commented 1 year ago

I echo this suggestion, given the extensive exploration I am going through as I prepare to ship a theme/system shortly. I would love to leverage this functionality, but I need to make decisions based on what is currently available.

justintadlock commented 1 year ago

One thing that might be helpful here is having an API for registering variations. Currently, there's just a class method, WP_Theme_JSON_Resolver::get_style_variations(), for getting all of the variations under the theme/styles folder.

At the very least, the function could use a filter hook for overwriting the $variations array (which should also have named keys for the variations).

graylaurenm commented 7 months ago

It would also be nice to see this with patterns.

justintadlock commented 7 months ago

It would also be nice to see this with patterns.

@graylaurenm - You can already remove patterns registered by the parent theme. Check out the documentation in the Theme Handbook: https://developer.wordpress.org/themes/features/block-patterns/#unregistering-block-patterns

graylaurenm commented 7 months ago

@justintadlock thank you, I must not have Googled this one. 🤦‍♀️

JDDevo commented 7 months ago

I'd like to add my support to this suggestion, I was kind of surprised that this wasn't already a filter. It's important to anyone who wishes to lock down the a theme in terms of style variations (eg brand colours and fonts), but still allow people the ability to edit templates through the editor otherwise. A child theme currently seems to be my way to deal with some of the issues of controlling block themes, and currently I can remove style variations from the parent by deleting the json files from the theme/styles folder but I suspect they would come back on the next theme update. My only other option currently would be to make my own block theme from scratch, which would then miss out on the team updates that 2023/4 are getting. So yes, would be very nice to at least have something I could put in functions.php to limit this.

bshuchter commented 5 months ago

+1. Agreed. Using TT4, I can easily add a style variation by including the appropriate json file in my child theme. I can also override a parent style variation by naming the json file the same as one of the defaults (e.g., naming the file mint.json but using a different title and different palette within the json file). But I can't remove any of the parent's style variations.

bshuchter commented 5 months ago

I'm not sure if this is the appropriate forum for a style variation question, so please forgive me if there's a better place to do that. But I just realized that each style variation in TT4 is also loading its own font sets. Are all 8 font sets loaded into memory, or only those related to the active style variation?

Simpa77 commented 5 months ago

+1

bgardner commented 3 months ago

Would love to see some movement on this.

rosa2 commented 2 months ago

+1 Thanks for such a good work :smile_cat:

lewiselborn commented 2 months ago

I'd also like to see this feature, not just for style variations but pattern variations, too.

dreamerworks commented 2 months ago

+1

saschafoerster commented 2 months ago

I renamed the folder "styles" to "styles_OFF" in TT4 and that did at least work as a workaround until the next update.