WP Manifestindependent plugin directory
manifest / editor / wp-gutenberg-a11y-enforcer

WP Gutenberg A11y Enforcer

Hooks block saving process to check accessibility compliance — server-side (content_save_pre), client-side (Gutenberg JS filter), and admin settings with validation log export.

by Omar Faruque Tuhin (Nadim) · github.com/nadimtuhin/wp-gutenberg-a11y-enforcer

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/nadimtuhin/wp-gutenberg-a11y-enforcer/archive/refs/heads/main.zip

From the readme

A WordPress plugin that enforces accessibility (a11y) rules on Gutenberg block content — both server-side (PHP, via a contentsavepre filter) and client-side (JavaScript, via the blocks.getSaveElement Gutenberg hook). Features | Layer | Mechanism | Effect | |-------|-----------|--------| | Backend (PHP) | contentsavepre filter | Strips non-compliant blocks before they are persisted to the database | | Frontend (JS) | blocks.getSaveElement Gutenberg filter | Injects a sentinel element that triggers block validation failure in the editor, preventing save | Accessibility rules enforced - core/image — must have a non-empty alt attribute (WCAG 2.1 SC 1.1.1). Additional rules can be added to Enforcer::validateBlock() (PHP) and getA11yViolations() (JS). Architecture Backend hook: contentsavepre Enforcer::filterContent() is registered on contentsavepre. When a post is saved: 1. WordPress passes the raw post content (serialised block HTML) through the filter. 2. parseblocks() splits the content into individual block objects. 3. Each block is evaluated by validateBlock(). 4. Blocks that fail validation are dropped; compliant blocks are re-serialised. 5. The cleaned content is returne

Read the full README on GitHub →