benecaster_workbench_tile_state
Says where a Podcast Workflow Workbench tile stands for one episode. It is called once per drawn tile per episode, starting from null. Every callback sees every tile: return $state untouched unless $tile_id is yours. A tile nobody answers for is Not started, with no summary and no button. This is part of the tile contract that Benecaster’s own Chapters tile and the partner add-ons build against; it changes only with deprecation.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$state |
array|null |
— | The state so far, `null` until a callback answers. For your tile, return `[ 'status' => 'not_started'|'in_progress'|'done' (anything else reads as not_started), 'summary' => string (one short plain-text line, cut past 120 characters), 'count' => int|null, 'action_url' => string, 'action_label' => string ]`. The button needs both `action_url` and `action_label`; `action_url` is an admin-app route starting `#/` or an `http` or `https` URL, and anything else is dropped. |
$tile_id |
string |
— | The tile being drawn |
$episode_id |
int |
— | The episode the tile is drawn for |
$show_id |
int |
— | The episode's own show (its `post_parent`), never the one picked in the show switcher |
Returns:
array|null
Example
add_filter( 'benecaster_workbench_tile_state', function ( ?array $state, string $tile_id, int $episode_id, int $show_id ): ?array {
if ( 'chapter-markers' !== $tile_id ) {
return $state;
}
$count = count( my_plugin_chapters( $episode_id ) );
return [
'status' => $count > 0 ? 'done' : 'not_started',
/* translators: %d: number of chapters */
'summary' => sprintf( _n( '%d chapter', '%d chapters', $count, 'my-plugin' ), $count ),
'count' => $count,
'action_url' => '#/episodes/' . $episode_id . '?tab=chapters',
'action_label' => __( 'Edit chapters', 'my-plugin' ),
];
}, 10, 4 );
Notes
When the tile's add_on names an add-on that is off for the episode's show, this filter is not called for that tile: it is drawn Not started, with a line saying the add-on it reads from is off for this show. Walkthrough: Put a tile on the Podcast Workflow Workbench, and say where it stands for each episode.
Affects
- Workbench
- GET benecaster-podcast-workflow/v1/shows/{show_id}/episodes
- GET benecaster-podcast-workflow/v1/shows/{show_id}/episodes/{episode_id}/workbench
Need this built rather than just documented? See our services →