Skip to content

Instantly share code, notes, and snippets.

@JayOkey
Last active March 7, 2018 02:11
Show Gist options
  • Save JayOkey/d8f26de315374cc2dcb7756044863061 to your computer and use it in GitHub Desktop.
Save JayOkey/d8f26de315374cc2dcb7756044863061 to your computer and use it in GitHub Desktop.
Removes WordPress query strings from Javascript and CSS files
<?php
/**
* Improve the ability to cache CSS and JS by removing query strings
**/
function remove_script_version( $src ){
if ( strpos( $src, 'uploads/bb-plugin' ) !== false || strpos( $src, 'uploads/bb-theme' ) !== false ) {
return $src;
}
$parts = explode( '?ver', $src );
return $parts[0];
}
add_filter( 'script_loader_src', 'remove_script_version', 15, 1 );
add_filter( 'style_loader_src', 'remove_script_version', 15, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment