Created
August 6, 2012 09:43
-
-
Save WolfieZero/3272892 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
define('DEBUG_JS', false); // Debug JS; seperates out the unminimised files | |
/*****************************************************************************/ | |
/** | |
* Enqued Scripts | |
* Sets up scripts to be included on the site | |
* | |
* Files called when not in debug mode are wrapped in `jsFileInc()`; this appends the URI from `.js` to `.min.js` | |
* | |
* @return null | |
*/ | |
function enquedScripts() { | |
if( !is_admin() ) { | |
// wp_deregister_script('l10n'); //http://wordpress.stackexchange.com/questions/5451/what-does-l10n-js-do-in-wordpress-3-1-and-how-do-i-remove-it | |
wp_deregister_script('jquery'); | |
wp_enqueue_script('jquery', jsFileInc('http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js'), false, false, true); | |
wp_enqueue_script('jqueryui', jsFileInc('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.js'), false, false, true); | |
wp_enqueue_script('twitterplatform', 'http://platform.twitter.com/widgets.js', false, false, true); | |
if (DEBUG_JS) { | |
wp_enqueue_script('fancybox.js', get_template_directory_uri().'/script/plugins/fancybox.js', array('jquery'), SITE_VERSION, true); | |
wp_enqueue_script('validate.js', get_template_directory_uri().'/script/plugins/jquery.validate.js', array('jquery'), SITE_VERSION, true); | |
wp_enqueue_script('masonry.js', get_template_directory_uri().'/script/plugins/masonry.js', array('jquery'), SITE_VERSION, true); | |
wp_enqueue_script('placeholder.js', get_template_directory_uri().'/script/plugins/placeholder.js', array('jquery'), SITE_VERSION, true); | |
wp_enqueue_script('rotator.js', get_template_directory_uri().'/script/plugins/rotator.js', array('jquery'), SITE_VERSION, true); | |
wp_enqueue_script('smoothscroll.js', get_template_directory_uri().'/script/plugins/smoothscroll.js', array('jquery'), SITE_VERSION, true); | |
} | |
wp_enqueue_script('main.js', jsFileInc(get_bloginfo('template_directory').'/script/main.js'), array('jquery'), SITE_VERSION, true); | |
} | |
} | |
/*****************************************************************************/ | |
/** | |
* Javascript Include | |
* Includes Javascript according to if it's in debug mode or not | |
* | |
* @param string $src The original, uncompressed, source file of the JS | |
* @param string $ext='.js' The extension of the file | |
* @return string The file path | |
*/ | |
function jsFileInc($src, $ext='.js') { | |
if (!DEBUG_JS) $src = str_replace($ext, '.min'.$ext, $src); | |
return $src; | |
} | |
/*****************************************************************************/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment