v1.2.0 — headless REST endpoint
Adds a read-only REST endpoint so a headless front end can serve the same FAQ content, and the same structured data, as the WordPress page.
New
GET /wp-json/answer-ready/v1/faqs/<post_id>
Returns a post's FAQ pairs plus the FAQPage JSON-LD that post publishes. Public, read-only, cached in a transient keyed by the post's modified time, and sent with Cache-Control: public, max-age=300, s-maxage=3600. Drafts, private, password-protected and non-public post types all return the same 404.
Changed
- The normaliser, the
wp_kses()allowlist and the schema builder moved intoincludes/faq-data.php. The block's render callback and the endpoint both call it, so the JSON-LD on the page and the JSON from the API are the same graph by construction. render.phpis 31 lines shorter and holds no schema logic of its own.
Added
- A PHPUnit suite that needs no WordPress install —
composer install && composer test. examples/headless-nextjs/— a Next.js App Router page consuming the endpoint.
The block's behaviour on the page is unchanged: same editor UI, same <details>/<summary> accordion, same JSON-LD output.
Requirements: WordPress 6.5+, PHP 8.0+.