Read or change a show’s preset task list, and run code when a show saves it
A show’s Workflow settings tab → Preset tasks holds the tasks every new episode’s production plan starts from (see Read or change an episode’s production plan, change how a new plan starts, and run code when a plan is finalised).
A task is { id, name, offset_days, duration_days }:
offset_daysis its due date in whole days from the episode’s publish date: negative before, 0 on publish day, positive after, from −365 to 365.duration_daysis how long it runs, ending on that due date (1 to 365), so a 7-day task due at −28 starts at −34.idis stable across saves. The default list’s ids startdefault-; a new task getstask-and 12 hex digits.
The list is stored whole in the show’s post meta _benecaster_workflow_task_list (a JSON list). With no saved list the show uses the default list of fifteen tasks, translated when it is read; a saved [] is an empty list.
GET /benecaster-podcast-workflow/v1/shows/{show_id}/task-listanswers{ tasks, customised, defaults }: the show’s list (the default list until it saves one), whether it has saved one, and the default list.PUT …/task-listsends{ tasks: [ { id?, name, offset_days, duration_days } ] }, the whole list in order, at most 100 tasks. A missing, invalid or repeatedidis replaced with a new one. Anything else invalid is400 benecaster_podcast_workflow_invalid_task_listwithdata.index, the row at fault, and nothing is saved. It answers asGETdoes.- Both routes need
benecaster_rest_permission_admin, then refuse with404 benecaster_podcast_workflow_show_not_foundor403 benecaster_podcast_workflow_off_for_show. - benecaster_podcast_workflow_before_save_preset_tasks and benecaster_podcast_workflow_after_save_preset_tasks are actions,
( int $show_id, array $tasks ), around the save,$tasksbeing the list as stored.
Code
<?php
add_action( 'benecaster_podcast_workflow_after_save_preset_tasks', function ( int $show_id, array $tasks ): void {
$longest = max( array_column( $tasks, 'duration_days' ) ?: [ 0 ] );
update_post_meta( $show_id, '_my_plugin_longest_task', $longest );
}, 10, 2 );
Hooks Used
Need this built rather than just documented? See our services →