Change color presets via php?

Hi there,

in Pro there are color presets (“Brand Primary”, etc.) I’ll guess these are css global variables. Is it possible to change them via php in function.php? It should be possible, as you do so with Pro.
Our client want to change a color over time and we do not want to send him to the Pro-Menu. We like to setup a page with an color picker and after sending the form we want to change the color via php.

Thank you,
Michael

Hi Michael,

Thanks for reaching out. Regretfully, this isn’t possible without custom development. It would be great if Global Colors were Global CSS variables but they’re not because when the system was developed there wasn’t enough browser support. This means they’re actually rewritten in the CSS output.

Considering this would be a pretty involved customization, it’s outside the scope of support we can offer but I can point you in the right direction if you want to explore the theme code. Take a look in this file:

cornerstone/includes/classes/styling/class-color-manager.php

Specifically, the cs_color_items filter is a place you could overwrite a color with an external value. I can’t really get more into it here, but hopefully that will get you started.

Hi @alexander,

I see. Thank you for pointing the direction.
However, I believe I will give a sql-query a try: Modifying “cornerstone_color_items” in the options table. There I find my color values.

Again thank you.
Michael

Ok sounds good!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.