Skip to main content

Read, write, rearrange and promote a show’s Content Calendar ideas over REST

Premium Advanced Content Calendar

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 …/ideas answers { items: [idea] } in board order.
  • POST …/ideas and PUT or PATCH …/ideas/{id} send every field: type ('' for undecided, or a switched-on type other than episode; an edit may keep a type since switched off), type_name (required, 1–60 characters, when type is other), title (1–200 characters) and notes (up to 5,000 characters). A refusal is 400 benecaster_content_calendar_invalid_idea, with data.field. A new idea goes first. Past 500 ideas on a show, POST answers 400 benecaster_content_calendar_too_many_ideas.
  • PUT …/ideas/order sends { ids }, every idea of the show, first to last, and answers the board as GET does. A list that is not exactly the show’s ideas (one missing, one twice, another show’s) is 409 benecaster_content_calendar_ideas_changed and changes nothing.
  • DELETE …/ideas/{id} answers { deleted: true, id }.
  • POST …/ideas/{id}/promote sends every content item field, as POST …/items does, makes the item, then deletes the idea. It answers 201 { item, idea_removed }, item being the content item as POST …/items answers it. A refused item field answers as POST …/items does, 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();

View on GitHub →

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