0

In a theme where the user can choose the colour scheme from colour pickers in the customiser, what's the best practice for updating the style sheet?

My current method is to hook into wp_head and update the appropriate selectors using <style> tags.

This approach works fine when there's only a few selected affected, but what's the best way when overwriting large number of styles such as Bootstrap's default, primary, success, warning, etc, colours? In this case a large number of lines (even "minified") are inserted in to the document's head. Does this even matter?

0

Sounds like you have a design problem in your theme. Users never like being bombarded with thousands of options which they might not even be sure when and where they are applied, so they can't even test it. So the first question should be why is it that you are having so many options in the first place?

(side note, in a plugin I am collaborating on, we going to try and release a plugin to add the ability of having full styling abilities instead of cluttering the core plugin)

From the technical POV there is nothing bad in putting styling in the head, but if you are going to go that way, make sure you output it only on the pages that actually need it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.