Skip to main content

Show a different duration format in the admin only

Free Beginner

Show the podcaster total minutes (62 min) on Benecaster → Episodes while listeners keep the website’s format.

Code

<?php
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 );

View on GitHub →

Hooks Used

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