update_(meta_type)_metadata хук-фильтрWP 3.1.0

Short-circuits updating metadata of a specific type.

The dynamic portion of the hook name, $meta_type, refers to the meta object type (post, comment, term, user, or any other type with an associated meta table). Returning a non-null value will effectively short-circuit the function.

Possible hook names include:

Использование

add_filter( 'update_(meta_type)_metadata', 'wp_kama_update_meta_type_metadata_filter', 10, 5 );

/**
 * Function for `update_(meta_type)_metadata` filter-hook.
 * 
 * @param null|bool $check      Whether to allow updating metadata for the given type.
 * @param int       $object_id  ID of the object metadata is for.
 * @param string    $meta_key   Metadata key.
 * @param mixed     $meta_value Metadata value. Must be serializable if non-scalar.
 * @param mixed     $prev_value Optional. Previous value to check before updating. If specified, only update existing metadata entries with this value. Otherwise, update all entries.
 *
 * @return null|bool
 */
function wp_kama_update_meta_type_metadata_filter( $check, $object_id, $meta_key, $meta_value, $prev_value ){

	// filter...
	return $check;
}
$check(null|true|false)
Whether to allow updating metadata for the given type.
$object_id(int)
ID of the object metadata is for.
$meta_key(строка)
Metadata key.
$meta_value(разное)
Metadata value. Must be serializable if non-scalar.
$prev_value(разное)
Optional. Previous value to check before updating. If specified, only update existing metadata entries with this value. Otherwise, update all entries.

Список изменений

С версии 3.1.0 Введена.

Где вызывается хук

update_metadata()
update_(meta_type)_metadata
wp-includes/meta.php 233
$check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );

Где используется хук в WordPress

wp-includes/default-filters.php 124
add_filter( 'update_term_metadata', 'wp_check_term_meta_support_prefilter' );
wp-includes/ms-default-filters.php 63
add_filter( 'update_blog_metadata', 'wp_check_site_meta_support_prefilter' );