Files
wp-healthcheck/includes/steps/100-uptime.php
Steve Hanlon 6dd050ea1d Rename to ATT Site Healthcheck (private prefix)
Wholesale rename to avoid clashes with generic 'site healthcheck'
plugin names on a target site:

  - Plugin Name:        'Site Healthcheck' → 'ATT Site Healthcheck'
  - Main file:          site-healthcheck.php → att-site-healthcheck.php
  - Plugin folder:      site-healthcheck → att-site-healthcheck
  - Admin menu slug:    site-healthcheck → att-site-healthcheck
  - Settings slug:      site-healthcheck-settings → att-site-healthcheck-settings
  - PHP class prefix:   WPH_ → ATT_HC_
  - Function prefix:    wph_ → att_hc_
  - Option / transient: wph_* → att_hc_*
  - Action/filter:      wph_* → att_hc_*
  - CSS class prefix:   wph- → att-hc-
  - Constants:          WPH_GITEA_* → ATT_HC_GITEA_*
  - Class file names:   class-wph-*.php → class-att-hc-*.php
  - Dev folder:         ~/dev/wp-healthcheck → ~/dev/att-site-healthcheck

Existing in-progress sessions on installs that had the old wph_session
option will not migrate — they were intended for dev use only and the
user has confirmed this is OK for the rename window.

Smoke-tested on testsite: classes load, 14 steps discovered, save/load
round-trip works, admin page renders with new att-hc- CSS classes.

Recovery plugin detection unchanged — that lives in wp-site-recovery
and continues to be detected by Name + Author header.
2026-06-12 11:11:42 +01:00

61 lines
2.8 KiB
PHP

<?php
if (!defined('ABSPATH')) exit;
return new class extends ATT_HC_Step {
public function id(): string { return 'uptime'; }
public function title(): string { return 'Step 10 — Uptime and Availability'; }
public function sub_items(): array {
return [
'Check uptime monitoring logs if available — note any downtime incidents since the last healthcheck and flag to client if significant',
'Confirm the site is resolving correctly on both www and non-www',
];
}
public function autocheck(array $session_state): array {
$f = [];
// Known monitoring plugins
$monitors = [
'worker/init.php' => 'ManageWP Worker',
'mainwp-child/mainwp-child.php' => 'MainWP Child',
'jetpack/jetpack.php' => 'Jetpack',
'wp-umbrella/wp-umbrella.php' => 'WP Umbrella',
'uptime-robot/uptime-robot.php' => 'UptimeRobot',
];
$detected = [];
foreach ($monitors as $file => $label) {
if (function_exists('is_plugin_active') && is_plugin_active($file)) $detected[] = $label;
}
$f[] = $this->finding(
'monitor_plugin',
$detected ? 'ok' : 'info',
'Monitoring plugin',
$detected ? implode(', ', $detected) : 'none detected',
$detected ? 'Pull downtime stats from the relevant dashboard.' : 'External monitoring (UptimeRobot/BetterStack/Pingdom) may still be in place.'
);
// www vs non-www: try fetching both and see whether one redirects to the other
$home = home_url('/');
$parts = parse_url($home);
$host = $parts['host'] ?? '';
$scheme = $parts['scheme'] ?? 'https';
if ($host) {
$with_www = $scheme . '://' . (strpos($host, 'www.') === 0 ? $host : 'www.' . $host) . '/';
$without_www = $scheme . '://' . preg_replace('/^www\./', '', $host) . '/';
foreach (['with www' => $with_www, 'without www' => $without_www] as $label => $url) {
$resp = wp_remote_head($url, ['timeout' => 5, 'redirection' => 0]);
if (is_wp_error($resp)) {
$f[] = $this->finding('canonical_' . sanitize_key($label), 'warn', $label, $url, $resp->get_error_message());
continue;
}
$code = wp_remote_retrieve_response_code($resp);
$loc = wp_remote_retrieve_header($resp, 'location');
$detail = $loc ? '→ ' . $loc : '';
$f[] = $this->finding('canonical_' . sanitize_key($label), 'info', $label, 'HTTP ' . $code, $detail);
}
}
return $f;
}
};