Check whether a Benecaster add-on is available for a show
Use this when your code extends one of Benecaster’s add-ons — adding a section to the Analytics Dashboard’s digest, contributing rows to a Sponsor Manager export, reading transcripts the Transcription Service produced. You need to know whether that add-on is actually available on the show in front of you, so you can extend it when it is and stay out of the way when it is not.
⚠ This does not gate your own plugin. benecaster_addon_is_active() answers only about add-ons in Benecaster’s own catalogue — it compares against the entitlement list the licence server publishes, so a slug that is not one of theirs can never match and will always return false. If you sell your own plugin, license it your own way; use this to detect theirs.
The question has two halves, and one grant can give three answers. An add-on is available on a show when the licence grants it and the podcaster has left it switched on for that show. A Multi-Show customer can run the same add-on on shows A and B and switch it off for C. So code that resolves the question once and caches the answer gets show C wrong for the rest of the request.
The shape that follows: register unconditionally at boot, check at the point of use, where a show is actually in hand.
⚠⚠ Do not substitute benecaster_addon_is_active_for_any_show() for the per-show call to save a lookup. “Some show on this install has it” is not an answer to “may this show use it”. On a site running two shows on two different licences, that substitution shows one customer’s paid feature to another customer’s show.
The show context is a show post ID or the show’s _benecaster_show_uuid — both resolve identically, so pass whichever you already hold rather than looking the other one up.
Code
<?php
add_action( 'benecaster_boot', function ( \Benecaster\Container $container ): void {
// Nothing here knows which show is being rendered yet, so this is the
// one place the install-wide question is the right one: is it worth
// wiring up at all on this install?
if ( ! benecaster_addon_is_active_for_any_show( 'analytics-dashboard' ) ) {
return;
}
$container->make( \MyPlugin\DigestSection::class )->register();
} );
// ...and check per show, where the show is known.
add_filter( 'benecaster_analytics_digest_sections', function ( array $sections, string $type, int $show_id, array $data ): array {
if ( ! benecaster_addon_is_active( 'analytics-dashboard', $show_id ) ) {
return $sections;
}
$sections[] = my_plugin_build_section( $show_id, $data );
return $sections;
}, 10, 4 );