benecaster_show_episode_download
Controls whether the episode page shows its “Download episode” link to the current visitor. The link appears beneath the player when the episode’s download setting is on and the visitor can play the episode. Show Settings → Feeds → Download link has two checkboxes, both off by default: Show a download link on episode pages decides it for every episode with an audio file, and Show a download link on video-only episodes decides it for an episode with a video file and no audio file. $show_download starts at exactly that: the episode’s setting AND the visitor’s access. The filter always fires, so a callback sees the default either way.
The filter can only hide the link. Benecaster combines your return value with the starting value, so returning true for a visitor who cannot play the episode, or on a show where the setting is off, shows nothing. This differs from benecaster_show_episode_player, which a preview add-on uses to open the player: a download link opened to a locked visitor would hand them the full file, and a preview clip that opens the player does not open the download link.
The link points at the same file the player uses, which sits at your podcast host. For an episode with an audio file that is the viewer’s tier variant, from benecaster_get_episode_audio_url(), so after benecaster_episode_audio_url; an episode with both files links the audio. For a video-only episode it is the video URL, after benecaster_episode_video_url. An episode with only an embed code has no file and never gets a link. The link protects nothing the player does not: anyone who can play the episode can reach the file, and a copied URL works for whoever holds it.
The link renders in the episode/download template part, which a theme can override (see Template Overrides). Benecaster’s single.php decides whether to include the part and the part does not re-check access, so a theme that overrides single.php must call \Benecaster\Episode\EpisodePageLinkGate::shows_download() itself before including it.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$show_download |
bool |
— | Whether Benecaster would show the link (the episode's setting on, the video-only one for an episode whose only file is a video, and the visitor can play the episode) |
$episode_id |
int |
— | ID of the episode |
$user_id |
int|null |
— | WordPress user ID; null if not logged in |
$user_tier |
string|null |
— | Current tier slug; null if user has no active tier |
Returns:
bool
Example
// Offer downloads to paying subscribers only, not to visitors of public episodes.
add_filter( 'benecaster_show_episode_download', function ( bool $show, int $episode_id, ?int $user_id, ?string $user_tier ): bool {
return $show && null !== $user_tier;
}, 10, 4 );
Notes
Free. The filter fires in the free product's episode template, beside its free siblings.
Need this built rather than just documented? See our services →