benecaster_apply_default_credit()
benecaster_apply_default_credit( int $episode_id ): bool
Public helper that applies the show’s default credit template to an episode. Add-ons should use this function rather than invoking CreditStampService directly. Resolves the parent show from $episode_id, runs the show’s credit definition list through the benecaster_credit_options filter, picks the entry flagged is_default: true, and delegates to CreditStampService::stamp().
On success the stamp service fires benecaster_credit_before_stamp before shortcode resolution and benecaster_credit_applied after persisting the result.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
episode_id |
int |
— | Yes | The episode (post) ID to stamp with the show's default credit template. |
Return Value
Type:
bool
true when the default credit was successfully stamped onto the episode. false when the episode ID is invalid, the post type is not the Benecaster episode CPT, the episode has no parent show, no credit entry in the (filtered) list has is_default: true, or CreditStampService::stamp() throws for any other reason.
Example
$ok = benecaster_apply_default_credit( $episode_id );
if ( ! $ok ) {
// The stamp did not complete — log or handle as appropriate
}
Hooks Fired
-
benecaster-credit-before-stamp -
benecaster-credit-applied
Notes
CreditStampService is an internal class — its constructor signature is not considered stable API. This function provides a stable, add-on-safe entry point that handles show resolution, the benecaster_credit_options filter, and default selection before delegating to the service. Callers that bypass this function and instantiate CreditStampService directly may break when the constructor changes in a future release.
To stamp a specific non-default credit, use the ShowCreditsController PUT endpoint to promote a credit to default first, or use the EpisodeCreditsController REST endpoint to stamp by credit ID directly.
Need this built rather than just documented? See our services →