Skip to main content

benecaster_episode_share_links

Filter Free

Filters the share links array for an episode before output in episode/share.php. Each entry is {label, url, class}. Replace the whole array to swap platforms; append to add a platform alongside the defaults.

Return the array. Cast with (array). It is keyed by platform slug (x, facebook, …), and each row is an array with label, url and class.

Output escaping differs per key and is worth knowing: url goes through esc_url() (a disallowed protocol silently becomes an empty attribute), label through esc_html() (markup becomes literal text), and class through esc_attr(). A row missing url or label emits an empty attribute rather than being skipped, so build rows completely.

Returning an empty array renders the share section with no links rather than removing it; remove the template part to drop it entirely.

Parameters

Name Type Default Description
$links array Share links array; each entry: {label: string, url: string, class: string}
$episode_id int ID of the episode
$show_id int ID of the show

Returns: array

Example

add_filter( 'benecaster_episode_share_links', function( $links, $episode_id, $show_id ) {
    // Add a Bluesky share link after the existing entries.
    $title      = urlencode( get_the_title( $episode_id ) );
    $permalink  = urlencode( get_permalink( $episode_id ) );
    $links[] = [
        'label' => 'Bluesky',
        'url'   => 'https://bsky.app/intent/compose?text=' . $title . '%20' . $permalink,
        'class' => 'bc-share-bluesky',
    ];
    return $links;
}, 10, 3 );

Affects

  • episode/share.php template part

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