benecaster_get_plan_label()
Returns the human-readable display name for a plan slug.
Access: Free (can be called from any context)
Since: feature/license-panel-info
Signature
benecaster_get_plan_label( string $slug ): string
Parameters
| Parameter | Type | Description |
|---|---|---|
$slug |
string |
A plan slug, e.g. 'growth', 'multi-show', 'studio' |
Return Value
The human-readable name for the plan, sourced from the plans array in the cached benecaster_pricing_data transient.
If the transient is missing, stale, or does not contain the given slug, the function falls back to titlecasing the slug: hyphens and underscores are replaced with spaces and ucwords() is applied. For example, 'multi-show' → 'Multi Show' when the catalog is unavailable.
Usage
// Display the current plan name in a custom settings panel
$slug = benecaster_get_license_plan();
$label = $slug ? benecaster_get_plan_label( $slug ) : 'Unlicensed';
printf( '<p>Current plan: <strong>%s</strong></p>', esc_html( $label ) );
// Include the plan label in an admin email notification
add_action( 'benecaster_license_validated', function(): void {
$slug = benecaster_get_license_plan();
if ( ! $slug || ! benecaster_is_premium() ) {
return;
}
$label = benecaster_get_plan_label( $slug );
// use $label in notification content
} );
Notes
- This function always returns a non-empty string. When the slug is unrecognised and the catalog is unavailable, the return value is the titlecased slug rather than an empty string or
null. - The catalog is cached in the
benecaster_pricing_datatransient and refreshed alongside license validation. On a cold install before the first validation run, the transient may be absent and the fallback will apply. - Use
benecaster_get_license_plan()to obtain the current site’s plan slug before passing it to this function.
Related
benecaster_get_license_plan()— returns the current plan slugbenecaster_get_addon_label()— same pattern for add-on slugs