Open justintadlock opened 1 month ago
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/
/styles
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/
There are several methods that might be worth exploring:
theme.json
register_block_style()
Each of these methods could also potentially solve https://github.com/WordPress/gutenberg/issues/51277
There was also a support request as well: How to delete a (style combination) directly with the plugin
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:
theme.json
-like style data via PHP (similar to what's possible with block style variations andregister_block_style()
).WP_Theme_JSON_Resolver::get_style_variations()
to let plugins filter the variations.Each of these methods could also potentially solve https://github.com/WordPress/gutenberg/issues/51277