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

Ascertain whether it's possible to hook into and override theme.json settings in a particular editor context #34775

Open
getdave opened this issue Sep 13, 2021 · 2 comments
Labels
[Type] Experimental Experimental feature or API.

Comments

@getdave
Copy link
Contributor

getdave commented Sep 13, 2021

Part of #30007 (comment)

Ascertain whether it's possible to hook into and override theme.json settings in a particular editor context (e.g. can we override certain settings within the Nav Editor

Please see the link above for why we might we want to do this.

Currently the global styles settings are derived from x3 sources

  1. Core
  2. Theme (theme.json)
  3. User (global styles UI - incomplete).

There is a resolver which collates these disparate sources and merges them to form the final global styles settings.

Currently there is - by design or otherwise - no way to filter these settings.

Potential Solution

We could consider proposing a filter here:

It might look like this:

+ $result = apply_filters( 'theme_json_resolver_merged_data', $result );

return $result;

This would allow the Nav Editor to filter the settings.

Considerations

Is it a good idea to allow developers to potentially override User settings (recall User is one of the x3 sources for Global Styles settings)?

We could consider only allow overriding of Core/Theme settings. That would leave users fully "in charge" but (hopefully) still allow us to filter the settings in the Nav Editor. If the Nav block was configured via Theme JSON then this would allow us to alter the behaviour/display of the Nav block whilst used in the Nav Editor.

@getdave getdave self-assigned this Sep 13, 2021
@getdave getdave changed the title Ascertain whether it's possible to hook into and override theme.json settings in a particular editor context (e.g. can we override certain settings within the Nav Editor Ascertain whether it's possible to hook into and override theme.json settings in a particular editor context Sep 13, 2021
@sdwire
Copy link

sdwire commented Oct 11, 2021

Here's another reason one might want to hook in and override theme.json settings. I'm hosting a multi-site installation. In that installation, I offer a custom but highly configurable theme. Different sites using the same theme are configured differently. I would want my theme to have a chance to make some of those theme.json-configured decisions differently for different sites, depending on their dynamic configuration. In my case, the different editor contexts would be different subsites using the same installation of the same theme, but with different site-specific configurations.

For example, different sites may have different blocks available, or have certain capabilities of certain blocks enabled or disabled depending on the site-specific configuration.

I have been searching for how to make that happen, and this issue suggests to me that it's not (yet) possible. I do like the proposed idea for a filter that would allow the theme to have one last chance to update the merged configuration before the block editor responds to it.

If there's another way for the theme programming to make some of the theme.json decisions dynamically, I'd welcome that guidance as well.

@getdave
Copy link
Contributor Author

getdave commented Oct 13, 2021

You are right. I explored this and it's not possible...yet. I'm no longer actively pursuing this route but it's possible it might be something that is considered in future.

@getdave getdave removed their assignment Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Experimental Experimental feature or API.
Projects
None yet
2 participants