Last active
February 3, 2018 03:04
-
-
Save davidsword/a3760b1ae2e00802c677ea2a66132f08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// 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