Override whether a specific episode’s downloads get counted
Resolving whether an episode’s enclosure URL gets substituted for a redirect-proxy URL (and therefore counted) happens in two steps: the episode’s own three-state override (_benecaster_episode_download_tracking) wins when explicitly set to force-on or force-off; otherwise it falls back to the show’s _benecaster_show_download_tracking_enabled default. This filter runs after that resolution, on the final boolean, before the decision is applied — the one place an add-on can override the outcome without touching either the show or episode setting itself.
The filter receives only the resolved boolean and the episode ID — it does not see which layer (episode override vs. show default) produced that value, and it cannot distinguish “the show turned this off” from “the episode force-off’d it.” An add-on needing that distinction should read EpisodeMeta::get_download_tracking() / ShowMeta::has_download_tracking_enabled() directly rather than trying to infer it from this filter alone.
Code
<?php
add_filter( 'benecaster_episode_download_tracking_enabled', function ( bool $enabled, int $episode_id ): bool {
// Never track downloads for episodes tagged "sponsor-preview" —
// regardless of what the show or episode setting says.
if ( has_term( 'sponsor-preview', 'episode_tag', $episode_id ) ) {
return false;
}
return $enabled;
}, 10, 2 );
Hooks Used
Need this built rather than just documented? See our services →