Email delivery test step + step-form extension point

Demonstrates the drop-in pattern: adding a step with a form is a single
new file under includes/steps/, plus one small extension to the base
abstraction.

WPH_Step gains:
- render_extra($session_state) — emit extra HTML inside the step card
- handle_action($name, $input) — handle a step-specific POST and
  return a finding to record

New generic admin-post handler wph_step_action routes form submissions
to the matching step's handle_action() with nonce verification.

The email step (includes/steps/115-email.php):
- Detects 7 known SMTP plugins, surfaces default From address
- Renders a To: input prefilled with the current admin's email
- Sends via wp_mail() with wp_mail_failed capture so failures show the
  underlying error
- Records the outcome as a 'last_send' finding so it appears on the
  step card, in the summary, and in the downloadable report
This commit is contained in:
2026-06-11 18:45:47 +01:00
parent cf3007ec37
commit 0052005de1
4 changed files with 182 additions and 0 deletions

View File

@@ -55,4 +55,21 @@ abstract class WPH_Step {
$r = new ReflectionMethod($this, 'autocheck');
return $r->getDeclaringClass()->getName() !== WPH_Step::class;
}
/**
* Optional: render extra UI inside this step's card (forms, inputs, etc.).
* Default: nothing. Override when the step needs interactive controls
* beyond the standard status + notes pattern.
*/
public function render_extra(array $session_state): void {}
/**
* Optional: handle a step-specific POST (submitted from a form rendered by
* render_extra). Return a finding to append to the autocheck list, or null
* to do nothing.
*
* @param string $action_name name from the form's step_action field
* @param array<string,mixed>$input $_POST contents (sanitised by caller)
*/
public function handle_action(string $action_name, array $input): ?array { return null; }
}