public
Last active

How to hide your WordPress version number…completely

  • Download Gist
gistfile1.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
<?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' );

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.