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
196       *
197       * @param null|bool $check      Whether to allow updating metadata for the given type.
198       * @param int       $object_id  ID of the object metadata is for.
199       * @param string    $meta_key   Metadata key.
200       * @param mixed     $meta_value Metadata value. Must be serializable if non-scalar.
201       * @param mixed     $prev_value Optional. Previous value to check before updating.
202       *                              If specified, only update existing metadata entries with
203       *                              this value. Otherwise, update all entries.
204       */
205      $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
206      if ( null !== $check ) {
207           return (bool) $check;
208      }
209
210      // Compare existing value to new value if no prev value given and the key exists only once.
211      if ( empty( $prev_value ) ) {
212           $old_value = get_metadata_raw( $meta_type, $object_id, $meta_key );
213           if ( is_countable( $old_value ) && count( $old_value ) === 1 ) {
214                if ( $old_value[0] === $meta_value ) {