Created
July 18, 2022 10:11
-
-
Save texe/f0e3acc3c3c60543d9588b1346544d9d to your computer and use it in GitHub Desktop.
WordPress - remove version strings from CSS & JS link hrefs in WordPress
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
//Remove version strings from CSS and JS link hrefs | |
function ct_remove_version_strings( $src ) { | |
global $wp_version; | |
parse_str(parse_url($src, PHP_URL_QUERY), $query); | |
if ( !empty($query['ver']) && $query['ver'] === $wp_version ) { | |
$src = remove_query_arg('ver', $src); | |
} | |
return $src; | |
} | |
add_filter( 'script_loader_src', 'ct_remove_version_strings' ); | |
add_filter( 'style_loader_src', 'ct_remove_version_strings' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment