| | 325 | * Update meta data by meta ID |
| | 326 | * |
| | 327 | * @since 3.3.0 |
| | 328 | * |
| | 329 | * @uses update_metadata() Calls update_metadata() to actually update the meta value after |
| | 330 | * the meta_key, object_id and prev_value are fetched. |
| | 331 | * @uses get_metadata_by_mid() Calls get_metadata_by_mid() to fetch the meta key, value |
| | 332 | * and object_id of the given meta_id. |
| | 333 | * |
| | 334 | * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) |
| | 335 | * @param int $meta_id ID for a specific meta row |
| | 336 | * @param string $meta_value Metadata value |
| | 337 | * @return bool True on successful update, false on failure. |
| | 338 | */ |
| | 339 | function update_metadata_by_mid( $meta_type, $meta_id, $meta_value ) { |
| | 340 | if ( ! $meta_type ) |
| | 341 | return false; |
| | 342 | |
| | 343 | $column = esc_sql($meta_type . '_id'); |
| | 344 | |
| | 345 | // Fetch the meta key, value and object_id by the given meta_id. |
| | 346 | if ( $meta = get_metadata_by_mid( $meta_type, $meta_id ) ) { |
| | 347 | $object_id = $meta->{$column}; |
| | 348 | $meta_key = $meta->meta_key; |
| | 349 | $prev_value = $meta->meta_value; |
| | 350 | |
| | 351 | // If the meta was found, update it. |
| | 352 | return update_metadata( $meta_type, $object_id, $meta_key, $meta_value, $prev_value ); |
| | 353 | } |
| | 354 | |
| | 355 | return false; |
| | 356 | } |
| | 357 | |
| | 358 | /** |