Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. add_filter( 'style_loader_src', 'remove_src_version' );
  2. function remove_src_version ( $src ) {
  3. global $wp_version;
  4. $version_str = '?ver='.$wp_version;
  5. $version_str_offset = strlen( $src ) - strlen( $version_str );
  6.  
  7. if( substr( $src, $version_str_offset ) == $version_str )
  8. $without_ver = substr( $src, 0, $version_str_offset );
  9.  
  10. $file_path = str_replace(get_stylesheet_directory_uri(), get_stylesheet_directory(), $without_ver);
  11.  
  12. $file_path_alt = str_replace(get_template_directory_uri(), get_template_directory(), $without_ver);
  13.  
  14. if (file_exists($file_path)) {
  15. return $without_ver.'?ver='.filemtime($file_path);
  16. } elseif (file_exists($file_path_alt)) {
  17. return $without_ver.'?ver='.filemtime($file_path_alt);
  18. }
  19. else return $without_ver;
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement