benecaster_explicit_badge_label
Overrides the human-readable text inside the explicit badge. The default is “Explicit” for both explicit modes and “Clean” for the clean mode.
This filter exists because the wording is genuinely contested. Some podcasters want the compact “E” that Apple uses, some want “18+”, some want their own phrasing — and every one of those strings has to be translatable for the Localization work. Reach for this before the HTML filter: it is the smaller hammer, and it leaves the accessibility attributes and class modifiers intact.
The returned string is escaped at render time, so return plain text rather than markup. If you need markup, that is what benecaster_explicit_badge_html is for.
Restyle or reword the Explicit badge
The Explicit badge is rendered by one class — Benecaster\Episode\ExplicitBadgeRenderer — from every surface it appears on: the episode single page, archive cards, the [benecaster_episodes] list, the [benecaster_player] title strip, and the [benecaster_explicit_badge] shortcode. All of them share the same three filters, so a single hook changes the badge everywhere rather than needing a template override per surface.
Three asks come up repeatedly, and each maps to exactly one filter. Pick the smallest one that does the job.
“Change the wording.” Use the label filter. “E”, “18+”, “Adult”, your own phrasing — all one line, and the accessibility attributes and class modifiers stay intact.
“Restyle it.” Usually no PHP at all. The markup already carries --{mode} and --context-{surface} class modifiers, so CSS can style explicit differently from clean, and the archive grid differently from the single page. Reach for the HTML filter only when you need to change the structure — injecting an icon, say — not the appearance.
“Force it on for this one episode.” Use the mode filter. It overrides the resolved value without writing to the episode, which keeps a one-off out of your stored data.
<?php
// 1. Replace "Explicit" with a short "E" everywhere the badge renders.
add_filter( 'benecaster_explicit_badge_label', function ( string $label, string $mode ): string {
return 'clean' === $mode ? $label : 'E';
}, 10, 2 );
// 2. Restyle without touching templates — the class list already carries
// two modifiers (--{mode} + --context-{surface}), so plain CSS handles
// most cases. The HTML filter is the escape hatch when class-only styling
// is not enough (e.g. injecting an <svg> icon for aria-hidden purposes).
add_filter( 'benecaster_explicit_badge_html', function ( string $html, int $episode_id, int $show_id, string $mode, string $context ): string {
if ( 'clean' === $mode ) {
return $html; // leave the empty string alone
}
return sprintf(
'<span class="my-explicit" role="img" aria-label="%s"><svg aria-hidden="true"></svg><span class="visually-hidden">%s</span></span>',
esc_attr__( 'Explicit content', 'my-theme' ),
esc_html__( 'Explicit', 'my-theme' )
);
}, 10, 5 );
// 3. Force the badge on a specific episode without touching the stored
// meta — useful for a one-off override during a special series.
add_filter( 'benecaster_explicit_badge_mode', function ( string $mode, int $episode_id, int $show_id ): string {
return 12345 === $episode_id ? 'yes' : $mode;
}, 10, 3 );
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$label |
string |
— | Default label text for this mode. |
$mode |
string |
— | The resolved mode the label belongs to — `'clean'`, `'yes'`, or `'explicit'`. |
Returns:
string
Examples
Use a compact "E" instead of "Explicit"
add_filter( 'benecaster_explicit_badge_label', function ( string $label, string $mode ): string {
return 'clean' === $mode ? $label : 'E';
}, 10, 2 );
Reword both labels in your own text domain
add_filter( 'benecaster_explicit_badge_label', function ( string $label, string $mode ): string {
return 'clean' === $mode
? __( 'Family friendly', 'my-theme' )
: __( 'Adult content', 'my-theme' );
}, 10, 2 );