简体   繁体   中英

Using LESS for WordPress Theme Options

Curious if anyone has tried something like this/if it would work:

Many premium WordPress themes allow the administrator to change theme setting like color and typography and then (typically) either inject CSS directly into the header to override the defaults OR switch between a number of pre-set stylesheets.

Would it be possible to allow an administrator to instead use theme options to set base colors, typography rules, etc. and then use these to set LESS/SASS variables and run the compiler to spit out a completely new style.css file that would be rebuilt using those variables in the place of the default values (obviously we would also want a way to revert to the default).

I THINK this should be possible (and might actually be a great lightweight approach to allow for some pretty advanced customization) but I'm curious if anyone has tried something similar and what potential drawbacks I might run into.

This is certainly possible, though I have never done it personally. I would start out with a PHP less compiler like LESS PHP and use that both to compile the theme stylesheet and to re-compile based on options set in a WordPress admin menu.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM