Skip to main content

benecaster_addon_active_show_ids()

Utilities Free
benecaster_addon_active_show_ids( string $addon_slug ): int[]

The list counterpart to benecaster_addon_is_active(). Each published show is asked the same per-show question, so a show is listed only when its license grants the add-on and the add-on is switched on for it. A site-wide add-on (registered with scope: 'site'; see benecaster_register_addon()) needs no switch, only the grant.

Use it for a page or query that spans shows: a public archive across the site, a directory, a cross-show report. When you have one show in hand, ask benecaster_addon_is_active() instead. Recipe: List content only from the shows where your add-on is on.

Parameters

Name Type Default Required Description
addon_slug string — Yes Your add-on's entitlement slug, e.g. 'benecaster-addon-guest-manager'. The short form ('guest-manager') works too.

Return Value

Type: int[]

The IDs of the published shows the add-on is active for, or an empty array.

Example

// Only episodes from shows where my add-on is on.
$show_ids = benecaster_addon_active_show_ids( 'benecaster-addon-my-addon' );

$episodes = [] === $show_ids ? [] : get_posts( [
    'post_type'       => 'benecaster_episode',
    'post_status'     => 'publish',
    'post_parent__in' => $show_ids,
] );

Notes

An empty array for every add-on once the license server has been unreachable for 30 days, exactly as benecaster_addon_is_active() answers false then. Also empty for an empty slug, and for an add-on that is on for no show. A show with no license connection is granted nothing, and a draft or private show is never listed.

Don't pass an empty result to post_parent__in. WP_Query ignores an empty array there and matches posts from every show, so check for [] first, as in the example.

Need this built rather than just documented? See our services →