Using Less Files

Hello,

Can I utilize the LESS files in my child theme and if so do I need to use a pre-processor or will BB take care of this?
Any guidance would be great!

Regards

Bob

Hey Bob,

I’ve already assigned this another member of our team who may be able to assist you.

Ben

Thanks Ben!

Hey Robert,

You can use LESS in your child theme, but BB doesn’t have any auto processing going on. With that said, here’s some code to get you going in the right direction.

So the first thing you need to do is include the LESS class and create a new instance of that…

if ( ! class_exists( 'lessc' ) ) {
			    require_once FL_THEME_DIR . '/classes/class-lessc.php';
		}

$less = new lessc;

Once you have that, you need to get your LESS file into a variable like so (replace our path with yours)…

$less = file_get_contents( FL_THEME_DIR . '/less/theme.less' );

And finally, you need to compile and save it…

$compiled = $less->compile( $less );

file_put_contents( YOUR_CACHE_FILE, $less )

Let me know if you have any questions about that.

Justin

1 Like

Justin,

That’s perfect, thanks very much!

You’re welcome, Robert!