Last active
March 12, 2019 14:10
-
-
Save mathetos/06c37f92b4972bcfda89785fed89b8f1 to your computer and use it in GitHub Desktop.
Function for conditionally enqueing minified or un-minified scripts based on WP_DEBUG
This file contains hidden or 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
<?php | |
add_action( 'wp_enqueue_scripts', 'debug_theme_enqueue_styles' ); | |
function debug_theme_enqueue_styles() { | |
if (WP_DEBUG == true) : | |
$random = mt_rand(); | |
wp_enqueue_style( 'main-css-unminified', get_template_directory_uri() . '/assets/styles/build/main.css', '', $random ); | |
else : | |
wp_enqueue_style( 'main-css-minified', get_template_directory_uri() . '/main.min.css', '', MY_THEME_VERSION ); | |
endif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment