Files
wp-healthcheck/includes/steps/120-wrap-up.php
Steve Hanlon cf3007ec37 Phase 3 v2: all step automations + cross-cutting UI
Step automations (six more):
- Step 3 (Core): current vs latest WP version, db upgrade flag, auto-
  update policy, safe-update sequence reminder.
- Step 5 (Theme): parent/child detection, customisation warning when
  non-default theme without child, theme update available, inactive
  theme list.
- Step 6 (Visual): mShots screenshot URL, key-page HEAD checks (home,
  login, posts page, WC shop/cart/checkout), mixed-content scan.
- Step 7 (Performance): keyless PageSpeed Insights v5 API (mobile +
  desktop, cached 12h, skipped on .local), caching plugin detection,
  heavy-image scan (>500KB).
- Step 10 (Uptime): monitoring plugin detection (ManageWP, MainWP,
  Jetpack, WP Umbrella, UptimeRobot), www/non-www canonical check.
- Step 12 (Wrap-up): cross-step rollup — bad/warn counts, blocked
  steps, top examples for the technician's final glance.

Cross-cutting:
- Sticky step-index sidebar with status dots per step (the linear-
  stepper alternative that keeps the overview).
- 'Stop & escalate' summary card at top listing blocked steps with
  escalation guidance and notes.
- Previous-session snapshot stored on finish; diff banner on the next
  session shows new/resolved/changed counts.
- HTML report builder (printable, inline-styled). Download HTML,
  Download Markdown, Copy, and Email actions on the finish panel.
  Email uses wp_mail with text/html.

Smoke-tested on testsite: all 12 steps return findings (5/9/4 by level
on a fresh local install), admin page renders with all UI markers,
HTML report is 26KB, Markdown report is 13KB, prev-session diff banner
appears on second session.

Deferred:
- hc-5ix.27 self-hosted update channel — needs hosting infra.
- Full PDF report — would need vendoring Dompdf.
- Step 3 safe-mode update wizard — worth its own bead.
2026-06-11 16:13:15 +01:00

70 lines
3.1 KiB
PHP

<?php
if (!defined('ABSPATH')) exit;
return new class extends WPH_Step {
public function id(): string { return 'wrap_up'; }
public function title(): string { return 'Step 12 — Wrap Up and Document'; }
public function sub_items(): array {
return [
'Log everything done in the client record: versions before and after, any issues found, any fixes applied, anything flagged for follow-up',
'Note the date, time taken, and technician',
'If using ManageWP or WP Umbrella, generate the client report and review it before sending — make sure it accurately reflects what was done',
'Send the client report or file it according to your process',
'If anything was flagged that needs a separate quote or client decision, send that communication now rather than leaving it',
];
}
public function autocheck(array $session_state): array {
// Roll up all 'bad' and 'warn' findings from other steps into a wrap-up summary.
$bad = [];
$warn = [];
$blocked = [];
foreach (WPH_Steps::instance()->all() as $sid => $s) {
if ($sid === 'wrap_up') continue;
// Pull stored autocheck results from session data (we get session_state passed in).
$stored = $session_state['autocheck'][$sid] ?? null;
if ($stored && !empty($stored['findings'])) {
foreach ($stored['findings'] as $finding) {
$label = $s->title() . ' → ' . $finding['label'];
if ($finding['level'] === 'bad') $bad[] = $label . ' (' . $finding['value'] . ')';
if ($finding['level'] === 'warn') $warn[] = $label . ' (' . $finding['value'] . ')';
}
}
$step_state = $session_state['steps'][$sid] ?? null;
if (is_array($step_state) && ($step_state['status'] ?? '') === 'blocked') {
$blocked[] = $s->title();
}
}
$f = [];
$f[] = $this->finding(
'bad_count',
count($bad) > 0 ? 'bad' : 'ok',
'Critical findings',
(string) count($bad),
$bad ? implode(' · ', array_slice($bad, 0, 6)) . (count($bad) > 6 ? ' …' : '') : 'No bad-level findings across steps.'
);
$f[] = $this->finding(
'warn_count',
count($warn) > 0 ? 'warn' : 'ok',
'Warnings',
(string) count($warn),
$warn ? implode(' · ', array_slice($warn, 0, 8)) . (count($warn) > 8 ? ' …' : '') : ''
);
$f[] = $this->finding(
'blocked_steps',
count($blocked) > 0 ? 'bad' : 'ok',
'Blocked steps',
(string) count($blocked),
$blocked ? implode(', ', $blocked) : ''
);
$f[] = $this->finding(
'tip_copy',
'info',
'Tip',
'paste this into the client record',
'Click Copy to clipboard on the finish screen — the full Markdown report is also downloadable.'
);
return $f;
}
};