Files
wp-healthcheck/includes/steps/60-visual.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

90 lines
4.4 KiB
PHP

<?php
if (!defined('ABSPATH')) exit;
return new class extends ATT_HC_Step {
public function id(): string { return 'visual'; }
public function title(): string { return 'Step 6 — Visual and Functional Check'; }
public function blurb(): string {
return 'Do a manual walkthrough of the site.';
}
public function sub_items(): array {
return [
'Homepage — load and visually inspect. Check for broken images, layout issues, console errors (open browser dev tools)',
'Navigation — click through the main menu. Confirm all links resolve correctly, no 404s on primary pages',
'Key pages — About, Contact, Services or equivalent. Check content renders correctly',
'Contact form — submit a test entry and confirm it delivers (check spam folder if no delivery). Note which form plugin is in use',
'If WooCommerce — check shop page loads, a product page loads, add to basket works. Do not need to complete a full test purchase every time unless flagged',
'If membership/login — confirm login page loads and (if test credentials available) login works',
'Mobile view — check the homepage and one internal page on a mobile viewport in browser dev tools',
'HTTPS — confirm the padlock is showing and there are no mixed content warnings',
'Redirects — confirm www/non-www and HTTP/HTTPS are redirecting correctly to the canonical URL',
];
}
public function autocheck(array $session_state): array {
$f = [];
$home = home_url('/');
// mShots screenshot (WordPress.com's public screenshot service, no key needed)
$shot = 'https://s.wordpress.com/mshots/v1/' . rawurlencode($home) . '?w=1200';
$f[] = $this->finding(
'screenshot',
'info',
'Homepage screenshot',
$home,
'mShots: ' . $shot . ' — open this URL to view the rendered preview.'
);
// Key pages we should be able to find
$pages = [
'Home' => $home,
'Login' => wp_login_url(),
'Posts page' => function_exists('get_post_type_archive_link') ? get_post_type_archive_link('post') : '',
];
if (function_exists('get_option')) {
$page_for_posts = (int) get_option('page_for_posts');
if ($page_for_posts) $pages['Posts page'] = get_permalink($page_for_posts) ?: $pages['Posts page'];
}
// WooCommerce shop?
if (class_exists('WooCommerce') && function_exists('wc_get_page_id')) {
$shop_id = (int) wc_get_page_id('shop');
if ($shop_id > 0) $pages['WC shop'] = get_permalink($shop_id);
$cart_id = (int) wc_get_page_id('cart');
if ($cart_id > 0) $pages['WC cart'] = get_permalink($cart_id);
$checkout_id = (int) wc_get_page_id('checkout');
if ($checkout_id > 0) $pages['WC checkout'] = get_permalink($checkout_id);
}
foreach ($pages as $label => $url) {
if (!$url) continue;
$resp = wp_remote_head($url, ['timeout' => 5, 'redirection' => 3]);
if (is_wp_error($resp)) {
$f[] = $this->finding('page_' . sanitize_key($label), 'bad', $label, $url, $resp->get_error_message());
continue;
}
$code = wp_remote_retrieve_response_code($resp);
$level = ($code >= 200 && $code < 400) ? 'ok' : 'bad';
$f[] = $this->finding('page_' . sanitize_key($label), $level, $label, 'HTTP ' . $code, $url);
}
// Mixed content quick check on homepage
if (parse_url($home, PHP_URL_SCHEME) === 'https') {
$body_resp = wp_remote_get($home, ['timeout' => 6]);
if (!is_wp_error($body_resp)) {
$body = (string) wp_remote_retrieve_body($body_resp);
preg_match_all('/(?:src|href)\s*=\s*["\']http:\/\/[^"\']+["\']/i', $body, $m);
$http_count = isset($m[0]) ? count($m[0]) : 0;
$f[] = $this->finding(
'mixed_content',
$http_count > 0 ? 'warn' : 'ok',
'Mixed content',
$http_count . ' http:// reference(s) on homepage',
$http_count ? 'Browsers will block or warn — replace with https:// or protocol-relative URLs.' : ''
);
}
}
return $f;
}
};