Code-Snippets-Functions/Execute a function on a child site/WordPress/disable-site-health-in-wp-admin.txt

34 lines
607 B
Text

if ( ! defined( 'ABSPATH' ) ) exit;
// disable the admin menu
function escode_remove_site_health_menu() {
remove_submenu_page( 'tools.php', 'site-health.php' );
}
add_action( 'admin_menu', 'escode_remove_site_health_menu' );
// block site health page screen
function wp_block_site_health_access() {
if ( is_admin() ) {
$screen = get_current_screen();
// if screen id is site health
if ( 'site-health' == $screen->id ) {
wp_redirect( admin_url() );
exit;
}
}
}
add_action( 'current_screen', 'wp_block_site_health_access' );