Files
wp-healthcheck/includes/class-wph-step.php
Steve Hanlon 8de7cad0de Phase 1 MVP: drop-in step registry + session + Markdown report
Plugin skeleton, drop-in step registry, option-backed session, single-page
checklist UI, downloadable Markdown report. Steps live as one file each
under includes/steps/ — adding/removing one is a single file change.
Step IDs are stable strings so renaming files preserves session data.

Architecture (hc-5ix.3): WPH_Steps singleton globs includes/steps/*.php,
natsort-orders by filename, requires each file (which returns a WPH_Step
instance), then applies a 'wph_steps' filter so installs can drop steps.

Session (hc-5ix.4): option-backed (per decision — plugin is installed
per-engagement, so DB-resident history would be lost on uninstall).
Single in-progress session per site; finished sessions render a report
that the user downloads/copies.

Recovery bootstrap (hc-5ix.1): detects whether wp-site-recovery is
installed + active, surfaces state on the start panel and in every
active session. Manual install for now; private update channel deferred
to hc-5ix.27.

Smoke-tested on testsite: registry discovery (13 steps in correct order),
start → update_step → progress count → finish → 8KB Markdown report →
discard cycle.
2026-06-11 15:49:29 +01:00

46 lines
1.7 KiB
PHP

<?php
if (!defined('ABSPATH')) exit;
/**
* Base class for a healthcheck step.
*
* Each step lives in its own file under includes/steps/ with a numeric prefix
* (e.g. 10-backup.php). The file returns an instance of a subclass of WPH_Step.
* Drop a new file in that directory and it shows up; delete a file and it
* disappears. The numeric prefix controls order so re-ordering is a rename.
*
* Stable string IDs (returned by id()) are stored in the session, so renaming
* the file does NOT lose data as long as id() stays the same.
*/
abstract class WPH_Step {
/** Stable identifier (lowercase slug). NEVER change once shipped. */
abstract public function id(): string;
/** Human-readable title shown in the UI and report. */
abstract public function title(): string;
/** Intro paragraph shown under the title (plain text or simple inline HTML). */
public function blurb(): string { return ''; }
/** Sub-items the technician should tick through (plain strings). */
public function sub_items(): array { return []; }
/** "Watch out for" callouts (plain strings). */
public function watch_outs(): array { return []; }
/**
* If this step has a stop/escalate condition (e.g. backup failed → stop),
* return the guidance string. Rendered as a banner when status=blocked.
*/
public function escalation(): ?string { return null; }
/**
* Phase 3 hook — return structured findings (php version, plugin update
* intel, etc.) for the technician to verify. Phase 1 returns nothing.
*
* @return array<string,mixed>
*/
public function autocheck(array $session_state): array { return []; }
}