We built DEV3 AI Accessibility Checker & Fixer as a PHP plugin with a React admin app, a block editor sidebar and optional front-end helpers. There is no overlay and no compliance badge; every score screen says it covers automated checks only.
Key design decisions
- One rule engine, two inputs. A DOMDocument-based checker runs 20+ WCAG 2.2 rules on a whole rendered page or on one block's HTML. Content issues carry a block-path locator so they can be fixed; issues in theme markup get guidance only.
- Contrast from the real colour stack. Text and background colours are resolved from inline styles,
has-*-color classes, var:preset|color|* values and the theme palette, then walked up through parent blocks with alpha blending. Text over images or gradients is skipped rather than guessed.
- Deterministic contrast fixes. The fixer keeps the hue and saturation and searches lightness in 0.5% steps for the nearest colour that reaches 4.5:1 (3:1 for large text), or offers the nearest passing theme palette colour.
- Block-valid edits. Fixes change the target tag and the block's attributes together (for example
style.color.text or textColor), and leave every other byte of the post alone, so blocks stay valid in the editor.
- Draft, apply, undo. Each fix stores the post content before and after. Undo refuses with a 409 if the post changed since; a draft whose target changed becomes stale.
- An honest statement generator. The accessibility statement follows the W3C structure, pre-fills known limitations from open issues, and flags over-claims such as "fully compliant" unless a manual audit is confirmed.
Architecture
Site scans run as background jobs: each page is fetched as a logged-out visitor (same host only, signed request) and its content is also checked block by block, so issues are attributed to content or to the theme. The editor sidebar checks unsaved content live and applies fixes through block attributes, so normal editor undo works. The Google Gemini API (gemini-2.5-flash) drafts vision alt text from the image and nearby text, descriptive link text and accessible names; with AI off, rules-based fixes still work. Skip link, focus outline, link underlines and new-tab hints are optional helpers, off by default. The API client, jobs and settings come from a shared core used across DEV3's plugins.