Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * WordPress automatically adds query strings to enqueued static resources like stylesheets and scripts.
  5. * This is meant for caching reasons (e.g. if a script version changes,
  6. * it should prevent the client to use a cached copy of the old one).
  7. * However, this feature can be omitted to improve site performance.
  8. */
  9.  
  10. function remove_query_strings_questionmark( $src ){
  11. $rqs = explode( '?ver', $src );
  12. return $rqs[0];
  13. }
  14.  
  15. function remove_query_strings_ampersand( $src ){
  16. $rqs = explode( '&ver', $src );
  17. return $rqs[0];
  18. }
  19.  
  20. // hook filters
  21. add_filter( 'script_loader_src', 'remove_query_strings_questionmark', 15, 1 );
  22. add_filter( 'style_loader_src', 'remove_query_strings_questionmark', 15, 1 );
  23. add_filter( 'script_loader_src', 'remove_query_strings_ampersand', 15, 1 );
  24. add_filter( 'style_loader_src', 'remove_query_strings_ampersand', 15, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement