Last active
September 1, 2016 08:59
-
-
Save palicko/65e9bb051df3f72190fe40df3873656c to your computer and use it in GitHub Desktop.
Hide WP generators
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
/* Hide WP version strings from scripts and styles | |
* @return {string} $src | |
* @filter script_loader_src | |
* @filter style_loader_src | |
*/ | |
function mu_remove_wp_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', 'mu_remove_wp_version_strings' ); | |
add_filter( 'style_loader_src', 'mu_remove_wp_version_strings' ); | |
/* Hide WP version strings from generator meta tag */ | |
function mu_remove_version() { | |
return ''; | |
} | |
add_filter( 'the_generator', 'mu_remove_version' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment