Skip to content

Commit

Permalink
REST API: Support status=future for post update and creation.
Browse files Browse the repository at this point in the history
Right now this is just an alias for "publish" and behaves exactly the same way (with a past date it will be published & back-dated; with no date it will be published immediately; with a future date it will be scheduled).

Merges r124520-wpcom.
  • Loading branch information
Kat Hagan authored and zinigor committed Sep 25, 2015
1 parent 3cb5dbb commit 834e452
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions json-endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@
'private' => 'Privately publish the post.',
'draft' => 'Save the post as a draft.',
'pending' => 'Mark the post as pending editorial approval.',
'future' => 'Schedule the post (alias for publish; you must also set a future date).',
'auto-draft' => 'Save a placeholder for a newly created post, with no content.',
),
'sticky' => array(
Expand Down Expand Up @@ -684,6 +685,7 @@
'private' => 'Privately publish the post.',
'draft' => 'Save the post as a draft.',
'pending' => 'Mark the post as pending editorial approval.',
'future' => 'Schedule the post (alias for publish; you must also set a future date).',
'auto-draft' => 'Save a placeholder for a newly created post, with no content.',
),
'sticky' => array(
Expand Down Expand Up @@ -819,6 +821,7 @@
'publish' => 'Publish the post.',
'private' => 'Privately publish the post.',
'draft' => 'Save the post as a draft.',
'future' => 'Schedule the post (alias for publish; you must also set a future date).',
'pending' => 'Mark the post as pending editorial approval.',
),
'sticky' => array(
Expand Down Expand Up @@ -884,6 +887,7 @@
'publish' => 'Publish the post.',
'private' => 'Privately publish the post.',
'draft' => 'Save the post as a draft.',
'future' => 'Schedule the post (alias for publish; you must also set a future date).',
'pending' => 'Mark the post as pending editorial approval.',
),
'sticky' => array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ function write_post( $path, $blog_id, $post_id ) {
add_action( 'rest_api_inserted_post', array( $GLOBALS['publicize_ui']->publicize, 'async_publicize_post' ) );
}

// 'future' is an alias for 'publish' for now
if ( 'future' === $input['status'] ) {
$input['status'] = 'publish';
}

if ( $new ) {
$input = $this->input( true );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ function write_post( $path, $blog_id, $post_id ) {
add_action( 'rest_api_inserted_post', array( $GLOBALS['publicize_ui']->publicize, 'async_publicize_post' ) );
}

// 'future' is an alias for 'publish' for now
if ( 'future' === $input['status'] ) {
$input['status'] = 'publish';
}

if ( $new ) {
$input = $this->input( true );

Expand Down

0 comments on commit 834e452

Please sign in to comment.