Inject Podcasting 2.0 Episode Tags from an Add-on
The episode-level half of Podcasting 2.0: transcripts, soundbites, season numbers, per-episode artwork, and credits. Benecaster fills these in from the episode’s own settings, and benecaster_feed_podcast_episode_tags hands the set to an add-on before it is written out, to add to, change, or remove.
This is the seam Benecaster’s own add-ons use, which is the best argument for it being the right place for yours: the Transcription Service attaches transcripts here, Guest Manager attaches credits, and Chapter Markers attaches chapters. They compose rather than collide, because each adds its own entry instead of replacing the set.
Code
<?php
add_filter( 'benecaster_feed_podcast_episode_tags', function ( array $tags, int $episode_id, int $show_id ): array {
// Inject a soundbite from an external clipping service.
$highlight = get_post_meta( $episode_id, '_my_addon_highlight', true );
if ( is_array( $highlight ) && isset( $highlight['start'], $highlight['duration'] ) ) {
$tags['soundbites'][] = [
'start_time' => (float) $highlight['start'],
'duration' => (float) $highlight['duration'],
'title' => (string) ( $highlight['title'] ?? '' ),
];
}
// Append an editor credit from show meta.
$editor_name = (string) get_post_meta( $show_id, '_my_addon_editor_name', true );
if ( $editor_name !== '' ) {
$tags['feed_credits'][] = [
'role' => 'editor',
'name' => $editor_name,
'url' => (string) get_post_meta( $show_id, '_my_addon_editor_url', true ),
];
}
return $tags;
}, 10, 3 );
Hooks Used
Need this built rather than just documented? See our services →