Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * WordPress automatically adds query strings to enqueued static resources like stylesheets and scripts.
- * This is meant for caching reasons (e.g. if a script version changes,
- * it should prevent the client to use a cached copy of the old one).
- * However, this feature can be omitted to improve site performance.
- */
- function remove_query_strings_questionmark( $src ){
- $rqs = explode( '?ver', $src );
- return $rqs[0];
- }
- function remove_query_strings_ampersand( $src ){
- $rqs = explode( '&ver', $src );
- return $rqs[0];
- }
- // hook filters
- add_filter( 'script_loader_src', 'remove_query_strings_questionmark', 15, 1 );
- add_filter( 'style_loader_src', 'remove_query_strings_questionmark', 15, 1 );
- add_filter( 'script_loader_src', 'remove_query_strings_ampersand', 15, 1 );
- add_filter( 'style_loader_src', 'remove_query_strings_ampersand', 15, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement