Source View: update_postmeta

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

  • Action hooks look like this: do_action( "hook_name" )
  • Filter hooks look like this: apply_filters( "hook_name", "what_to_filter" ).

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
235                 * Fires immediately before updating a post's metadata.
236                 *
237                 * @since 2.9.0
238                 *
239                 * @param int    $meta_id    ID of metadata entry to update.
240                 * @param int    $object_id  Object ID.
241                 * @param string $meta_key   Meta key.
242                 * @param mixed  $meta_value Meta value.
243                 */
244                do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
245           }
246      }
247
248      $result = $wpdb->update( $table, $data, $where );
249      if ( ! $result )
250           return false;
251
252      wp_cache_delete($object_id, $meta_type . '_meta');
253
 
Line Code
652           // Format the where query arguments.
653           $where = array();
654           $where[$id_column] = $meta_id;
655
656           /** This action is documented in wp-includes/meta.php */
657           do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
658
659           if ( 'post' == $meta_type ) {
660                /** This action is documented in wp-includes/meta.php */
661                do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
662           }
663
664           // Run the update query, all fields in $data are %s, $where is a %d.
665           $result = $wpdb->update( $table, $data, $where, '%s', '%d' );
666           if ( ! $result )
667                return false;
668
669           // Clear the caches.
670           wp_cache_delete($object_id, $meta_type . '_meta');