There are several similar questions here, but none of them seem to concern my specific case, at least not what I found. Here is the code that I use to include the latest version of jquery in my WP theme, and also to make sure that it appears in the footer.
function current_jquery($version) {
global $wp_scripts;
if ( ( version_compare($version, $wp_scripts -> registered[jquery] -> ver) == 1 ) && !is_admin() ) {
wp_deregister_script('jquery');
wp_register_script('jquery',
'http://ajax.googleapis.com/ajax/libs/jquery/'.$version.'/jquery.min.js',
false, $version, true);
}
}
add_action('wp_head', current_jquery('1.5.1'));
Then I use wp_enqueue_script("jquery");in header.php and it works, except that I get a jquery include that ends with "jquery.min.js? Ver = 1.5.1" and I want to get rid of the request part.
I checked the wp_register_script function and from what I read, to get rid of the request, I just need to replace the second of the last variable with an empty string. '' However, when I do this, I get the "standard" version of Wordpress instead, that is, "jquery.min.js? Ver = 3.0.1" (or whatever that happens at that time).
Because I do not understand 100% everything that happens here (between current_jquery, add_action and wp_enqueue_script). I'm not even sure where to start (does this $ version get the WP version value somehow?) All I know is that wp_register_script doesn’t seem to respond to entering the version as it was documented. What am I missing here?
, (split, reg_replace, ) "src", , .