Skip to main content

benecaster_is_premium()

Returns true when the site has an active paid Benecaster license.

Access: Free (can be called from any context)
Since: Batch 2


Signature

benecaster_is_premium(): bool

Return Value

true when the license status is 'active' or 'grace_period' on any paid plan. false when the license status is 'none', 'invalid', 'suspended', 'cancelled', or 'expired', or when the 'launch' plan (free tier) is active.

Grace period behavior: benecaster_is_premium() returns true during a grace period — the license has lapsed but existing premium functionality degrades gracefully rather than immediately restricting. Use this function as the gate for add-on feature availability; the core plugin handles the degradation internally.


Usage

// Gate a premium add-on feature
if ( benecaster_is_premium() ) {
    // Register premium-only REST endpoint
    register_rest_route( 'my-addon/v1', '/premium-feature', [
        'methods'             => 'GET',
        'callback'            => [ $this, 'handle_premium_feature' ],
        'permission_callback' => '__return_true',
    ] );
}
// Show an upgrade notice when a feature requires premium
add_shortcode( 'my_addon_shortcode', function( $atts ): string {
    if ( ! benecaster_is_premium() ) {
        return '<p>This feature requires a paid Benecaster plan.</p>';
    }
    return my_addon_render_output( $atts );
} );

Notes

  • This function reads from the locally cached benecaster_license_status option — it does not make an HTTP call to the license server. It is safe to call on every request.
  • For checking a specific plan, use benecaster_get_license_plan().
  • For checking an add-on, use benecaster_addon_is_active().
  • Do not check benecaster_license_status directly from add-on code — use this function. The internal status values may evolve; this function is the stable contract.

  • benecaster_get_license_plan() — returns the current plan slug
  • benecaster_addon_is_active() — checks whether a specific add-on is licensed and active