Last active
March 7, 2018 02:11
-
-
Save JayOkey/d8f26de315374cc2dcb7756044863061 to your computer and use it in GitHub Desktop.
Removes WordPress query strings from Javascript and CSS files
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
<?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