benecaster_get_show_benchmarks()
benecaster_get_show_benchmarks( int $show_id ): array
Returns the platform benchmarks for a show: how comparable shows on the same Benecaster plan are doing, in exactly the shape Benecaster’s own Benchmarks panel receives.
Benchmarks are per license. A show reads the cohort of its own license’s plan, and a show that is not connected to a license gets none.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
show_id |
int |
— | Yes | WordPress post ID of the show. |
Return Value
Type:
array
available (bool), calculated_at, sample_size, minimum_sample_not_met and benchmarks — the same shape Benecaster's Benchmarks panel receives. Under benchmarks, membership_plugins and addons_enabled are share distributions with label, sample, shares and names; a null sample or shares means not enough data yet, not none. available is false when there is nothing usable.
Example
$benchmarks = benecaster_get_show_benchmarks( $show_id );
if ( ! $benchmarks['available'] ) {
return; // Hide the comparison rather than draw zeros.
}
printf(
esc_html__( 'Compared with %d shows on the same plan', 'my-addon' ),
(int) $benchmarks['sample_size']
);
Notes
It reads the cached copy only and never contacts Benecaster's servers, so it is safe to call on any request. The cache is filled by a daily scheduled job and whenever the Benecaster Dashboard is opened.
When available is false, show nothing. That happens when telemetry is not shared, nothing has been fetched yet, the server could not be reached, or the show is not connected. Drawing zeros would tell the podcaster their show compares badly when there is simply no comparison.
There is no capability check.
Need this built rather than just documented? See our services →