Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save drlinux/ce7ab72a130279cec843 to your computer and use it in GitHub Desktop.
Save drlinux/ce7ab72a130279cec843 to your computer and use it in GitHub Desktop.
<?php
/**
* Removes file version queries from script/stylesheet calls.
* http://wordpress.stackexchange.com/a/96325/23011
*
* Enhanced to keep query of google font stylesheets:
* Removes “?ver=3.5.1” from http://domain.tld/wp-content/themes/theme/stlye.css?ver=3.5.1
* Leaves http://fonts.googleapis.com/css?family=MyFont untouched.
*/
add_filter( 'script_loader_src', 'gp130419_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', 'gp130419_remove_script_version', 15, 1 );
function gp130419_remove_script_version( $src ){
$url = explode( '?', $src );
if( 'http://fonts.googleapis.com/css' == $url[0] ) :
$version = explode( '&ver=', $url[1] );
$url[1] = $version[0];
endif;
return ( 'http://fonts.googleapis.com/css' == $url[0] ) ? $url[0] . '?' . $url[1] : $url[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment