Filtering theme, default, and custom colors (add_theme_support('editor_color_palette') not working) #63585
briangrider
started this conversation in
Developer Experience
Replies: 1 comment 2 replies
-
It's If you are using theme.json, there are a few filters you can adjust like so: add_filter("wp_theme_json_data_default", function ($theme_json) {
$data = $theme_json->get_data();
// Remove default color palette.
$data["settings"]["color"]["palette"]["default"] = [];
// Remove default duotone.
$data["settings"]["color"]["duotone"]["default"] = [];
// Remove default gradients.
$data["settings"]["color"]["gradients"]["default"] = [];
// Update the theme data.
$theme_json->update_with($data);
return $theme_json;
}); I imagine there's also a way to do that in Javascript so you can make adjustments based on the editor context? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
I've been coming up against this issue for a while... hoping for some input. As far as I can tell, there is no way to filter, replace, or change colors programmatically in Gutenberg when using block themes (specifically 2022, 2023, and 2024) outside of the theme itself. updateSettings and updateEditorSettings don't seem to work (and would be limited to just theme colors even if they did). This seems like a basic necessity in a platform that prides itself on customizability. I feel like there should be a hook similar to useSettings (called "useUpdateSettings" or something like that), that operates the same as useSettings but gives you a setter instead of a value. For example, you pass in "color.palette.theme" and something similar to setThemeColors((prevThemeColors)=>{}) is returned that allows you to filter/update/change that data. Is there a reason this doesn't exist? I assume it's to make people stay within the limitations of the style panel but as a plugin developer, it's very limiting.
Additionally, it seems add_theme_support('editor_color_palette') is not working with the 2024, 2023, and 2022 theme. Is there a trick I'm missing here? With a custom barebones theme that doesn't have default theme colors, it seems to still work.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions