EpisodeCreditsController
\Benecaster\REST\EpisodeCreditsController
Admin REST endpoint for stamping a show-level credit template onto an episode. Registers POST /wp-json/benecaster/v1/episodes/{id}/stamp-credit. Auth: permission_callback_admin (manage_options + wp_rest nonce). A thin boundary layer only — all storage and shortcode resolution live in CreditStampService; this class maps its RuntimeException to HTTP responses.
Constructor Dependencies
| Type | Description |
|---|---|
\Benecaster\Episode\CreditStampService |
Performs the actual credit-template resolution, shortcode execution, and persistence. |
Methods
| Method | Visibility | Since | Description |
|---|---|---|---|
register_routes(): void |
Public | — | Registers POST /episodes/{id}/stamp-credit, permission_callback_admin, with a numeric-id validate_callback. |
stamp_credit( WP_REST_Request $request ): WP_REST_Response|WP_Error |
Public | — | Body: credit_id. 404 for a missing or non-episode {id}; 400 invalid_param when credit_id is empty. Delegates to CreditStampService::stamp(), which throws RuntimeException for a missing parent show or an unknown credit template — both are mapped to 400 stamp_failed with the exception's own message, since from the client's perspective both are a lookup failure against data it should already know about. On success, returns the stamped HTML plus stamped_credit_source (read fresh from EpisodeMeta after the write). |
Notes
Extends the plugin's internal RestController base — not part of the public API; its own docblock tells add-on developers not to extend it, and to register independent routes on rest_api_init with the public benecaster_rest_permission_admin() function instead. Inherits register() (hooks register_routes() onto rest_api_init), the permission_callback_admin / permission_callback_editor / permission_callback_subscriber callbacks, rest_error(), and not_found().
benecaster_credit_before_stamp and benecaster_credit_applied fire from CreditStampService, not from this controller — see that class's own entry.