Skip to content

Instantly share code, notes, and snippets.

@davidsword
Last active February 3, 2018 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsword/a3760b1ae2e00802c677ea2a66132f08 to your computer and use it in GitHub Desktop.
Save davidsword/a3760b1ae2e00802c677ea2a66132f08 to your computer and use it in GitHub Desktop.
<?
// When WP_DEBUG is true (aka: while developing) use LESS client side
add_action('wp_head', 'ds_use_clientside_LESS',999);
function ds_use_clientside_LESS() {
if ( WP_DEBUG ) : ?>
<link rel="stylesheet/less" type="text/css" href="<?= get_template_directory_uri() . '/style.less' ?>" />
<script type="text/javascript">less = { env: 'development' };</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/2.7.1/less.min.js"></script>
<? endif;
}
// When WP_DEBUG is false (aka: live site, after LESS compiled) use compiled .css file
add_action( 'wp_enqueue_scripts', 'ds_make_scripts' );
function ds_make_scripts() {
if (! WP_DEBUG ) {
wp_register_style('main', get_template_directory_uri() . '/style.css', '', null);
wp_enqueue_style( 'main');
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment