Skip to main content

CreditStampService

\Benecaster\Episode\CreditStampService

Class Free

Applies a show’s credit template to an episode. Stamping runs the template body through do_shortcode() once, at the moment of the call, and stores the resulting HTML on the episode as _benecaster_stamped_credit, with the template’s ID as _benecaster_stamped_credit_source. Later edits to the template do not change episodes that were already stamped; re-stamping is the only way to refresh one.

The class has one method, no constructor and no dependencies. It is internal. To stamp a show’s default credit from add-on code, use benecaster_apply_default_credit(), which finds the default template, honours the benecaster_credit_options filter and reports failure as false instead of throwing. To stamp a specific template, POST /benecaster/v1/episodes/{id}/stamp-credit with a credit_id, the route the editor’s Apply button calls, which needs an admin user. To change the template body just before it resolves, hook the benecaster_credit_before_stamp filter, and to act afterwards, hook the benecaster_credit_applied action.

Methods

Method Visibility Since Description
stamp( int $episode_id, string $credit_id ): string Public — Stamps the credit template $credit_id onto the episode and returns the resolved HTML. In order: it loads the episode, its parent show and the template, and throws \RuntimeException when any of them is missing (messages "Episode not found.", "Episode has no parent show.", "Parent show missing." and "Credit template not found on this show."). It then passes the template body through the benecaster_credit_before_stamp filter, runs the result through do_shortcode(), saves it as the episode's stamped credit and stamped-credit source, and fires benecaster_credit_applied. The $credit_id is the template's ID on the show, not a post ID. No capability check is made.

Hooks Fired

Notes

The returned string, and the $stamped_html passed to benecaster_credit_applied, are the raw output of do_shortcode(). The copy saved on the episode is passed through wp_kses_post() first, so markup that wp_kses_post() strips is present in the return value and absent from what is stored.

The action fires only after the meta has been written. An exception thrown earlier leaves any previous stamp on the episode untouched.