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

Additional CSS option is missing when a block theme does not include a theme.json #52750

Open
carolinan opened this issue Jul 19, 2023 · 7 comments
Labels
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

@carolinan
Copy link
Contributor

Description

Block themes are not required to include a theme.json file in order to be activated on a WordPress installation.
When such a theme is activated, the global Additional CSS and the blocks additional CSS fields in the Site Editor are missing.

Step-by-step reproduction instructions

Activate a block theme without theme.json.
Go to Appearance > Editor > edit any template or select "Styles".

Look for the Additional CSS fields in the Styles sidebar.

Screenshots, screen recording, code snippet

No response

Environment info

Only tested on 6.3 Rc 1.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@carolinan carolinan added Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Testing Needs further testing to be confirmed. labels Jul 19, 2023
@jordesign jordesign added the [Type] Bug An existing feature does not function as intended label Jul 19, 2023
@github-actions
Copy link

Hi,
This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps.
Thanks for helping out.

@github-actions github-actions bot added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Aug 19, 2023
@jordesign jordesign removed the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Oct 26, 2023
@tellthemachines tellthemachines removed the Needs Testing Needs further testing to be confirmed. label Apr 4, 2024
@tellthemachines
Copy link
Contributor

I can reproduce this issue, but I'm not certain it's a bug 😅

The way that global styles is implemented means that if the theme doesn't provide a theme.json file, the wp_global_styles custom post type never gets created (see relevant code here). Without the custom post type, nothing the global styles panel works at all, including additional CSS. I think ideally we should hide the whole panel, because trying to edit styles with no result is a very broken experience.

This raises a few questions though:

  • Should it be possible to edit global styles if the theme doesn't provide a theme.json file?
  • If not, should it be possible to have a block theme without a theme.json?
  • How might this play out in a scenario where it's possible to mix and match templates and theme.json files from different themes as outlined in Decouple block themes into composable parts: Tracking issue #55595?

@carolinan
Copy link
Contributor Author

If not, should it be possible to have a block theme without a theme.json?

Requiring theme.json now would be a breaking change. In its most simple version, a block theme is only a style.css and a index.html file. It would only use a theme.json if it needed to overwrite the WordPress defaults.

@tellthemachines
Copy link
Contributor

That makes sense! I think the best thing to do for now is to hide the global styles panel. If a theme were using a stylesheet for its CSS instead of theme.json, it wouldn't be possible for users to edit the theme styles in global styles anyway.

@ramonjd
Copy link
Member

ramonjd commented Apr 8, 2024

I think the best thing to do for now is to hide the global styles panel.

Looks like there's an issue for this from 2020:

@carolinan
Copy link
Contributor Author

I think the option needs to be available even if the theme does not add any changes to the default styling or settings.

Thinking of how classic themes and the Customizer work, I can still use the Customizer's CSS field even if the theme does not add any Customizer controls.

@tellthemachines
Copy link
Contributor

I can still use the Customizer's CSS field even if the theme does not add any Customizer controls.

That's a good point, but the implementation of Additional CSS in global styles won't make this easy. As I mentioned above, it's saved in the wp_global_styles custom post type, which is conditional on the presence of a theme.json. This makes sense because we want to also be able to add Additional CSS in theme.json files themselves, and that CSS, if it exists, will be reflected in the UI (so it's editable by the user).

I think if we want to make Additional CSS available for block themes without theme.json, we'll need a whole new implementation for it. How impactful might that work be? Is this a useful enough feature for enough people that it would be worth the developer time investment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

4 participants