- Timestamp:
- 11/09/2016 03:41:07 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php
r39058 r39179 123 123 public function update_value( $request, $object_id ) { 124 124 $fields = $this->get_registered_fields(); 125 126 125 foreach ( $fields as $name => $args ) { 127 126 if ( ! array_key_exists( $name, $request ) ) { … … 160 159 */ 161 160 protected function delete_meta_value( $object_id, $name ) { 162 if ( ! current_user_can( 'delete_post_meta', $object_id, $name ) ) { 161 $meta_type = $this->get_meta_type(); 162 if ( ! current_user_can( "delete_{$meta_type}_meta", $object_id, $name ) ) { 163 163 return new WP_Error( 164 164 'rest_cannot_delete', … … 168 168 } 169 169 170 if ( ! delete_metadata( $ this->get_meta_type(), $object_id, wp_slash( $name ) ) ) {170 if ( ! delete_metadata( $meta_type, $object_id, wp_slash( $name ) ) ) { 171 171 return new WP_Error( 172 172 'rest_meta_database_error', … … 193 193 */ 194 194 protected function update_multi_meta_value( $object_id, $name, $values ) { 195 if ( ! current_user_can( 'edit_post_meta', $object_id, $name ) ) { 195 $meta_type = $this->get_meta_type(); 196 if ( ! current_user_can( "edit_{$meta_type}_meta", $object_id, $name ) ) { 196 197 return new WP_Error( 197 198 'rest_cannot_update', … … 201 202 } 202 203 203 $current = get_metadata( $ this->get_meta_type(), $object_id, $name, false );204 $current = get_metadata( $meta_type, $object_id, $name, false ); 204 205 205 206 $to_remove = $current; … … 228 229 229 230 foreach ( $to_remove as $value ) { 230 if ( ! delete_metadata( $ this->get_meta_type(), $object_id, wp_slash( $name ), wp_slash( $value ) ) ) {231 if ( ! delete_metadata( $meta_type, $object_id, wp_slash( $name ), wp_slash( $value ) ) ) { 231 232 return new WP_Error( 232 233 'rest_meta_database_error', … … 238 239 239 240 foreach ( $to_add as $value ) { 240 if ( ! add_metadata( $ this->get_meta_type(), $object_id, wp_slash( $name ), wp_slash( $value ) ) ) {241 if ( ! add_metadata( $meta_type, $object_id, wp_slash( $name ), wp_slash( $value ) ) ) { 241 242 return new WP_Error( 242 243 'rest_meta_database_error', … … 262 263 */ 263 264 protected function update_meta_value( $object_id, $name, $value ) { 264 if ( ! current_user_can( 'edit_post_meta', $object_id, $name ) ) { 265 $meta_type = $this->get_meta_type(); 266 if ( ! current_user_can( "edit_{$meta_type}_meta", $object_id, $name ) ) { 265 267 return new WP_Error( 266 268 'rest_cannot_update', … … 270 272 } 271 273 272 $meta_type = $this->get_meta_type();273 274 $meta_key = wp_slash( $name ); 274 275 $meta_value = wp_slash( $value );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)