从WordPress5.2版本之后我们在升级程序是否会发现菜单中多了一项Site Health。Site Health是用于检测当前网站中需要有哪些改进的,我们可以在后台 - 工具 - Site Health中可以看到。如果我们觉得没有必要,也可以禁止掉,这里老蒋整理禁止的方法,如果有需要就对应添加到当前主题Functions.php文件中。
禁止的原因是出于可能一直检测网站导致网站速度变慢的问题,所以我们这里不让他检测。


//禁PHP版本检测
function prefix_remove_site_health( $tests ) {<br> unset( $tests'direct' );
return $tests;
}
add_filter( 'site_status_tests', 'prefix_remove_site_health' );

这里我们还可以一并禁止程序更新检测和插件检测。

//禁PHP、程序版本、插件版本检测
function prefix_remove_site_health( $tests ) {<br> unset( $tests'direct' );
unset( $tests['direct']['wordpress_version'] );<br> unset( $tests'direct' );
return $tests;
}
add_filter( 'site_status_tests', 'prefix_remove_site_health' );

这里我们只是可以禁止他的检测状态,全部删除掉目前还没有方法。


扫描二维码,在手机上阅读!