Skip to main content

Read or change which Workbench tiles a show draws, and run code when a show saves its choice

Premium Intermediate Podcast Workflow

A show’s Workflow settings tab turns each Workbench tile on or off for that show (tiles are described in Put a tile on the Podcast Workflow Workbench, and say where it stands for each episode); every episode of the show draws the same tiles. A show stores only what differs from each tile’s default_on, in the show’s post meta _benecaster_workflow_tiles (a JSON object { tile_id: true|false }). So a tile declared later appears at its own default, and removing the key puts every tile back to its default.

  • GET /benecaster-podcast-workflow/v1/shows/{show_id}/workflow-settings answers { tiles: [ { id, label, stage, description, default_on, on, add_on, partner_active } ] }, every tile in canvas order. on is whether the show draws it; partner_active is false when the tile’s add_on is off for the show.
  • PUT …/workflow-settings sends { tiles: { tile_id: true|false } }. Send every tile: one left out goes back to its default. An unknown id is ignored; any value but true or false is 400 benecaster_podcast_workflow_invalid_tile_settings. It answers as GET does.
  • Both routes need benecaster_rest_permission_admin, then refuse with 404 benecaster_podcast_workflow_show_not_found or 403 benecaster_podcast_workflow_off_for_show.
  • benecaster_podcast_workflow_before_save_tile_settings and benecaster_podcast_workflow_after_save_tile_settings are actions, ( int $show_id, array $tiles ), around the save, $tiles being what is stored (only the differences from the defaults).

Code

<?php
add_action( 'benecaster_podcast_workflow_after_save_tile_settings', function ( int $show_id, array $tiles ): void {
    if ( false === ( $tiles['chapter-markers'] ?? null ) ) {
        my_plugin_stop_suggesting_chapters( $show_id );
    }
}, 10, 2 );

View on GitHub →

Hooks Used

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