Created
October 10, 2012 14:50
-
-
Save Kevinlearynet/3866108 to your computer and use it in GitHub Desktop.
Google CDN Hosted jQuery 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
/** | |
* Google hosted jQuery | |
*/ | |
function google_hosted_jquery( $src, $handle ) { | |
// Only run for jQuery | |
if ( $handle == "jquery" ) { | |
$parse_url = parse_url( $src ); | |
$version = str_replace( 'ver=', '', $parse_url['query'] ); | |
return "//ajax.googleapis.com/ajax/libs/jquery/$version/jquery.min.js"; | |
} | |
return $src; | |
} | |
add_filter( 'script_loader_src', 'google_hosted_jquery', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment