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

Add method for plugins to register theme style variations #63574

Open
justintadlock opened this issue Jul 15, 2024 · 1 comment · May be fixed by #63607
Open

Add method for plugins to register theme style variations #63574

justintadlock opened this issue Jul 15, 2024 · 1 comment · May be fixed by #63607
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Feature] Theme Style Variations Related to style variations provided by block themes [Type] Enhancement A suggestion for improvement.

Comments

@justintadlock
Copy link
Contributor

justintadlock commented Jul 15, 2024

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:

  • Create an API for registering theme.json-like style data via PHP (similar to what's possible with block style variations and register_block_style()).
  • Add a filter hook over the result of WP_Theme_JSON_Resolver::get_style_variations() to let plugins filter the variations.
  • Add a filter hook for the directory paths that should be scanned for JSON files.

Each of these methods could also potentially solve #51277

@justintadlock justintadlock added [Type] Enhancement A suggestion for improvement. [Feature] Theme Style Variations Related to style variations provided by block themes labels Jul 15, 2024
@ndiego ndiego added the [Feature] Extensibility The ability to extend blocks or the editing experience label Jul 16, 2024
@bph
Copy link
Contributor

bph commented Jul 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Feature] Theme Style Variations Related to style variations provided by block themes [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants