public
Created

WordPress: Removes the version parameter from the script URI for the Google CDN.

  • Download Gist
strip-query-string.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
<?php
// for the functions.php
add_filter('script_loader_src', 'toscho_script_loader_filter');
 
/**
* Removes the version parameter from the script URI for the Google CDN.
*
* @param string $src Original script URI
* @return string
*/
function toscho_script_loader_filter($src)
{
// Not our business.
if ( FALSE === strpos($src, 'http://ajax.googleapis.com/') )
{
return $src;
}
// Separate the version parameter.
$new_src = explode('?', $src);
 
// Just the URI without the query string.
return $new_src[0];
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.