Last active
October 23, 2022 01:34
-
-
Save warderer/8ca3279e11077f747024aa1944de5db8 to your computer and use it in GitHub Desktop.
[Remove WP Version Number] Hackers usually look for version number first when checking for vulnerabilities. By default wordpress prints the version number in header, rss feed, scripts and styles. #wordpress #security
This file contains hidden or 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
| # In template file functions.php | |
| # Remove version from header: | |
| remove_action('wp_head', 'wp_generator'); | |
| # Remove version from RSS feed | |
| function remove_version_info() { | |
| return ''; | |
| } | |
| add_filter('the_generator', 'remove_version_info'); | |
| # Remove version number from scripts and styles files | |
| function remove_version_from_style_js( $src ) { | |
| if ( strpos( $src, 'ver=' . get_bloginfo( 'version' ) ) ) | |
| $src = remove_query_arg( 'ver', $src ); | |
| return $src; | |
| } | |
| add_filter( 'style_loader_src', 'remove_version_from_style_js',9999); | |
| add_filter( 'script_loader_src', 'remove_version_from_style_js',9999); | |
| # Reference: Mansoor Ahmed (2021). 4 Ways to Secure Your WordPress Login. https://www.cloudways.com/blog/secure-wordpress-login/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment