Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: update_{$meta_type}_metadata

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.

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

Source View

Line Code
113      $column = sanitize_key($meta_type . '_id');
114      $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
115
116      // expected_slashed ($meta_key)
117      $meta_key = wp_unslash($meta_key);
118      $passed_value = $meta_value;
119      $meta_value = wp_unslash($meta_value);
120      $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type );
121
122      $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
123      if ( null !== $check )
124           return (bool) $check;
125
126      // Compare existing value to new value if no prev value given and the key exists only once.
127      if ( empty($prev_value) ) {
128           $old_value = get_metadata($meta_type, $object_id, $meta_key);
129           if ( count($old_value) == 1 ) {
130                if ( $old_value[0] === $meta_value )
131                     return false;