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

Child themes theme support do not override parent's theme.json settings #35762

Closed
oandregal opened this issue Oct 19, 2021 · 3 comments
Closed
Assignees
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended

Comments

@oandregal
Copy link
Member

oandregal commented Oct 19, 2021

Description

Reported at #35459 (comment)

The settings for a theme are pulled from its theme.json and fall back to their theme supports if the equivalent theme.json setting is not present. When it comes to child themes we need to consider the whole chain of settings:

parent theme supports => parent theme.json settings => child theme support => child theme.json settings

Options provided in the later stages of the chain should be able to override options provided before. For example, the child theme support settings should override the parent theme.json settings.

Step-by-step reproduction instructions

  • Create a child theme of TT1-blocks without theme.json.
  • Add this code to the functions.php of the child:
function twenty_twenty_one_child_setup() {
        remove_theme_support( 'experimental-link-color' );
        remove_theme_support( 'custom-line-height' );
}
add_action( 'after_setup_theme', 'twenty_twenty_one_child_setup', 15 );

The expected result is that, when you go to the editor, the link and line-height controls should not be present. Instead, what happens is that they are.

@oandregal oandregal added [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Bug An existing feature does not function as intended Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Oct 19, 2021
@Mamaduka
Copy link
Member

@oandregal, I think this works as expected.

Step-by-step reproduction instructions

  1. Remove settings.color.link and settings.typography.customLineHeight from TT1 Blocks theme.json file.
  2. Register theme support for TT1 Blocks, since it doesn't use them:
add_theme_support( 'experimental-link-color' );
add_theme_support( 'custom-line-height' );
  1. Create a child theme without a theme.json.
  2. Remove theme support in child using the following snippet:
add_action( 'after_setup_theme', function() {
	remove_theme_support( 'experimental-link-color' );
	remove_theme_support( 'custom-line-height' );
}, 15 );

@Mamaduka
Copy link
Member

Hi, @oandregal

Did you get a chance to test my latest findings?

@oandregal
Copy link
Member Author

Oh, interesting. I've just checked remove_theme_support and it just removes the property from the global. It's reasonable to think theme authors don't expect this to work because remove_theme_support never worked that way, instead we had to add things like add_theme_support( 'disable-custom-colors' );.

Thanks for following up on this, George!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants