-
-
Save tommcfarlin/bb94f210cbfbc6903d8b to your computer and use it in GitHub Desktop.
[WordPress] Using SCRIPT_DEBUG To Debug JavaScript Files in WordPress
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
<?php | |
// Add define('SCRIPT_DEBUG', true); to wp-config.php to enable loading of non-minified, | |
// non-concatenated scripts and stylesheets. | |
if ( ! defined( 'SCRIPT_DEBUG' ) ) { | |
if ( ! empty( $GLOBALS['wp_version'] ) ) { | |
$develop_src = false !== strpos( $GLOBALS['wp_version'], '-src' ); | |
} else { | |
$develop_src = false; | |
} | |
define( 'SCRIPT_DEBUG', $develop_src ); | |
} |
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
<?php | |
/* If we're debugging JavaScript files, define the | |
* suffix for the file to load the proper version. | |
*/ | |
$js_suffix = ( defined( 'SCRIPT_DEBUG' ) ) ? '.min.js' : '.js'; | |
wp_enqueue_script( | |
'acme-demo-javascript', | |
plugin_dir_url( dirname( __FILE__ ) ) . 'admin/assets/js/large-button' . $js_suffix, | |
array( 'jquery' ), | |
'1.0.0', | |
false | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment