Files
wp-healthcheck/includes/steps/110-small-fixes.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

67 lines
2.6 KiB
PHP

<?php
if (!defined('ABSPATH')) exit;
return new class extends ATT_HC_Step {
public function id(): string { return 'small_fixes'; }
public function title(): string { return 'Step 11 — Small Fixes'; }
public function blurb(): string {
return 'Address any small issues found during the check that fall within the ~15 minute threshold. Anything longer goes on the quote list.';
}
public function sub_items(): array {
return [
'Broken internal links on key pages',
'Missing alt text on homepage images',
'Obvious content errors noticed in passing (broken shortcodes, missing widgets)',
'Reactivating a deactivated-but-needed plugin',
'Clearing accumulated spam comments',
];
}
public function autocheck(array $session_state): array {
$f = [];
// Deactivated-but-installed plugins
if (!function_exists('get_plugins')) require_once ABSPATH . 'wp-admin/includes/plugin.php';
$inactive = [];
foreach (get_plugins() as $file => $meta) {
if (!is_plugin_active($file)) $inactive[] = ($meta['Name'] ?? $file);
}
$f[] = $this->finding(
'inactive_plugins',
count($inactive) > 0 ? 'info' : 'ok',
'Deactivated-but-installed plugins',
(string) count($inactive),
$inactive ? implode(', ', array_slice($inactive, 0, 10)) . (count($inactive) > 10 ? ' …' : '') : ''
);
// Homepage alt-text scan
$url = home_url('/');
$resp = wp_remote_get($url, ['timeout' => 6]);
if (is_wp_error($resp)) {
$f[] = $this->finding('homepage_alt', 'warn', 'Homepage alt text', 'fetch failed', $resp->get_error_message());
} else {
$body = (string) wp_remote_retrieve_body($resp);
$imgs = 0;
$missing = 0;
if (preg_match_all('/<img\b[^>]*>/i', $body, $matches)) {
foreach ($matches[0] as $tag) {
$imgs++;
if (!preg_match('/\salt\s*=\s*"[^"]+"/i', $tag) && !preg_match('/\salt\s*=\s*\'[^\']+\'/i', $tag)) {
$missing++;
}
}
}
$level = $missing > 0 ? 'warn' : 'ok';
$f[] = $this->finding(
'homepage_alt',
$level,
'Homepage alt text',
$missing . ' missing of ' . $imgs . ' image(s)',
$missing ? 'Empty/missing alt attributes hurt accessibility and SEO.' : ''
);
}
return $f;
}
};