Skip to main content

benecaster_player_output

Filter Free

Filters the rendered player HTML of the benecaster_player shortcode. Fires only when a player rendered. The locked state returns before this filter runs; change that message with benecaster_locked_content_message instead.

When the player rendered a video, the wrapper carries the benecaster-player--video class, which is the reliable way to tell the two apart. $atts['media'] holds the attribute as written, which is the preference asked for rather than what played.

Use to wrap the output in a custom container, inject additional markup around the player, or replace the output entirely. Return an empty string to suppress the shortcode completely. If you replace the markup, keep the .benecaster-player wrapper and its data-episode-id and data-show-id attributes, which the web play beacon counts.

Parameters

Name Type Default Description
$html string — Full rendered shortcode output
$episode_id int — ID of the episode
$atts array — Resolved shortcode attributes

Returns: string

Examples

Wrap player in branded container

add_filter( 'benecaster_player_output', function ( $html, $episode_id, $atts ) {
    if ( $html ) {
        $html = '<div class="my-player-wrap" data-episode="' . (int) $episode_id . '">' . $html . '</div>';
    }
    return $html;
}, 10, 3 );

Wrap in custom container div

add_filter( 'benecaster_player_output', function ( string $html, int $episode_id, array $atts ): string {
    return '<div class="my-player-wrapper">' . $html . '</div>';
}, 10, 3 );

Notes

Not called for the locked state, so a callback here never needs its own access check. A visitor shown a preview clip gets the audio player.

Affects

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