Last active
April 4, 2019 00:31
-
-
Save frankiejarrett/2657482 to your computer and use it in GitHub Desktop.
How to hide your WordPress version number…completely
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
<?php | |
/* Hide WP version meta tag from header and generator tag from feeds | |
* @return null | |
* @filter the_generator | |
*/ | |
function fjarrett_remove_wp_version_tag() { | |
return null; | |
} | |
add_filter( 'the_generator', 'fjarrett_remove_wp_version_tag' ); | |
/* Hide WP version strings from scripts and styles | |
* @return {string} $src | |
* @filter script_loader_src | |
* @filter style_loader_src | |
*/ | |
function fjarrett_remove_wp_version_strings( $src ) { | |
global $wp_version; | |
$parts = explode( '?', $src ); | |
if ( $parts[1] === 'ver=' . $wp_version ) { | |
return $parts[0]; | |
} | |
else { | |
return $src; | |
} | |
} | |
add_filter( 'script_loader_src', 'fjarrett_remove_wp_version_strings' ); | |
add_filter( 'style_loader_src', 'fjarrett_remove_wp_version_strings' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Originally posted on: http://frankiejarrett.com/how-to-hide-your-wordpress-version-number-completely/