最新彻底删除 WordPress 站点健康状态面板的方法

WordPress从 5.2 版开启增加了一个站点健康功能,其实没啥用,直接删除 WordPress 站点健康状态面板和菜单项,将下面4项代码添加到当前主题函数模板functions.php中就可以干掉他们。

1、删除站点健康菜单项

  1. add_action( 'admin_menu', 'remove_site_health_menu' );

  1. function remove_site_health_menu(){

  1. remove_submenu_page( 'tools.php','site-health.php' );

  1. }

2、删除仪表盘站点健康状态面板

  1. add_action('wp_dashboard_setup', 'remove_site_health_dashboard_widget');

  1. function remove_site_health_dashboard_widget()

  1. {

  1. remove_meta_box('dashboard_site_health', 'dashboard', 'normal');

  1. }

3、阻止站点运行站点健康检查页

  1. add_action( 'current_screen', 'block_site_health_access' );

  1. function block_site_health_access() {

  1. if ( is_admin() ) {

  1. $screen = get_current_screen();

  1. if ( 'site-health' == $screen->id ) {

  1. wp_redirect( admin_url() );

  1. exit;

  1. }

  1. }

  1. }

4、禁用站点健康电子邮件通知

  1. add_filter( 'wp_fatal_error_handler_enabled', '__return_false' );

上述方法并不能禁止站点健康功能在后台偷偷运行,如果想彻底禁止站点健康检测,请添加下方代码

  1. add_filter( 'site_status_tests', 'prefix_remove_site_health', 100 );

  1. function prefix_remove_site_health( $tests ) {

  1. $hidden_tests = array(

  1. 'php_version' => 'direct', //PHP 版本

  1. 'wordpress_version' => 'direct', //WordPress 版本

  1. 'plugin_version' => 'direct', //插件版本

  1. 'theme_version' => 'direct', //主题版本

  1. 'sql_server' => 'direct', //数据库服务器版本

  1. 'php_extensions' => 'direct', //PHP 扩展

  1. 'php_default_timezone' => 'direct', //PHP 默认时区

  1. 'php_sessions' => 'direct', //PHP Sessions

  1. 'utf8mb4_support' => 'direct', //MySQL utf8mb4 支持

  1. 'https_status' => 'direct', //HTTPS 状态

  1. 'ssl_support' => 'direct', //安全通讯

  1. 'scheduled_events' => 'direct', //计划的事件

  1. 'http_requests' => 'direct', //HTTP请求

  1. 'debug_enabled' => 'direct', //启用调试

  1. 'file_uploads' => 'direct', //文件上传

  1. 'plugin_theme_auto_updates' => 'direct', //插件和主题自动更新

  1. 'dotorg_communication' => 'async', //与WordPress.org联通状态

  1. 'background_updates' => 'async', //后台更新

  1. 'loopback_requests' => 'async', //Loopback request

  1. 'authorization_header' => 'async', //Authorization header

  1. 'rest_availability' => 'direct', //REST API 可用性

  1. );

  1. foreach ( $hidden_tests as $test=>$type ) {

  1. unset( $tests[$type][$test] );

  1. }

  1. return $tests;

  1. }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ts小陈

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值