allow for turning off
Closed this issue · 11 comments
So it looks like right now it turns whatever less file you give it into a style.css in the uploads directory.
I would rather it compile the way a desktop compiler would, so from:
/less/styles.less into
/css/styles.css
That way I can just include /css/styles.css - and then once I was done working on the theme, I could turn off the wp-less compiling action, so it wouldn't keep running on every page load.
How can I do this?
The compiler only runs if the .less file has been modified, not on every
page load. If you'd prefer what you say you'd be better off just using a
desktop app or if you want to use wp-less then you could copy the compiled
files to the theme after you're finished.
The reason for compiling the files to the uploads folder is that in a
secure WordPress installation that's the only folder that should be
writable by the server.
Hope that answers your question.
For various reasons I don't always develop locally. If I'm editing the theme files using the Theme Editor already, what difference does it make?
What's the theme editor? :)
To answer your question, you should be able to use the online editor the same way you upload updated files via FTP, i.e. wp-less detects a change in the date modified and recompiles for those changes, but then keeps the result cached till you edit again. Should work fine.
I know that -- that wasn't my question. Again, my question is, how can I have it compile a file like:
/less/styles.less into
/css/styles.css
Rather than compile into the uploads directory.
Thanks.
What's the end goal? As Rob said, you can use a Desktop Compiler. To change the path, you'd probably also need to change permissions of your theme directory (which isn't recommended). Cheers
If WordPress's built-in theme editor can edit the files already, there is no reason this plugin couldn't edit them.
The server is running suPHP which doesn't require permission changes to do this. Regardless, permissions are my choice -- I'm not a newbie, and I'm not asking for advice on security. I'm asking how to change the file the compiler outputs. Can someone please answer my actual question?
You'd have to change a lot of the lines that relate to get_cache_dir() and WP_CONTENT*, rewriting a good portion of the plugin. I'm a PHP newbie, so it's not anything I can whip up in 5 mins. Good luck!
Hey, there are filters for the cache path and cache URL so you can use them:
<?php
add_filter( 'wp_less_cache_path', 'my_less_cache_path' );
add_filter( 'wp_less_cache_url', 'my_less_cache_url' )
function my_less_cache_path( $path ) {
return get_stylesheet_directory() . '/css';
}
function my_less_cache_url( $url ) {
return get_stylesheet_directory_uri() . '/css';
}
?>
Sorry for not getting to that point sooner but I thought your end goal was to stop the compiler running every time which it doesn't do anyway.
You thought of everything ;) Had the same misunderstanding.
Thank you!
Added this to the WIKI https://github.com/sanchothefat/wp-less/wiki/change-the-compiled-stylesheet-path-and-URL