Created
April 26, 2012 17:40
-
-
Save LogixRepo/2501216 to your computer and use it in GitHub Desktop.
Wordpress: Function - enqueue_scripts_method()
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
| /* ENQEUE CUSTOM SCRIPTS */ | |
| function enqueue_scripts_method() { | |
| /* | |
| wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); | |
| $handle (required): script name - Default: None | |
| $src (optional): url to script (optional if wp_register_script has been used, if this is the case use just $handle) - Default: false | |
| $deps (optional): if script depends on another script, i.e. 'jquery' - Default: array() | |
| $ver (optional): script version - Default: false | |
| $in_footer (optional): Boolean to link file in wp_footer(). Default: false | |
| */ | |
| wp_deregister_script( 'jquery' ); | |
| wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js'); | |
| wp_enqueue_script( 'jquery' ); | |
| wp_register_script('modernizr', get_template_directory_uri() . '/js/libs/modernizr.min.js'); | |
| wp_enqueue_script ('modernizr'); | |
| wp_enqueue_script('respond.js', get_template_directory_uri() . '/js/libs/respond.min.js', array('jquery'), '1.0', true); | |
| wp_enqueue_script('custom_script', get_template_directory_uri() . '/js/script.js', array('jquery'), '1.0', true); | |
| // Load Mobilizr if the user is on a mobile device. | |
| $agent = $_SERVER['HTTP_USER_AGENT']; | |
| if(preg_match('/iPhone|Android|Blackberry/i', $agent)){ | |
| wp_enqueue_script('mobilizr', get_template_directory_uri() . '/js/mobilizr.js', array('jquery'), '1.0', true); | |
| } | |
| } | |
| add_action('wp_enqueue_scripts', 'enqueue_scripts_method'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment