add_blog_metadata
Short-circuits adding metadata of a specific type.
Это один из вариантов динамического хука add_(meta_type)_metadata
Использование
add_filter( 'add_blog_metadata', 'wp_kama_add_blog_metadata_filter', 10, 5 );
/**
* Function for `add_blog_metadata` filter-hook.
*
* @param null|int|false $check Whether to allow adding metadata for the given type. Return false or a meta ID to short-circuit the function. Return null to continue with the default behavior.
* @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 bool $unique Whether the specified meta key should be unique for the object.
*
* @return null|int|false
*/
function wp_kama_add_blog_metadata_filter( $check, $object_id, $meta_key, $meta_value, $unique ){
// filter...
return $check;
}
- $check(null|int|false)
- Whether to allow adding metadata for the given type. Return false or a meta ID to short-circuit the function. Return null to continue with the default behavior.
- $object_id(int)
- ID of the object metadata is for.
- $meta_key(строка)
- Metadata key.
- $meta_value(разное)
- Metadata value. Must be serializable if non-scalar.
- $unique(true|false)
- Whether the specified meta key should be unique for the object.
Список изменений
| С версии 3.1.0 | Введена. |
Где вызывается хук
add_blog_metadata
wp-includes/meta.php 90
$check = apply_filters( "add_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $unique );
Где используется хук в WordPress
wp-includes/ms-default-filters.php 62
add_filter( 'add_blog_metadata', 'wp_check_site_meta_support_prefilter' );