benecaster_episode_share_text
Filters the share message for each share platform after merge tags are resolved and before the text is URL-encoded into the share link. Fires once for each of twitter_x, facebook and linkedin that the shortcode renders. Use it to shorten, trim or localize the text X receives.
Only the twitter_x return value reaches a share. Facebook and LinkedIn accept the episode link alone and ignore prefilled text. X’s composer adds the episode URL itself, so leave it out of the text.
It does not fire for the Copy link button, which always copies the episode URL and nothing else. To find out whether a Copy link button rendered, check for a copy_link key in the $share_items that benecaster_episode_share_output receives. The Share Buttons Episode Page block does not apply this filter; it shares the episode title.
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 |
— | The share platform being rendered: twitter_x, facebook or linkedin |
Returns:
string
Examples
Cap X share text under 240 characters
add_filter( 'benecaster_episode_share_text', function( string $text, int $episode_id, int $show_id, string $platform_slug ): string {
// Only X uses the text, so leave the other platforms alone.
if ( 'twitter_x' === $platform_slug && mb_strlen( $text ) > 240 ) {
return mb_substr( $text, 0, 237 ) . '…';
}
return $text;
}, 10, 4 );
Notes
The shortcode's text attribute sets the starting text, before this filter runs.
Affects
- benecaster_episode_share shortcode
Need this built rather than just documented? See our services →