Last active
August 10, 2017 08:22
-
-
Save vpadhariya/f5d0004f6c70b68623891e09d5cce20d to your computer and use it in GitHub Desktop.
WordPress remove query string from static resource
This file contains hidden or 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 | |
/** | |
* Remove query string from static resource | |
* @param type $src | |
* @return type | |
*/ | |
function _remove_script_version($src) | |
{ | |
$return = $src; | |
/** | |
* Remember for some scripts its required like googleapis or | |
* other third party CDN resources that you need to ignore | |
*/ | |
if(!stristr($src, 'googleapis')) | |
{ | |
$parts = explode('?', $src); | |
$return = $parts[0]; | |
} | |
return $return; | |
} | |
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