- Timestamp:
- 11/03/2016 08:04:59 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
r39106 r39126 94 94 'callback' => array( $this, 'delete_item' ), 95 95 'permission_callback' => array( $this, 'delete_item_permissions_check' ), 96 'args' => array( 97 'force' => array( 98 'type' => 'boolean', 99 'default' => false, 100 'description' => __( 'Required to be true, as resource does not support trashing.' ), 101 ), 102 ), 96 103 ), 97 104 'schema' => array( $this, 'get_public_item_schema' ), … … 221 228 */ 222 229 public function delete_item( $request ) { 230 $force = isset( $request['force'] ) ? (bool) $request['force'] : false; 231 232 // We don't support trashing for this resource type. 233 if ( ! $force ) { 234 return new WP_Error( 'rest_trash_not_supported', __( 'Revisions do not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) ); 235 } 236 237 $revision = $this->get_post( $request['id'] ); 238 $previous = $this->prepare_item_for_response( $revision, $request ); 239 223 240 $result = wp_delete_post( $request['id'], true ); 224 241 … … 235 252 do_action( 'rest_delete_revision', $result, $request ); 236 253 237 if ( $result ) { 238 return true; 239 } else { 254 if ( ! $result ) { 240 255 return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) ); 241 256 } 257 258 $response = new WP_REST_Response(); 259 $response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data() ) ); 260 return $response; 242 261 } 243 262
Note: See TracChangeset
for help on using the changeset viewer.