Skip to main content

Template — episode/explicit-badge.php

templates/episode/explicit-badge.php

The explicit-content badge. Rendered as a template part on the episode single page, on archive cards, inside the [benecaster_episodes] list, in the [benecaster_player] title strip, and by the [benecaster_explicit_badge] shortcode — one template serving all five surfaces.

Variables

Variable Type Notes
$episode_id int WordPress post ID of the episode being rendered
$show_id int WordPress post ID of the episode’s show
$context string Which surface is rendering — 'single', 'card', 'list', 'player', or 'shortcode'. Becomes the --context-{surface} class modifier
$show_clean bool Whether to render a “Clean” badge on non-explicit episodes. false on every automatic placement; set by the shortcode’s show_clean attribute

Default Output

<span class="benecaster-explicit-badge benecaster-explicit-badge--explicit benecaster-explicit-badge--context-single"
      role="img" aria-label="Explicit content"><span class="benecaster-explicit-badge__text">Explicit</span></span>

The label sits in its own __text span rather than as a bare text node — that is what you target to hide the wording and show an icon, and an override that drops it will break any CSS written against it.

Two class modifiers are always present — --{state} and --context-{surface}.

The state modifier is only ever --clean or --explicit, never --yes. Three modes resolve — clean, yes and explicit — but yes and explicit both render the same badge and both carry --explicit. Anything unrecognised resolves to clean. If you need to tell yes from explicit in CSS you cannot, and the mode is not exposed in the markup — branch in benecaster_explicit_badge_html instead, which receives the resolved $mode.

--context-{surface} is passed through sanitize_html_class() and falls back to single, so a custom context string will not break the class list.

Between the two modifiers, most restyling needs no override at all: CSS alone can distinguish explicit from clean, and the archive grid from the single page.

Clean episodes render nothing unless $show_clean is true — an empty string, not an empty element. A badge that appears on every episode carries no information, so the default is silence.

Before You Override

An override is usually the wrong tool here. Three filters cover the common cases and survive plugin updates cleanly, where a copied template silently goes stale when the default changes:

See the recipe Restyle or reword the Explicit badge.

Override the template when you want different structure per surface and find branching on $context inside a filter more awkward than a template that owns the markup outright.

If You Do Override

Keep it readable to screen readers. The default carries role="img" and an aria-label because colour and a single letter mean nothing to assistive technology. An override needs an equivalent — a visually-hidden text span, or an aria-label on your element.

Do not resolve the value yourself. $episode_id and $show_id are handed to you, but working out which one wins is ExplicitBadgeRenderer::resolve_mode()‘s job, and it also applies the mode filter. Reading the episode meta directly will disagree with the feed on any episode set to inherit.

Structured data is emitted separately. The schema.org contentRating on the episode page comes from render_schema_meta(), not from this template. Hiding or emptying the badge here does not remove it, which is the intended behaviour — a theme’s visual choice should not strip structured data.

Theme Override Path

{theme}/benecaster/episode/explicit-badge.php

See template-overrides for the full override directory convention and lookup order.

See Also