Skip to main content

benecaster_admin_duration_display

Filter Free

Filters an episode duration as the admin Episodes list shows it. It fires once per episode in the episode list and single-episode REST responses (GET /shows/{id}/episodes and GET /episodes/{id}), which carry the result as duration_display beside the unchanged duration. The Benecaster → Episodes list shows it in each row’s meta line, and hides the figure when a callback returns ''.

It takes the same arguments and has the same default as benecaster_duration_display, the website’s filter, and is kept separate so a site can show the podcaster more or less precision than its listeners see.

Display only. The episode editor’s Duration field, REST’s duration and the feed keep HH:MM:SS, and it does not touch the website.

Parameters

Name Type Default Description
$formatted string — The default: `H:MM`, rounded to the nearest minute. For a value that is not a duration, that value as stored, trimmed
$seconds int|null — Total whole seconds, or null when the value is not a duration
$duration string — The stored value

Returns: string

Example

add_filter( 'benecaster_admin_duration_display', function ( string $formatted, ?int $seconds ): string {
    if ( null === $seconds ) {
        return $formatted;
    }
    /* translators: %d: total minutes of an episode */
    return sprintf( __( '%d min', 'my-plugin' ), (int) round( $seconds / 60 ) );
}, 10, 2 );

Notes

It is not called for an empty duration. See Show a different duration format in the admin only.

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