Know when Sponsor Manager clears a show’s feed, and how its tag reaches the feed and Episode Credits
Benecaster runs no shortcodes in the feed except its own gates, so Sponsor Manager resolves its own tag only, benecaster_sponsor_message, on Benecaster’s filters. The same rules decide what shows as on a page (see Restyle or change a sponsor message where its tag shows it). Its callbacks run at priority 10 and are registered whether or not Sponsor Manager is on for any show.
- benecaster_episode_content
( $content, $episode_id, $tier_slug )carries the full show notes:<content:encoded>,<description>when the Podcatcher Description is empty, and the episode page, where it runs beforethe_content. The tag becomes the message’s HTML, and a<p>holding nothing but the tag is removed with it. - benecaster_episode_description_rss
( $description, $episode_id )carries the Podcatcher Description (<description>,<itunes:summary>). The tag becomes the copy as plain text, a line per paragraph. - benecaster_credit_before_stamp
( $body, $episode_id, $credit_id, $show )runs when an Episode Credits template is applied. The tag becomes the HTML, for the episode being stamped, before Benecaster’s owndo_shortcode(). The copy is frozen into the stamp as of that day, as every stamped credit is.
The filter’s $episode_id decides the show, never a global post or the tag’s own episode_id. An escaped tag, [[benecaster_sponsor_message …]], is left for the_content. A callback of yours on the same filters at priority 10 or lower sees the raw tag; above 10, the resolved copy.
When the feed is cleared
Nothing about a message is part of the feed’s cache key, so Sponsor Manager fires benecaster_clear_feed_cache with the message’s show itself:
- on every message save, archive and restore, after benecaster_sponsor_manager_after_save_message or benecaster_sponsor_manager_after_archive_message;
- from the cron event
benecaster_sponsor_manager_message_date, scheduled once per message and date, with the arguments[ int $message_id, 'start' | 'end' ]: at 00:00 on its start date, and at 00:00 the day after its end date, in the site’s time zone. A save replaces the message’s two events, and an archived message has none. To remove them all, usewp_unschedule_hook(), notwp_clear_scheduled_hook(), which matches arguments.
A daily cron event, benecaster_sponsor_manager_message_dates, puts back any start or end event still ahead that is missing; Benecaster’s uninstall and Reset Plugin Data remove every benecaster_ cron event. Both events run only while Sponsor Manager is on for at least one show.
Code
<?php
// Purge a CDN's copy of the show's feed whenever Sponsor Manager (or anything) clears it.
add_action( 'benecaster_clear_feed_cache', function ( $show_id = null ): void {
if ( $show_id ) {
my_cdn_purge( benecaster_get_public_feed_url( (int) $show_id ) );
}
}, 20 );
Hooks Used
Need this built rather than just documented? See our services →