AdminDieHandler
Corex\Admin\Errors\AdminDieHandler · class · Core layer
Makes every human-facing admin refusal a CoreX page (spec 083, FR-001). ## Why a wp_die_handler filter is the right instrument here, and was not before Spec 079 declined to install one, and DECISIONS #174 records that. Its concern was real but different: the access-request form was posting a browser at a REST route, and the tempting fix was content negotiation — one endpoint answering HTML or JSON depending on who asked. That would have silently changed what every API consumer received. Nothing here reopens it; no route changes behaviour, and nothing inspects Accept. What the narrower reading cost was measured before this class was written: nine of eleven admin addresses still rendered WordPress’s white box to a real subscriber, including CoreX’s own Careers screen, because AccessDeniedGate can only match admin.php?page=corex-* (specs/083-admin-error-surface/evidence/before/refusal-matrix.md). ## The machine boundary is core’s, not ours wp_die() chooses its handler by request type before any filter runs (wp-includes/functions.php:3791-3849): Ajax, JSON/REST, JSONP, XML-RPC and XML/feeds each reach their own filter, and only the final else reaches wp_die_handler. Filtering that one alone is therefore not a promise to be careful — it is a branch a machine caller cannot arrive on. The guards in {@see shouldHandle()} are a second fence, not the first.
Public API
Section titled “Public API”__construct(AdminErrorClassifier $classifier, AdminErrorPresenter $presenter)
Section titled “__construct(AdminErrorClassifier $classifier, AdminErrorPresenter $presenter)”register(): void
Section titled “register(): void”noteDenial(): void
Section titled “noteDenial(): void”noteNonceResult(string|int $action, mixed $result): void
Section titled “noteNonceResult(string|int $action, mixed $result): void”Record a failed nonce check, so the refusal that follows is described as an expired link rather than as a missing capability. log-out is deliberately excluded. wp_nonce_ays('log-out') reaches wp_die() at 403 like any refusal, but it is a confirmation prompt — “Do you really want to log out?” — and the link it offers is the one that completes the action. Presenting it as an error would describe a normal, deliberate step as a failure and drop the only control on the page.