移除WordPress版本号

收藏移除WordPress版本号的方法:

// 隐藏js/css附加的WP版本号
function jdsh8_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 ) {
 // 用WP版本号 + 456.6来替代js/css附加的版本号
 // 既隐藏了WordPress版本号,也不会影响缓存
 // 建议把下面的 456.6 替换成其他数字,以免被别人猜出
 $src = str_replace($wp_version, $wp_version + 456.6, $src);
 }
 return $src;
}
add_filter( 'script_loader_src', 'jdsh8_remove_wp_version_strings' );
add_filter( 'style_loader_src', 'jdsh8_remove_wp_version_strings' );
//删除在WP后台的右下方有版本号
add_filter('admin_footer_text', 'left_admin_footer_text');
function left_admin_footer_text($text) {
// 左边信息改成自己的站点
$text = '感谢访问aiboshuo.com';
return $text;
}
add_filter('update_footer', 'right_admin_footer_text', 11);
function right_admin_footer_text($text) {
// 隐藏右边版本信息
}

删除<head>标签中的WP版本号见https://pdbn.top/p190

以上代码添加到模板中的functions.php文件中