Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php

    r46586 r47122  
    162162
    163163        $parent_post_type_obj = get_post_type_object( $parent->post_type );
     164
    164165        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            );
    166171        }
    167172
     
    182187    public function create_item_permissions_check( $request ) {
    183188        $id = $request->get_param( 'id' );
     189
    184190        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            );
    186196        }
    187197
     
    215225        if ( ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status ) && $post->post_author == $user_id ) {
    216226            // 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.
    218228            $autosave_id = wp_update_post( wp_slash( (array) $prepared_post ), true );
    219229        } else {
     
    247257
    248258        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            );
    250264        }
    251265
     
    253267
    254268        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            );
    256274        }
    257275
     
    314332
    315333        $this->schema = $schema;
     334
    316335        return $this->add_additional_fields_schema( $this->schema );
    317336    }
     
    358377            if ( ! $autosave_is_different ) {
    359378                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                );
    361384            }
    362385
     
    364387            do_action( 'wp_creating_autosave', $new_autosave );
    365388
    366             // wp_update_post expects escaped array.
     389            // wp_update_post() expects escaped array.
    367390            return wp_update_post( wp_slash( $new_autosave ) );
    368391        }
Note: See TracChangeset for help on using the changeset viewer.