Skip to main content

Read and set the status of a task in an episode’s production plan, and run code when one changes

Premium Intermediate Podcast Workflow

Each task of an episode’s production plan (see Read or change an episode’s production plan, change how a new plan starts, and run code when a plan is finalised) carries a status a person sets: not_started (every new task), in_progress, blocked or complete.

Draft, Late and Unassigned are not statuses. They are worked out when shown, and never stored or accepted. A task is Late when its due date (publish date + offset_days, in the site’s time zone) is before today and it is not complete. Due today is not Late, and without a publish date nothing is Late.

  • PUT /benecaster-podcast-workflow/v1/shows/{show_id}/episodes/{episode_id}/plan/tasks/{task_id}/status sends { status } and saves it at once, whether the plan is a draft or final. It refuses with 400 benecaster_podcast_workflow_invalid_task_status, 404 benecaster_podcast_workflow_no_plan, 404 benecaster_podcast_workflow_task_not_found and the Workbench’s per-show checks, and answers as GET …/plan does. PUT …/plan never sets a status: it keeps each task’s by id, and a new task starts not_started.
  • The plan’s figures are summary on GET …/plan, and tasks on each row of GET …/shows/{show_id}/episodes and on the episode of GET …/workbench (see Read the Podcast Workflow Workbench over REST), null without a plan: { total, complete, late, blocked, finalised, next }. next is the task not complete with the lowest offset_days (on a tie, the one higher in the plan), as { id, name, offset_days, due_date, late } with due_date as Y-m-d or null; next is null when every task is complete.
  • benecaster_podcast_workflow_before_task_status_change and benecaster_podcast_workflow_after_task_status_change are actions, ( int $episode_id, string $task_id, string $new_status, string $old_status, int $show_id ), around a change, and only a change. The plan’s own save actions fire too.

Code

<?php
add_action( 'benecaster_podcast_workflow_after_task_status_change', function ( int $episode_id, string $task_id, string $new_status, string $old_status, int $show_id ): void {
    if ( 'blocked' === $new_status ) {
        my_plugin_alert_producer( $episode_id, $task_id );
    }
}, 10, 5 );

View on GitHub →

Hooks Used

Need this built rather than just documented? See our services →