简体   繁体   English

使用LESS for WordPress主题选项

[英]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. 许多优质的WordPress主题允许管理员更改主题设置,如颜色和排版,然后(通常)直接将CSS插入标题以覆盖默认值或在多个预设样式表之间切换。

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). 是否可以允许管理员使用主题选项来设置基色,排版规则等,然后使用它们设置LESS / SASS变量并运行编译器以吐出一个全新的style.css文件使用这些变量代替默认值重建(显然我们还想要一种恢复默认值的方法)。

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. 我会从像PHP少编译器开始使用LESS PHP,并使用它来编译主题样式表并根据WordPress管理菜单中设置的选项重新编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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