benecaster_episode_share_output
Filters the final HTML output of [benecaster_episode_share]. Use it to change the button markup, wrap the output in a custom container, or add share targets after the standard set. The Share Buttons Episode Page block does not apply this filter.
$share_items is keyed by platform slug and holds only the buttons that rendered. Each share platform’s item has type link, plus href, label and platform. The Copy link item, keyed copy_link, has type copy, plus url and label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$html |
string |
— | Rendered HTML output |
$share_items |
array |
— | The buttons that rendered, keyed by platform slug |
$atts |
array |
— | Resolved shortcode attributes |
Returns:
string
Examples
Wrap output with platform count attribute
add_filter( 'benecaster_episode_share_output', function( string $html, array $share_items, array $atts ): string {
return '<div class="episode-share-block" data-platforms="' . count( $share_items ) . '">' . $html . '</div>';
}, 10, 3 );
Add a hint only when a Copy link button rendered
add_filter( 'benecaster_episode_share_output', function( string $html, array $share_items, array $atts ): string {
if ( isset( $share_items['copy_link'] ) ) {
$html .= '<p class="share-hint">' . esc_html__( 'Copy the link to share it anywhere.', 'my-theme' ) . '</p>';
}
return $html;
}, 10, 3 );
Notes
To modify the share message text before it is encoded into platform URLs, use benecaster_episode_share_text instead.
Affects
- benecaster_episode_share shortcode
Need this built rather than just documented? See our services →