-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
CSS color variables are generated even if the defaults are disabled in theme.json #67268
Comments
I am not sure I understand. You are correct that adding a custom color palette to theme.json does not disable the default color palette. But it seems that you have a solution that works for you? I am not sure what the question is. |
Let me explain, I don't understand why setting settings.color.defaultPalette to false doesn't disable default colors and all that goes with them ? Currently, without using the PHP filter, all default styles (color,gradients,duotone) are loaded, even though I don't want any. My question should be :
yes, it could change the way things work, although I can't see who's using this color palette ? |
Quoting from the issue #36834 (comment) :
|
To my knowledge this is for compatibility reasons. For example, a block a pattern may be using these colors to be compatible with all themes. Such is the case with some of the patterns provided by core. A plugin may also be using them. |
I see, I've never come across any of these cases. |
It would be of great help to have a complete and detailed issue, since the issue description says something different, it is quiet confusing.
I believe you meant disabling the color palette doesn't prevent the generation of css variables
In the comment you are saying that this does not solve the problem? |
I updated the description |
I am facing the same challenges in version 2 and 3 for theme.json. The main confusion arises from the documentation around the When starting a new project or theme, where backward compatibility isn’t a concern (there are no blocks or patterns registered), disabling settings in theme.json should work as expected (and as documented) and reflect those changes throughout the project. |
Where does the documentation say that the CSS variables are not output if you disable the options?
https://developer.wordpress.org/news/2024/07/04/15-ways-to-curate-the-wordpress-editing-experience/ Please let me know were you are reading this so that the documentation can be corrected. |
@carolinan, I am not the only developer misreading the same documentation, I am just saying that it might be easier to make it super obvious that the theme.json settings are only turning off pickers options (or controllers) in the editor, and for those that want to remove on purpose the core presets from being output or available in the store to use the PHP filters. |
The documentation already uses a notice, I am not sure how to make it more obvious than that. I think the problem is that many people don't read documentation. Also, I am unsure of if the PHP filter shared here removes the CSS variables, since the replies are unclear. |
I tested and the PHP filter works, at least for the palette, duotone, and gradients. We might have to increase the hook priority, then it works for the color defaults, but not for spacing/spacingSizes or typography/fontSizes defaults. |
Description
Would it be possible to clarify the solution to use only what is needed and not load/write
This was mentioned here #43385, #40183, #56180
I think it's not very clear today, in the theme.json, for example, set
settings.color.defaultPalette
to false doesn't prevent the generation of css variables and CSS.has-**
helpers, just like"settings.color.defaultGradients": false
or"settings.color.defaultDuotone" : false
.Currently, the only solution I've found is this one
Step-by-step reproduction instructions
1 Add theme.jon
2 Add settings.color.defaultPalette, settings.color.defaultGradients, settings.color.defaultDuotone to false
3 Inspect DOM
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
The text was updated successfully, but these errors were encountered: