benecaster_sponsor_manager_episode_sponsors
Filters what benecaster_sponsor_manager_get_episode_sponsors() returns: an episode’s sponsors in the episode’s order, each [ 'sponsor_id' => int, 'company' => string, 'positions' => string[], 'archived' => bool, 'campaign' => array|null ]. It runs only when Sponsor Manager is on for the episode’s show.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$sponsors |
array |
— | The episode's sponsors as the function is about to return them |
$episode_id |
int |
— | The episode |
$show_id |
int |
— | The episode's show |
Returns:
array
Example
// Leave archived sponsors out of what other add-ons read.
add_filter( 'benecaster_sponsor_manager_episode_sponsors', function ( array $sponsors, int $episode_id, int $show_id ): array {
return array_values( array_filter( $sponsors, fn( array $s ): bool => ! $s['archived'] ) );
}, 10, 3 );
Notes
A return that is not an array is ignored. Never add a sponsor's contact or rate: what this function returns can reach public pages and other add-ons' screens. Walkthrough: Read an episode's sponsors, or a sponsor's episodes, from another add-on.
Need this built rather than just documented? See our services →