I have no idea why so many say its broken with 3.4.x.
I’m using it with WP 3.4.1 and it works fine. Anyway, you can disable the plugin and compile the .less file to .css, then change the line in funcions.php to include it in your theme, thats all.
I use Simpless for compile the less file. Once you know about less you won’t miss it anymore π
It doesn’t work for me either on WordPress 3.4.2, running on Windows XAMPP. I’m developing a theme with the WordPress Roots theme. I created an app.less file and tried to write some code in it, but the output isn’t compiled to CSS.
Is there any debug info that could help?
I investigated further and noticed several issues:
- Roots theme uses the wp_enqueue_scripts action. It says here to use the wp action. Why is that so? Why doesn’t it work with the wp_enqueue_scripts hook?
- In the Roots theme there are some htaccess tricks to put all the stylesheets into /assets/css. It seems the WP-LESS plugin needs the full wp-content path to the file. Is this a bug? Any workarounds?
Update – got it to work with the following code:
function roots_enqueue_less() {
wp_enqueue_style('roots_app', '/themes/mytheme/assets/css/app.less', array(), '', 'screen, projection');
}
add_action('wp', 'roots_enqueue_less');
- Full path following wp-content
- Using wp as the action
In my opinion it should also work with wp_enqueue_scripts action and with the /assets trick.
Plugin Author
thom4
(@oncletom)
Do you still encounter the problem?
I don’t see any change with WP 3.4.x.
Can you all copy/paste how you enqueue your CSS?
Thanks π
As I wrote above – the enqueued LESS file only works when it’s added to the ‘wp’ hook. When it’s added to ‘wp_enqueue_scripts’ it doesn’t work. At least not with the Roots theme:
http://www.rootstheme.com/
Plugin Author
thom4
(@oncletom)
wp_enqueue_scripts is far too late for a hook to make this working at the moment.
I’ve described the Processing Workflow on the project wiki.
I guess I could delay the LESS processing to the wp_print_styles action, in a low priority.
Sorry, I meant wp_enqueue_style. Might want to change the instructions here: http://ww.wp.xz.cn/extend/plugins/wp-less/faq/
Plugin Author
thom4
(@oncletom)
I’ve digged in the code: they enqueue CSS files on wp_enqueue_scripts, which is AFTER wp action and before wp_print_styles.
They recommend to compile files as yourtheme/style.css.
Anyway, their way of registering CSS is not very handy, especially as it forces the browser to load 4 CSS files⦠which is counterproductive for performances.
What I would do
add_action('wp_enqueue_scripts', 'customize_roots_css', 200);
add_action('init', 'my_less_styles');
function customize_roots_css(){
wp_dequeue_style('roots_bootstrap');
wp_dequeue_style('roots_bootstrap_responsive');
wp_dequeue_style('roots_app');
wp_dequeue_style('roots_child');
}
function my_less_styles(){
wp_enqueue_style('theme_main', get_stylesheet_directory_uri() . '/style.less');
}
Use @import to load bootstrap, responsive and roots CSS (if needed) to compile that in 1 working file.
Plugin Author
thom4
(@oncletom)
Problem finally addressed by a contribution β https://github.com/oncletom/wp-less/pull/18
Lands in 1.5.0.
THANK YOU. This works in roots theme now.
Plugin Author
thom4
(@oncletom)
Cool, nice to hear that π