Skip to main content

benecaster_timestamp_output

Filter Free

Filters the final rendered HTML of the benecaster_timestamp shortcode before it is returned. The shortcode is inserted by the TipTap editor’s # trigger and renders as a clickable element that seeks the nearest Benecaster player to the specified number of seconds when clicked. Use this filter to customize the rendered element — for example, to apply a custom button style, add data attributes, or add a tooltip — without changing the editor behavior.

The $time_seconds parameter is always in seconds. The display label (such as 1:23 or 01:23:45) is part of $html — modify $html to change the label. Return an empty string to suppress rendering entirely; no fallback label is output.

Parameters

Name Type Default Description
$html string Rendered timecode anchor HTML
$time_seconds int Timecode in seconds
$atts array Resolved shortcode attributes including time, episode_id, and label

Returns: string

Examples

Replace with custom player-trigger button

add_filter( 'benecaster_timestamp_output', function( $html, $time_seconds, $atts ) {
    $label = esc_html( $atts['label'] ?? gmdate( 'G:i:s', $time_seconds ) );
    return '<button class="episode-seek-btn" data-seconds="' . absint( $time_seconds ) . '">' . $label . '</button>';
}, 10, 3 );

Replace with styled timecode badge

add_filter( 'benecaster_timestamp_output', function ( string $html, int $time, array $atts ): string {
    $minutes = floor( $time / 60 );
    $seconds = $time % 60;
    $label   = sprintf( '%d:%02d', $minutes, $seconds );
    return sprintf(
        '<span class="ts-badge" data-seek="%d">%s</span>',
        $time,
        esc_html( $label )
    );
}, 10, 3 );

Add aria-label for accessibility

add_filter( 'benecaster_timestamp_output', function ( string $html, int $time, array $atts ): string {
    $label = ! empty( $atts['label'] ) ? $atts['label'] : 'Skip to ' . gmdate( 'H:i:s', $time );
    return str_replace( '<button', '<button aria-label="' . esc_attr( $label ) . '"', $html );
}, 10, 3 );

Affects

  • [benecaster_timestamp](/shortcodes/benecaster-timestamp/) shortcode
  • Timestamp TipTap node (inline)