WordPress / gutenberg

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

Add method for plugins to register theme style variations #63574

Open justintadlock opened 1 month ago

justintadlock commented 1 month ago

What problem does this address?

Currently, only themes can "register" theme style variations by adding JSON files to their /styles folder. WP_Theme_JSON_Resolver::get_style_variations() does this by scanning the folder and looking for the files in the parent and child themes: https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/get_style_variations/

However, there are no filter hooks or an API for adding custom variations outside of using the /styles folder.

Related support forum issue: https://wordpress.org/support/topic/custom-wordpress-styles-variations-for-block-themes-using-plugin/

What is your proposed solution?

There are several methods that might be worth exploring:

Each of these methods could also potentially solve https://github.com/WordPress/gutenberg/issues/51277

bph commented 1 month ago

There was also a support request as well: How to delete a (style combination) directly with the plugin