暴露版本号是不安全的一个行为,因为某些版本具有特有的一些漏洞
WordPress的版本号隐藏方法:
在当前主题的 functions.php 文件中添加如下代码
function remove_wp_version() { return ''; } add_filter('the_generator', 'remove_wp_version'); function remove_wp_version_strings( $src ) { global $wp_version; parse_str(parse_url($src, PHP_URL_QUERY), $query); if ( !empty($query['ver']) && $query['ver'] === $wp_version ) { $src = str_replace($wp_version, 520, $src); } return $src; } add_filter( 'script_loader_src', 'remove_wp_version_strings' ); add_filter( 'style_loader_src', 'remove_wp_version_strings' );
我在保存的时候发生了无法保存的错误,然后我是直接在服务器文件中修改的,改完刷新编辑器发现无法显示 functions.php ,这个问题是我使用了中文的代码注释导致的,删掉中文注释即可