Changeset 41727 for trunk/src/wp-includes/rest-api.php
- Timestamp:
- 10/04/2017 08:26:44 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api.php
r41238 r41727 1052 1052 } 1053 1053 } 1054 1055 if ( 'object' === $args['type'] ) { 1056 if ( $value instanceof stdClass ) { 1057 $value = (array) $value; 1058 } 1059 if ( ! is_array( $value ) ) { 1060 /* translators: 1: parameter, 2: type name */ 1061 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'object' ) ); 1062 } 1063 1064 foreach ( $value as $property => $v ) { 1065 if ( ! isset( $args['properties'][ $property ] ) ) { 1066 continue; 1067 } 1068 $is_valid = rest_validate_value_from_schema( $v, $args['properties'][ $property ], $param . '[' . $property . ']' ); 1069 1070 if ( is_wp_error( $is_valid ) ) { 1071 return $is_valid; 1072 } 1073 } 1074 } 1075 1054 1076 if ( ! empty( $args['enum'] ) ) { 1055 1077 if ( ! in_array( $value, $args['enum'], true ) ) { … … 1171 1193 return $value; 1172 1194 } 1195 1196 if ( 'object' === $args['type'] ) { 1197 if ( $value instanceof stdClass ) { 1198 $value = (array) $value; 1199 } 1200 if ( ! is_array( $value ) ) { 1201 return array(); 1202 } 1203 1204 foreach ( $value as $property => $v ) { 1205 if ( ! isset( $args['properties'][ $property ] ) ) { 1206 unset( $value[ $property ] ); 1207 continue; 1208 } 1209 $value[ $property ] = rest_sanitize_value_from_schema( $v, $args['properties'][ $property ] ); 1210 } 1211 1212 return $value; 1213 } 1214 1173 1215 if ( 'integer' === $args['type'] ) { 1174 1216 return (int) $value;
Note: See TracChangeset
for help on using the changeset viewer.