How to Disable Site Health in WordPress

In the ever-evolving landscape of WordPress, having control over your website’s features is crucial. Among these features, Site Health stands out as a tool to ensure your site’s stability and performance. However, every website is unique, and there might be situations where you want to disable Site Health. In this tutorial, we’ll walk you through the process of turning off Site Health in your WordPress installation. Rest assured, you won’t need any plugins to accomplish this task.

Before proceeding with any customizations in WordPress, it’s essential to set up a child theme. A child theme acts as a safe and efficient way to make modifications without affecting the parent theme. If you haven’t set up a child theme yet, follow this tutorial on How to Create a Child Theme for Customization. It will guide you through the process and ensure that your customizations remain intact even after theme updates.

Open the Theme Functions File

Inside your active child-theme folder, look for the functions.php file. This file contains the functions and code that modify the behavior of your theme. We’ll be adding our code snippets here.

Disable Site Health Submenu Item

Let’s start by removing the Site Health submenu item from the WordPress admin panel. Copy and paste the following code snippet at the end of your functions.php file:

// Remove Tools Submenu Item for Site Health.
add_action( 'admin_menu', function () {
	remove_submenu_page( 'tools.php', 'site-health.php' );
} );
Code language: PHP (php)

This code snippet effectively removes the Site Health submenu item from the Tools menu in your WordPress admin dashboard.

We use the admin_menu action hook to execute the provided function. Within the function, we utilize the remove_submenu_page function to eliminate the Site Health page from the Tools submenu.

Preventing Direct Access to Site Health

Continuing on, we’ll prevent direct access to the Site Health page. Add the following code snippet just below the previous one in your functions.php file:

// Prevent direct access to the Site Health page.
add_action( 'current_screen', function () {
    $screen = get_current_screen();
    if ( 'site-health' === $screen->id ) {
        wp_safe_redirect( admin_url() );
} );
Code language: PHP (php)

This code ensures that users attempting to directly access the Site Health page will be redirected to the admin dashboard.

The current_screen action hook is employed to check the current screen. If the screen ID corresponds to ‘site-health’, the user is redirected to the admin dashboard using the wp_safe_redirect function.

Disable Site Health Dashboard Widget

Lastly, let’s disable the Site Health dashboard widget that appears on your WordPress admin dashboard. Include the following code snippet in your functions.php file:

// Disable the Site Health Dashboard Widget.
add_action( 'wp_dashboard_setup', function () {
    global $wp_meta_boxes;
    if ( isset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_site_health'] ) ) {
        unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_site_health'] );
} );
Code language: PHP (php)

This code snippet removes the Site Health dashboard widget from your WordPress admin dashboard.

The wp_dashboard_setup action hook allows us to modify the dashboard widgets. Inside the provided function, we remove the dashboard_site_health widget from the $wp_meta_boxes global array.

That’s it! You’ve successfully disabled the Site Health feature in WordPress without the need for any plugins. By following the steps outlined in this tutorial, you’ve gained control over your WordPress experience and tailored it to meet your specific requirements.

Leave your feedback and help us improve ๐Ÿถ

We hope you found this article helpful! If you have any questions, feedback, or spot any errors, please let us know in the comments. Your input is valuable and helps us improve. If you liked this article, please consider sharing it with others. And if you really enjoyed it, you can show your support by buying us a cup of coffee โ˜•๏ธ or donating via PayPal ๐Ÿ’ฐ.

More free knowledge, because why not?

Your thoughts matter, leave a reply ๐Ÿ’ฌ

Your email address will not be published. Required fields are marked *