- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php
r46586 r47122 162 162 163 163 $parent_post_type_obj = get_post_type_object( $parent->post_type ); 164 164 165 if ( ! current_user_can( $parent_post_type_obj->cap->edit_post, $parent->ID ) ) { 165 return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to view autosaves of this post.' ), array( 'status' => rest_authorization_required_code() ) ); 166 return new WP_Error( 167 'rest_cannot_read', 168 __( 'Sorry, you are not allowed to view autosaves of this post.' ), 169 array( 'status' => rest_authorization_required_code() ) 170 ); 166 171 } 167 172 … … 182 187 public function create_item_permissions_check( $request ) { 183 188 $id = $request->get_param( 'id' ); 189 184 190 if ( empty( $id ) ) { 185 return new WP_Error( 'rest_post_invalid_id', __( 'Invalid item ID.' ), array( 'status' => 404 ) ); 191 return new WP_Error( 192 'rest_post_invalid_id', 193 __( 'Invalid item ID.' ), 194 array( 'status' => 404 ) 195 ); 186 196 } 187 197 … … 215 225 if ( ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status ) && $post->post_author == $user_id ) { 216 226 // Draft posts for the same author: autosaving updates the post and does not create a revision. 217 // Convert the post object to an array and add slashes, wp_update_post expects escaped array.227 // Convert the post object to an array and add slashes, wp_update_post() expects escaped array. 218 228 $autosave_id = wp_update_post( wp_slash( (array) $prepared_post ), true ); 219 229 } else { … … 247 257 248 258 if ( $parent_id <= 0 ) { 249 return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post parent ID.' ), array( 'status' => 404 ) ); 259 return new WP_Error( 260 'rest_post_invalid_id', 261 __( 'Invalid post parent ID.' ), 262 array( 'status' => 404 ) 263 ); 250 264 } 251 265 … … 253 267 254 268 if ( ! $autosave ) { 255 return new WP_Error( 'rest_post_no_autosave', __( 'There is no autosave revision for this post.' ), array( 'status' => 404 ) ); 269 return new WP_Error( 270 'rest_post_no_autosave', 271 __( 'There is no autosave revision for this post.' ), 272 array( 'status' => 404 ) 273 ); 256 274 } 257 275 … … 314 332 315 333 $this->schema = $schema; 334 316 335 return $this->add_additional_fields_schema( $this->schema ); 317 336 } … … 358 377 if ( ! $autosave_is_different ) { 359 378 wp_delete_post_revision( $old_autosave->ID ); 360 return new WP_Error( 'rest_autosave_no_changes', __( 'There is nothing to save. The autosave and the post content are the same.' ), array( 'status' => 400 ) ); 379 return new WP_Error( 380 'rest_autosave_no_changes', 381 __( 'There is nothing to save. The autosave and the post content are the same.' ), 382 array( 'status' => 400 ) 383 ); 361 384 } 362 385 … … 364 387 do_action( 'wp_creating_autosave', $new_autosave ); 365 388 366 // wp_update_post expects escaped array.389 // wp_update_post() expects escaped array. 367 390 return wp_update_post( wp_slash( $new_autosave ) ); 368 391 }
Note: See TracChangeset
for help on using the changeset viewer.