It's not immediately clear what the circumstances of your WP install are. WP_DEBUG
is a sitewide constant that sits in your wp-config.php
, so if you use that as a condition the scripts will be loaded for everybody working in the same install. To toggle it, you must edit wp-config.php
, which is fine if that's what you want. It doesn't make a lot of sense, though, because it everybody is allowed to develop you might as well leave the condition out.
If there are other people working in the same install you may want to narrow down your condition, by binding it to login conditions. You could limit loading the scripts to administrators like this:
if (current_user_can('administrator')) { load the script; }
Or you can tie it to individual users like this:
$current_user = wp_get_current_user();
if ($current_user->user_login == 'yitzhaki') { load the script;}
So it depends on the conditions under which you are developing what the smartest approach is. You may also want to remove this code when you distribute your theme.
*.test
domain on my local server. I useif( false !== strpos( $_SERVER['SERVER_NAME'], '.test' ) ) { /* dev functions here */}
.