Skip to main content

benecaster_sponsor_manager_message_output

Filter Premium sponsor-manager

Filters the HTML of the benecaster_sponsor_message shortcode: a sponsor message’s current copy inside <div class="benecaster-sponsor-message">.

It runs only when the copy is shown: the message exists and is not archived, the episode belongs to the message’s own show, Sponsor Manager is on for that show, and today, in the site’s time zone, is on or between the message’s start and end dates. It never runs for a tag that shows nothing, so it cannot make a message appear outside its show, its dates or the shows where Sponsor Manager is on.

Parameters

Name Type Default Description
$html string — The message's HTML, its body passed through `wp_kses_post`
$message_id int — The message
$episode_id int — The episode the tag is shown in
$atts array — The shortcode's attributes after defaults: `id`, `episode_id`

Returns: string

Example

// Label every sponsor read on the episode page.
add_filter( 'benecaster_sponsor_manager_message_output', function ( string $html, int $message_id, int $episode_id, array $atts ): string {
    return '<p class="sponsor-label">' . esc_html__( 'Sponsored', 'my-theme' ) . '</p>' . $html;
}, 10, 4 );

Notes

A return that is not a string is cast to one. The returned HTML is printed as is: escape anything you add. Walkthrough: Restyle or change a sponsor message where its tag shows it.

Affects

  • [benecaster_sponsor_message] shortcode

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