- Timestamp:
- 09/05/2020 06:07:46 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-request.php
r48642 r48945 859 859 $required = array(); 860 860 861 // No arguments set, skip validation. 862 if ( empty( $attributes['args'] ) ) { 863 return true; 864 } 865 866 foreach ( $attributes['args'] as $key => $arg ) { 867 861 $args = empty( $attributes['args'] ) ? array() : $attributes['args']; 862 863 foreach ( $args as $key => $arg ) { 868 864 $param = $this->get_param( $key ); 869 865 if ( isset( $arg['required'] ) && true === $arg['required'] && null === $param ) { … … 891 887 $invalid_params = array(); 892 888 893 foreach ( $a ttributes['args']as $key => $arg ) {889 foreach ( $args as $key => $arg ) { 894 890 895 891 $param = $this->get_param( $key ); … … 920 916 } 921 917 918 if ( isset( $attributes['validate_callback'] ) ) { 919 $valid_check = call_user_func( $attributes['validate_callback'], $this ); 920 921 if ( is_wp_error( $valid_check ) ) { 922 return $valid_check; 923 } 924 925 if ( false === $valid_check ) { 926 // A WP_Error instance is preferred, but false is supported for parity with the per-arg validate_callback. 927 return new WP_Error( 'rest_invalid_params', __( 'Invalid parameters.' ), array( 'status' => 400 ) ); 928 } 929 } 930 922 931 return true; 923 924 932 } 925 933
Note: See TracChangeset
for help on using the changeset viewer.