Feature Request: WordPress version number remove
-
It is better have a toggle button to switch on the Remove or Hide WordPress version number feature in the security section.
Viewing 8 replies - 1 through 8 (of 8 total)
-
dotto
Try This
function wpcode_snippet_remove_query_strings_split( $src ) { $output = preg_split( "/(&ver|\\?ver)/", $src ); return $output ? $output[0] : ''; } add_action( 'init', function () { if ( ! is_admin() ) { add_filter( 'script_loader_src', 'wpcode_snippet_remove_query_strings_split', 15 ); add_filter( 'style_loader_src', 'wpcode_snippet_remove_query_strings_split', 15 ); } } );-
This reply was modified 1 year, 11 months ago by
DJABHipHop.
Just out of curiosity, why do you need all that code to just remove the version number?.. There are simpler snippets.
Its build in to aes but does not work
-
This reply was modified 1 year, 11 months ago by
DJABHipHop.
Yes, I just find out the remove WP version in the disable component section. Thks.
Try this to improve security & increase performance
/** * Remove the 'type="text/css"' attribute from stylesheet link tags. * * @param string $tag The complete HTML tag for the stylesheet. * @param string $handle The name of the stylesheet. * @param string $src The URL of the stylesheet file. * @return string The modified HTML tag for the stylesheet. */ function preload_css($tag, $handle, $src){ return str_replace('type="text/css"', "", $tag); } add_filter('style_loader_tag', 'preload_css', 10, 3); /** * Remove the 'type="text/javascript"' attribute from script link tags. * * @param string $tag The complete HTML tag for the script. * @param string $handle The name of the script. * @param string $src The URL of the script file. * @return string The modified HTML tag for the script. */ function preload_script($tag, $handle, $src){ return str_replace('type="text/javascript"', "", $tag); } add_filter('script_loader_tag', 'preload_script', 10, 3); /** * Remove query strings from script and style URLs. * * @param string $src The URL of the script or style. * @return string The URL without query strings. */ function wpcode_snippet_remove_query_strings_split($src) { $output = preg_split( "/(&ver|\\?ver)/", $src ); // Split the URL by '&ver' or '?ver' return $output ? $output[0] : ''; // Return the URL without query strings } add_filter('script_loader_src', 'wpcode_snippet_remove_query_strings_split', 15); add_filter('style_loader_src', 'wpcode_snippet_remove_query_strings_split', 15); function add_async_defer($tag, $handle, $src) { return "<script async='async' defer='defer' src='".$src."'></script>"; } add_filter('script_loader_tag', 'add_async_defer', 10, 3);Skip this line as breaks the back end
add_filter('script_loader_tag', 'add_async_defer', 10, 3);Thks, I will try this code snippet.
-
This reply was modified 1 year, 11 months ago by
Viewing 8 replies - 1 through 8 (of 8 total)
The topic ‘Feature Request: WordPress version number remove’ is closed to new replies.