Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (6 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/class-wp-rest-server.php

    r47060 r47122  
    415415
    416416            $json_error_message = $this->get_json_last_error();
     417
    417418            if ( $json_error_message ) {
    418                 $json_error_obj = new WP_Error( 'rest_encode_error', $json_error_message, array( 'status' => 500 ) );
    419                 $result         = $this->error_to_response( $json_error_obj );
    420                 $result         = wp_json_encode( $result->data[0] );
     419                $json_error_obj = new WP_Error(
     420                    'rest_encode_error',
     421                    $json_error_message,
     422                    array( 'status' => 500 )
     423                );
     424
     425                $result = $this->error_to_response( $json_error_obj );
     426                $result = wp_json_encode( $result->data[0] );
    421427            }
    422428
     
    429435            }
    430436        }
     437
    431438        return null;
    432439    }
     
    454461            $data['_links'] = $links;
    455462        }
     463
    456464        if ( $embed ) {
    457465            // Determine if this is a numeric array.
     
    479487    public static function get_response_links( $response ) {
    480488        $links = $response->get_links();
     489
    481490        if ( empty( $links ) ) {
    482491            return array();
     
    847856
    848857            $args = array();
     858
    849859            foreach ( $matches as $param => $value ) {
    850860                if ( ! is_int( $param ) ) {
     
    867877
    868878                if ( ! is_callable( $callback ) ) {
    869                     $response = new WP_Error( 'rest_invalid_handler', __( 'The handler for the route is invalid' ), array( 'status' => 500 ) );
     879                    $response = new WP_Error(
     880                        'rest_invalid_handler',
     881                        __( 'The handler for the route is invalid' ),
     882                        array( 'status' => 500 )
     883                    );
    870884                }
    871885
     
    924938                            $response = $permission;
    925939                        } elseif ( false === $permission || null === $permission ) {
    926                             $response = new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to do that.' ), array( 'status' => rest_authorization_required_code() ) );
     940                            $response = new WP_Error(
     941                                'rest_forbidden',
     942                                __( 'Sorry, you are not allowed to do that.' ),
     943                                array( 'status' => rest_authorization_required_code() )
     944                            );
    927945                        }
    928946                    }
     
    9881006        }
    9891007
    990         return $this->error_to_response( new WP_Error( 'rest_no_route', __( 'No route was found matching the URL and request method' ), array( 'status' => 404 ) ) );
     1008        return $this->error_to_response(
     1009            new WP_Error(
     1010                'rest_no_route',
     1011                __( 'No route was found matching the URL and request method' ),
     1012                array( 'status' => 404 )
     1013            )
     1014        );
    9911015    }
    9921016
     
    10701094
    10711095        if ( ! isset( $this->namespaces[ $namespace ] ) ) {
    1072             return new WP_Error( 'rest_invalid_namespace', __( 'The specified namespace could not be found.' ), array( 'status' => 404 ) );
     1096            return new WP_Error(
     1097                'rest_invalid_namespace',
     1098                __( 'The specified namespace could not be found.' ),
     1099                array( 'status' => 404 )
     1100            );
    10731101        }
    10741102
     
    11871215            if ( isset( $callback['args'] ) ) {
    11881216                $endpoint_data['args'] = array();
     1217
    11891218                foreach ( $callback['args'] as $key => $opts ) {
    11901219                    $arg_data = array(
Note: See TracChangeset for help on using the changeset viewer.