- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-request.php
r41189 r42343 112 112 public function __construct( $method = '', $route = '', $attributes = array() ) { 113 113 $this->params = array( 114 'URL' => array(),115 'GET' => array(),116 'POST' => array(),117 'FILES' => array(),114 'URL' => array(), 115 'GET' => array(), 116 'POST' => array(), 117 'FILES' => array(), 118 118 119 119 // See parse_json_params. 120 'JSON' => null,120 'JSON' => null, 121 121 122 122 'defaults' => array(), … … 236 236 */ 237 237 public function set_header( $key, $value ) { 238 $key = $this->canonicalize_header_name( $key );238 $key = $this->canonicalize_header_name( $key ); 239 239 $value = (array) $value; 240 240 … … 251 251 */ 252 252 public function add_header( $key, $value ) { 253 $key = $this->canonicalize_header_name( $key );253 $key = $this->canonicalize_header_name( $key ); 254 254 $value = (array) $value; 255 255 … … 369 369 * An array of types to check, in order of priority. 370 370 * 371 * 371 * @param string $type The type to check. 372 372 * } 373 373 * @param WP_REST_Request $this The request object. … … 406 406 */ 407 407 public function set_param( $key, $value ) { 408 $order = $this->get_parameter_order();408 $order = $this->get_parameter_order(); 409 409 $this->params[ $order[0] ][ $key ] = $value; 410 410 } … … 588 588 589 589 // Enable lazy parsing. 590 $this->parsed_json = false;591 $this->parsed_body = false;590 $this->parsed_json = false; 591 $this->parsed_body = false; 592 592 $this->params['JSON'] = null; 593 593 } … … 651 651 ); 652 652 if ( function_exists( 'json_last_error' ) ) { 653 $error_data['json_error_code'] = json_last_error();653 $error_data['json_error_code'] = json_last_error(); 654 654 $error_data['json_error_message'] = json_last_error_msg(); 655 655 } … … 803 803 804 804 if ( $invalid_params ) { 805 return new WP_Error( 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params ) ); 805 return new WP_Error( 806 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 807 'status' => 400, 808 'params' => $invalid_params, 809 ) 810 ); 806 811 } 807 812 … … 825 830 826 831 $attributes = $this->get_attributes(); 827 $required = array();832 $required = array(); 828 833 829 834 // No arguments set, skip validation. … … 841 846 842 847 if ( ! empty( $required ) ) { 843 return new WP_Error( 'rest_missing_callback_param', sprintf( __( 'Missing parameter(s): %s' ), implode( ', ', $required ) ), array( 'status' => 400, 'params' => $required ) ); 848 return new WP_Error( 849 'rest_missing_callback_param', sprintf( __( 'Missing parameter(s): %s' ), implode( ', ', $required ) ), array( 850 'status' => 400, 851 'params' => $required, 852 ) 853 ); 844 854 } 845 855 … … 869 879 870 880 if ( $invalid_params ) { 871 return new WP_Error( 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params ) ); 881 return new WP_Error( 882 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 883 'status' => 400, 884 'params' => $invalid_params, 885 ) 886 ); 872 887 } 873 888 … … 946 961 */ 947 962 public static function from_url( $url ) { 948 $bits = parse_url( $url );963 $bits = parse_url( $url ); 949 964 $query_params = array(); 950 965 … … 957 972 // Pretty permalinks on, and URL is under the API root. 958 973 $api_url_part = substr( $url, strlen( untrailingslashit( $api_root ) ) ); 959 $route = parse_url( $api_url_part, PHP_URL_PATH );974 $route = parse_url( $api_url_part, PHP_URL_PATH ); 960 975 } elseif ( ! empty( $query_params['rest_route'] ) ) { 961 976 // ?rest_route=... set directly
Note: See TracChangeset
for help on using the changeset viewer.