Skip to main content

benecaster_episode_share_text

Filter Free

Filters the share message text for each platform after merge tags are resolved but before the text is URL-encoded into the platform share URL. Fires once per platform per shortcode or block render. Use to set different message lengths per platform, strip specific characters, or localize the text.

Built-in platform slugs: twitter, facebook, linkedin, threads, email, copy. For the twitter slug, return text only — the episode URL is appended as a separate parameter by the renderer. The copy slug fires for parity but the filter return value is not used in the URL (the episode permalink is always copied as-is). Custom platform slugs added via the platforms shortcode attribute are passed through unchanged.

Parameters

Name Type Default Description
$text string Share message with merge tags already resolved
$episode_id int ID of the episode being shared
$show_id int ID of the show
$platform_slug string Platform being rendered: twitter, facebook, linkedin, threads, email, copy

Returns: string

Examples

Truncate Twitter share text to 200 characters

add_filter( 'benecaster_episode_share_text', function( $text, $episode_id, $show_id, $platform_slug ) {
    // Shorten the share text for Twitter; leave other platforms as-is.
    if ( 'twitter' === $platform_slug && mb_strlen( $text ) > 200 ) {
        return mb_substr( $text, 0, 197 ) . '…';
    }
    return $text;
}, 10, 4 );

Cap Twitter/X text under 240 characters

add_filter( 'benecaster_episode_share_text', function( string $text, int $episode_id, int $show_id, string $platform_slug ): string {
    if ( $platform_slug === 'twitter_x' && mb_strlen( $text ) > 240 ) {
        $text = mb_substr( $text, 0, 237 ) . '…';
    }
    return $text;
}, 10, 4 );

Notes

For the copy platform slug the filter return value is not used — the episode permalink is always copied as-is. The filter fires for the copy slug for parity with other platforms.

Affects

  • [benecaster_episode_share](/shortcodes/benecaster-episode-share/) shortcode
  • Share Buttons Episode Page block