Skip to main content

Set tier and availability on imported episodes in bulk

Free Intermediate

The write half of Flag imported episodes your own way. A migration add-on that has just imported 400 episodes, or a WP-CLI script staging a back catalogue for a launch date, wants one call rather than 400 episode saves — POST /shows/{id}/import-review/bulk, Migration\SspImporter::apply_bulk_defaults().

The datetime is your site’s LOCAL wall clock, not UTC. AvailabilityRepository::upsert() is the single conversion point, so passing gmdate( 'Y-m-d H:i:s' ) shifts every episode in the batch by the site’s offset, silently. Use current_time( 'mysql' ) if you need “now”, or just pass 'immediate'.

The REST route validates; the PHP method does not. POST /shows/{id}/import-review/bulk (requires manage_options) refuses the whole request with invalid_episode if any id is not an imported episode of that show, and writes nothing — deliberately all-or-nothing, because a half-applied batch reporting success leaves a back catalogue half-gated with nothing on screen saying so. Calling apply_bulk_defaults() directly skips that check, so pass ids you derived from ImportReviewQuery, as in the code example.

'all' means every tier currently mapped to the show, resolved at call time — not “public forever”. A tier added later is not covered retroactively.

POST /shows/{id}/ssp-review/bulk is the same operation and is not deprecated; both routes run this one method. Prefer the import-review one unless you are already working against the SSP panel’s surface.

Code

<?php
add_action( 'benecaster_boot', function ( \Benecaster\Container $container ): void {
    $show_id = 12;

    $rows = $container->make( \Benecaster\Episode\ImportReviewQuery::class )
        ->rows_for_show( $show_id, [ 'rss' ] );

    $container->make( \Benecaster\Migration\SspImporter::class )->apply_bulk_defaults(
        $show_id,
        array_column( $rows, 'id' ),
        'gold',                 // a tier's internal slug, or 'all'
        '2027-01-15 08:00:00'   // site-local, or 'immediate'
    );
} );

View on GitHub →

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