'remove_wp_version',
'title' => 'Hide WordPress version number',
'desc' => 'Remove the generator tag and the core version from asset URLs',
'icon' => 'shield',
'risk' => 'safe',
'level' => 'beginner',
'audience' => 'everyone',
'priority' => 2,
'benefit' => 'Your WordPress version is visible in the page source. Hiding it makes it a little harder to match your site against known problems in that version, but most automated attacks try their exploits regardless. Keeping WordPress updated matters far more.',
'help' => 'Removes the tag from the page head and the generator line from feeds, and strips ?ver= from CSS and JS URLs when it equals the WordPress version. The version can still be worked out in other ways, for example from readme.html. Without the version in those URLs, browsers may keep a cached copy of a core file for a while after you update WordPress.',
'before' => ' in the page head',
'after' => 'Tag removed; core asset URLs carry no version.',
'detect' => function () {
return array(
'detected' => true,
'message' => 'WordPress version exposed in HTML source',
'safe' => true,
'savings' => 'Security',
);
},
'callback' => function () {
remove_action( 'wp_head', 'wp_generator' );
add_filter( 'the_generator', '__return_empty_string' );
$s = function ( $src ) {
if ( strpos( $src, 'ver=' . get_bloginfo( 'version' ) ) !== false ) {
$src = remove_query_arg( 'ver', $src );
}return $src;
};
add_filter( 'style_loader_src', $s, 9999 );
add_filter( 'script_loader_src', $s, 9999 );
},
);