YUI Preview Token solves the authentication problem in decoupled (headless) WordPress architectures. Application Passwords are a great built-in WordPress feature for this purpose, but they require managing long-lived secrets on the frontend side. This plugin instead issues per-post tokens that grant read access for a configurable period — no persistent secrets required.
The frontend (Astro, Next.js, Nuxt, etc.) receives a preview URL and can fetch the draft content directly via the REST API.
/wp-json/yui-preview-token/v1/preview?token=… to retrieve the draft content.Token Management
bin2hex(random_bytes(32)) (256-bit CSPRNG). The lookup key stored in wp_options is the SHA-256 hash of the raw token, not the token itself — so a database leak does not expose usable tokens directly.Editor Integration
Admin Settings
https://*.example.com).Issued Tokens List
Security
Referrer-Policy: no-referrer prevents token leakage via referer headers.draft, pending, and future post statuses.Audit Logging
WP_DEBUG_LOG by default; point to a dedicated file with PVT_LOG_FILE.Internationalisation
Filter
yuipt_preview_response_data — Modify the REST API response data before it is sent.Actions
yuipt_token_issued( int $post_id, int $user_id ) — Fires after a token is issued.yuipt_token_used( int $post_id, int $user_id ) — Fires when a token is used successfully.yuipt_invalid_token( string $ip ) — Fires on an invalid/expired token attempt.yuipt_rate_limit_exceeded( string $ip, string $endpoint ) — Fires when rate limit is hit.yuipt_capability_denied( int $user_id, int $post_id ) — Fires on a capability denial.Constants (wp-config.php)
PVT_SKIP_HTTPS_CHECK — Set to true to disable the HTTPS requirement (development only).PVT_LOG_FILE — Absolute path to a dedicated audit log file.This plugin is designed for headless WordPress setups where a decoupled frontend (e.g. Astro, Next.js, Nuxt, SvelteKit) renders content from the WordPress REST API. It gives content editors a simple, secure way to share draft previews with stakeholders without granting them WordPress accounts or exposing long-lived API credentials.