- Timestamp:
- 12/02/2016 09:55:09 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php
r39328 r39436 118 118 * @access public 119 119 * 120 * @param WP_REST_Request $request Full details aboutthe request.120 * @param array $meta Array of meta parsed from the request. 121 121 * @param int $object_id Object ID to fetch meta for. 122 122 * @return WP_Error|null WP_Error if one occurs, null on success. 123 123 */ 124 public function update_value( $ request, $object_id ) {124 public function update_value( $meta, $object_id ) { 125 125 $fields = $this->get_registered_fields(); 126 126 foreach ( $fields as $meta_key => $args ) { 127 127 $name = $args['name']; 128 if ( ! array_key_exists( $name, $ request) ) {128 if ( ! array_key_exists( $name, $meta ) ) { 129 129 continue; 130 130 } … … 134 134 * from the database and then relying on the default value. 135 135 */ 136 if ( is_null( $ request[ $name ] ) ) {136 if ( is_null( $meta[ $name ] ) ) { 137 137 $result = $this->delete_meta_value( $object_id, $meta_key, $name ); 138 138 if ( is_wp_error( $result ) ) { … … 142 142 } 143 143 144 $is_valid = rest_validate_value_from_schema( $ request[ $name ], $args['schema'], 'meta.' . $name );144 $is_valid = rest_validate_value_from_schema( $meta[ $name ], $args['schema'], 'meta.' . $name ); 145 145 if ( is_wp_error( $is_valid ) ) { 146 146 $is_valid->add_data( array( 'status' => 400 ) ); … … 148 148 } 149 149 150 $value = rest_sanitize_value_from_schema( $ request[ $name ], $args['schema'] );150 $value = rest_sanitize_value_from_schema( $meta[ $name ], $args['schema'] ); 151 151 152 152 if ( $args['single'] ) { … … 392 392 'context' => array( 'view', 'edit' ), 393 393 'properties' => array(), 394 'arg_options' => array( 395 'sanitize_callback' => null, 396 'validate_callback' => array( $this, 'check_meta_is_array' ), 397 ), 394 398 ); 395 399 … … 445 449 return $value; 446 450 } 451 452 /** 453 * Check the 'meta' value of a request is an associative array. 454 * 455 * @since 4.7.0 456 * @access public 457 * 458 * @param mixed $value The meta value submitted in the request. 459 * @param WP_REST_Request $request Full details about the request. 460 * @param string $param The parameter name. 461 * @return WP_Error|string The meta array, if valid, otherwise an error. 462 */ 463 public function check_meta_is_array( $value, $request, $param ) { 464 if ( ! is_array( $value ) ) { 465 return false; 466 } 467 468 return $value; 469 } 447 470 }
Note: See TracChangeset
for help on using the changeset viewer.