0

I'm working in a wordpress plugin, and i want to create a "customize" menu. My idea is to put a few color pickers to allow admins to change the color scheme of the theme (buttons, titles,font, background...) without edit css directly.

I have the menu, but now i don't know how to "apply" the variables to css. I thought a few solutions:

1- Convert the css file to php and get the variables. This solution is not useful because i need to change theme's files, and i want to do it only in my plugin.

2- The second way is to "overwrite" the css. The original css will remain intact, but i will add a few lines at the end of the css file, adding "!important" to overwrite the first order. This way seems too "ugly" and bad solution overall.

The question is, what is the best method to do this?

Thank you a lot!

2 Answers 2

1

I would suggest another solution :

Add a css class to the body, based on the user's preference. This class will override the color settings, without needing any !important

Sign up to request clarification or add additional context in comments.

Comments

0

Well, I'm not professional, in my opinion, if you want to change the color of all the buttons, font, background... but if the theme has many color of an element (for example, the font has more than one color, if you change the color globally, whether it looks good?) If it doesn't matter, maybe you can add class to the element you want to change? Using the priority of css, maybe can realize it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.