benecasterAdmin Localized Data Reference
The Benecaster React admin SPA receives its boot data via wp_localize_script under the benecasterAdmin global. This reference documents every property on that object.
Shape
interface BenecasterAdmin {
apiUrl: string;
nonce: string;
adminUrl: string;
pluginVersion: string;
license: LicenseStatus | null;
pricing: PricingData | null;
staging: StagingContext;
currentUser: {
id: number;
displayName: string;
capabilities: Record<string, boolean>;
};
}
Properties
apiUrl
Base URL for the REST API. Example: "https://yoursite.com/wp-json/benecaster/v1/". Always has a trailing slash. Use this rather than constructing the URL manually — it handles subdirectory installs and custom REST namespaces.
nonce (WP REST nonce)
A wp_rest nonce scoped to the current admin session. Send as the X-WP-Nonce header on all authenticated requests. The React app refreshes the nonce every 12 hours in the background.
adminUrl
WordPress admin base URL, e.g. "https://yoursite.com/wp-admin/". Used to construct links to non-Benecaster admin pages (media library, user editor, etc.).
pluginVersion
Installed plugin version string, e.g. "1.4.2". Useful for conditional feature flags in add-on React code.
license
Current license status as returned by GET /license. null when this site is not connected to a Benecaster plan. The React admin uses this to render the upgrade prompts, tier usage bars, and the add-on license badges. Full shape: see GET /license in the REST API reference.
pricing
Current pricing data from GET https://benecaster.com/wp-json/benecaster-license/v1/pricing, cached as the benecaster_pricing_data transient. null when the transient is empty. The React admin reads plan limits and prices from this object — do not hardcode any plan limits.
staging
Context about the current staging environment state. Always present (never null), even on production domains.
interface StagingContext {
isStaging: boolean; // true when BENECASTER_STAGING constant is defined
cap: number | null; // staging subscriber cap; null for unlimited plans
}
isStaging drives the staging banner in the React admin shell, the per-row staging status indicators in the Subscribers screen, and the TokenManager::validate() branch that gates feed access to staging-active subscribers only. It is false on production domains and does not change during a session.
cap is the effective staging subscriber cap as read from the license response. null for Pro, Multi-Show, and Studio (unlimited plans). The staging swap modal uses cap to determine when the set is full and offer the swap UI.
currentUser
Minimal current-user data for capability-gating the admin UI. capabilities is a flat map of capability names to booleans — only capabilities relevant to Benecaster are included (e.g. manage_benecaster, manage_options).
Extending the Payload
Add-ons can append properties via the benecaster_admin_localized_data filter:
add_filter( 'benecaster_admin_localized_data', function ( array $data ): array {
$data['myAddon'] = [
'apiKey' => get_option( 'my_addon_api_key_set' ) ? true : false,
'version' => MY_ADDON_VERSION,
];
return $data;
} );
Keep the payload lean — it is inlined into every admin page load. For large datasets, load them lazily via REST API requests from the React components that need them.
See Also
Need this built rather than just documented? See our services →
Last updated