Add a test to Tools > Site Health that warns when plugins your site depends on, like backups or security, are not active.
add_filter( 'site_status_tests', function ( array $tests ): array {
$tests['direct']['nahnu_required_plugins'] = [
'label' => 'Required plugins',
'test' => 'nahnu_site_health_required_plugins',
];
return $tests;
} );
function nahnu_site_health_required_plugins(): array {
// Plugin file => name to show.
$required = [
'updraftplus/updraftplus.php' => 'UpdraftPlus (backups)',
];
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$missing = array_filter( $required, fn ( string $name, string $file ): bool => ! is_plugin_active( $file ), ARRAY_FILTER_USE_BOTH );
$result = [
'label' => 'All required plugins are active',
'status' => 'good',
'badge' => [ 'label' => 'Site setup', 'color' => 'blue' ],
'description' => '<p>Every plugin this site relies on is installed and active.</p>',
'actions' => '',
'test' => 'nahnu_required_plugins',
];
if ( $missing ) {
$result['label'] = 'Some required plugins are not active';
$result['status'] = 'critical';
$result['badge'] = [ 'label' => 'Site setup', 'color' => 'red' ];
$result['description'] = '<p>These plugins should be active: ' . esc_html( implode( ', ', $missing ) ) . '.</p>';
$result['actions'] = '<p><a href="' . esc_url( admin_url( 'plugins.php' ) ) . '">Go to Plugins</a></p>';
}
return $result;
}
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
Site Health checks the things WordPress cares about, but not the things your site needs, like a backup plugin being active. Adding your own test puts those checks in the same place, and failures show up in the Site Health dashboard widget.
The site_status_tests filter registers tests. A “direct” test runs when the Site Health screen loads and calls your function, which returns a result with a label, a status of good, recommended or critical, a badge and a description.
This example checks a list of plugin files with is_plugin_active() and reports any that aren’t active as critical.
$required list to the plugin files you rely on. You’ll find them as folder/main-file.php in wp-content/plugins.'async' test so Site Health doesn’t hang.Deactivate one of the listed plugins and open Tools → Site Health. “Some required plugins are not active” should appear as a critical issue.