Skip to main content

benecaster_get_episode_references_html()

Episode Free
benecaster_get_episode_references_html( int $episode_id, int $show_id, int $user_id, string $context = 'email' ): string

Returns an episode’s references as HTML for one email recipient: the same block each feed item carries at the end of its show notes, so a listener sees the same list in their podcast app and in their inbox. Use it to put the references in an episode email your add-on sends.

The references pass through benecaster_episode_references with $context, are built into the block, and pass through benecaster_episode_references_html. The block uses only <p>, <ul>, <li> and <a href>.

Parameters

Name Type Default Required Description
episode_id int — Yes The episode (post) ID.
show_id int — Yes The episode's own show. Any other show answers ''.
user_id int — Yes The recipient's WordPress user ID, never the current user's: an email is often rendered in a cron run, where the current user is nobody. 0 is a recipient with no account, who gets what a signed-out visitor gets.
context string 'email' No email or rss, passed to the filters. Any other value is treated as email.

Return Value

Type: string

The references block as HTML, or '' when the recipient cannot access the episode, the episode has no references, a filter removed them all, or the episode is missing or not in $show_id. Never a heading on its own.

Example

$references = benecaster_get_episode_references_html( $episode_id, $show_id, $recipient_user_id );
if ( '' !== $references ) {
    $body .= $references;
}

Hooks Fired

Notes

It returns nothing for a recipient who cannot access the episode, the same rule the episode page follows. An email sent at publish can reach subscribers the episode has not opened to yet, and they do not get the links the page withholds. The check is benecaster_user_can_access_episode() for the recipient. There is no license check.

Pass the recipient's user ID, not get_current_user_id().

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