-
Notifications
You must be signed in to change notification settings - Fork 658
Return full post object when deleting post #1256
Conversation
@WP-API/amigos #reviewmerge |
From the HTTP spec for DELETE:
I don’t know what |
@@ -327,6 +327,10 @@ public function delete_item( $request ) { | |||
return new WP_Error( 'rest_user_cannot_delete_post', __( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => 401 ) ); | |||
} | |||
|
|||
$mock_request = new WP_REST_Request( 'GET', rest_url( 'wp/v2/' . $this->get_post_type_base( $this->post_type ) . '/' . $post->ID ) ); | |||
$mock_request->set_param( 'context', 'edit' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$mock_request
isn't really the right name, since this is a real request and "mock" has a specific meaning. $get_request
?
This generally looks OK to me. One thing we might want to consider is wrapping the post in another object (e.g. |
Also, should we consider this from #627? if ( $new_status === 'trash' ) {
// Send a 202 if it's only trashed to indicate that it will be
// actually deleted later
$response->set_status( 202 ); i.e. 200 = permanently deleted, 202 = trashed Not sure we need the distinction now with the split from double-DELETE to separate trash/perma-delete, but worth thinking about. |
See #1260 |
Return full post object when deleting post
See #1224