我同意@Zlatev 你可能不想做这个客户端。有更简单的方法来包含更少的内容。
有plugins 允许您这样做。即使是jetpack也有less support.
如果您的目标是将其包含在主题中,则可以使用wp-less.
Just download that plugin and drop in somewhere in your theme and include it in your functions.php
like this:
require get_template_directory() . \'/inc/wp-less/bootstrap-for-theme.php\';
一零
function mytheme_enqueue_less_css() {
wp_enqueue_style(\'official_flowershop-theme-style\', get_template_directory_uri().\'/css/less/theme.less\');
}
add_action( \'wp_enqueue_scripts\', \'mytheme_enqueue_less_css\' );
The plugin has lots of extra features you can use (see full list here): function mytheme_less_setup() {
define(\'WP_LESS_COMPILATION\', \'deep\');
$less = WPLessPlugin::getInstance();
$less->dispatch();
// do stuff with its API like:
$less->addVariable(\'bg_primary\', \'#A0D4A4\');
$less->addVariable(\'bg_secondary\', \'#474747\');
$less->addVariable(\'bg_light\', \'#f5f5f5\');
$less->addVariable(\'bg_body\', \'#ffffff\');
if (get_theme_mod(\'officialtheme_bg_primary\') != \'\' ) {
$less_color = get_theme_mod("officialtheme_bg_primary");
$less->addVariable("bg_primary", "$less_color");
}
if (get_theme_mod(\'officialtheme_bg_secondary\') != \'\' ) {
$less_color = get_theme_mod("officialtheme_bg_secondary");
$less->addVariable("bg_secondary", "$less_color");
}
if (get_theme_mod(\'officialtheme_bg_light\') != \'\' ) {
$less_color = get_theme_mod("officialtheme_bg_light");
$less->addVariable("bg_light", "$less_color");
}
if (get_theme_mod(\'officialtheme_bg_body\') != \'\' ) {
$less_color = get_theme_mod("officialtheme_bg_body");
$less->addVariable("bg_body", "$less_color");
} // WP Less initialize and add variables
}
add_action( \'after_setup_theme\', \'mytheme_less_setup\' );
Caution:虽然在一个主题/插件中使用较少的或sass/scss,但据我所知,目前还没有任何可用的插件解决方案可以为css添加前缀。对我来说,这是一个交易破坏者,因为我可以在我的电脑上用像Prepros 或代码套件。但是,如果您想轻松地使用prefix-free 虽然这是我们之前试图避免的,所以虽然这很容易,但不一定是一个很好的解决方案。