REST API
Reign has a small REST namespace, /wp-json/reign/v1/. It covers one thing core WordPress does not provide for a theme: fresh per-user nonces on cached pages. It works on a plain WordPress install, with no BuddyPress or WooCommerce needed.
Routes are registered on rest_api_init from inc/REST/Component.php.
Cache-safe nonce refresh
Section titled “Cache-safe nonce refresh”GET /wp-json/reign/v1/nonces
Section titled “GET /wp-json/reign/v1/nonces”Logged-in only. Returns the per-user nonces: reign_friendship_nonce, reign_notification_nonce, reign_message_nonce and a generic rest_nonce. Reign prints them in the footer for logged-in page views. Use this route for code on a page served from a full-page cache. There, printed nonces would be stale or belong to someone else. The response sends Cache-Control: no-store, private.
The request needs the logged-in cookie and a REST nonce. Reign prints one in window.reignApiConfig.rest_nonce.
fetch( '/wp-json/reign/v1/nonces', { credentials: 'same-origin', headers: { 'X-WP-Nonce': window.reignApiConfig.rest_nonce },} ) .then( ( response ) => response.json() ) .then( ( nonces ) => console.log( nonces.reign_message_nonce ) );The reply has four keys: reign_friendship_nonce, reign_notification_nonce, reign_message_nonce and rest_nonce.
Detect Reign from code
Section titled “Detect Reign from code”In PHP, check the parent theme and ask Reign which supported plugins are active. Both work with a child theme active.
if ( 'reign-theme' === get_template() && function_exists( 'reign_get_integrations' ) ) { $integrations = reign_get_integrations(); // Keyed by plugin slug: array( 'label' => ..., 'active' => true|false ). if ( $integrations['buddypress']['active'] ) { // BuddyPress is active on a Reign site. }}JavaScript client
Section titled “JavaScript client”window.reignApi (script handle reign-api) wraps the route and returns a
Promise: reignApi.refreshNonces(). Reign registers the script but does not
load it on every page: add reign-api to your own script’s dependencies to
use it. wp.apiFetch( { path: '/reign/v1/nonces' } ) works too.
Load your own script with reign-api as a dependency, from the child theme’s functions.php.
add_action( 'wp_enqueue_scripts', function () { wp_enqueue_script( 'my-site-js', get_stylesheet_directory_uri() . '/js/my-site.js', array( 'reign-api' ), '1.0.0', true );} );Then, in js/my-site.js, refresh the nonces before an AJAX call on a cached page.
reignApi.refreshNonces().then( ( nonces ) => { // nonces.reign_message_nonce is current for the logged-in member.} );Sign-in and registration are not REST routes
Section titled “Sign-in and registration are not REST routes”Sign-in goes through WordPress’s own wp_signon(). Reign’s login popup posts to admin-ajax.php. It hands over to wp-login.php when a security plugin takes over the request. Lockouts, captcha and two-factor then apply as they do on the login page. Registration happens on the site’s registration page
(WordPress or BuddyPress). For programmatic login from another application,
use WordPress core’s Application Passwords.
The signup, magic-link and colour-preference routes that earlier versions
registered were removed in 8.1.0, and the public /reign/v1/info route in
8.1.1; nothing in Reign called them, and /info showed any visitor the exact
theme version. To detect Reign, use the PHP check above. The light
and dark switch keeps each visitor’s choice in their browser.
What this namespace does not cover
Section titled “What this namespace does not cover”It has no routes for posts, pages or BuddyPress data. WordPress core’s
/wp/v2/ namespace and the BuddyPress REST API already cover that, and
Reign does not duplicate them.

