Read, write, rearrange and promote a show’s Content Calendar ideas over REST
The routes behind a show’s Ideas board: GET and POST /benecaster-content-calendar/v1/shows/{show_id}/ideas, PUT …/ideas/order, GET, PUT, PATCH and DELETE …/ideas/{id}, and POST …/ideas/{id}/promote.
Access. The same permission and per-show check as Read and write a show’s Content Calendar content items over REST: manage_options and the REST nonce, and Content Calendar switched on for {show_id}, else 403 benecaster_content_calendar_off_for_show. An idea of another show answers 404 benecaster_content_calendar_idea_not_found, as one that does not exist.
An idea is answered as { id, show_id, type, type_name, type_label, type_color, type_enabled, title, notes }. type_label is '' and type_color null while the type is undecided. type_enabled is false for a type the show has switched off or removed; promoting the idea then needs another type. The stored fields are listed in Run your own code when a Content Calendar idea is saved, deleted or rearranged.
GET …/ideasanswers{ items: [idea] }in board order.POST …/ideasandPUTorPATCH …/ideas/{id}send every field:type(''for undecided, or a switched-on type other thanepisode; an edit may keep a type since switched off),type_name(required, 1–60 characters, whentypeisother),title(1–200 characters) andnotes(up to 5,000 characters). A refusal is400 benecaster_content_calendar_invalid_idea, withdata.field. A new idea goes first. Past 500 ideas on a show,POSTanswers400 benecaster_content_calendar_too_many_ideas.PUT …/ideas/ordersends{ ids }, every idea of the show, first to last, and answers the board asGETdoes. A list that is not exactly the show’s ideas (one missing, one twice, another show’s) is409 benecaster_content_calendar_ideas_changedand changes nothing.DELETE …/ideas/{id}answers{ deleted: true, id }.POST …/ideas/{id}/promotesends every content item field, asPOST …/itemsdoes, makes the item, then deletes the idea. It answers201 { item, idea_removed },itembeing the content item asPOST …/itemsanswers it. A refused item field answers asPOST …/itemsdoes, and the idea stays.
Ideas are stored in the table {prefix}benecaster_calendar_ideas. To add keys of your own to each idea, see Add to what the Content Calendar REST API answers for an idea.
Code
<?php
$request = new WP_REST_Request( 'POST', '/benecaster-content-calendar/v1/shows/42/ideas' );
$request->set_body_params( [ 'type' => '', 'type_name' => '', 'title' => 'Listener mailbag', 'notes' => 'From the October episodes' ] );
$idea = rest_do_request( $request )->get_data();
Need this built rather than just documented? See our services →