get_term_metadata
Short-circuits the return value of a meta field.
Possible filter names include:
Это один из вариантов динамического хука get_(meta_type)_metadata
Использование
add_filter( 'get_term_metadata', 'wp_kama_get_term_metadata_filter', 10, 5 ); /** * Function for `get_term_metadata` filter-hook. * * @param mixed $value The value to return, either a single metadata value or an array of values depending on the value of `$single`. * @param int $object_id ID of the object metadata is for. * @param string $meta_key Metadata key. * @param bool $single Whether to return only the first value of the specified `$meta_key`. * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', or any other object type with an associated meta table. * * @return mixed */ function wp_kama_get_term_metadata_filter( $value, $object_id, $meta_key, $single, $meta_type ){ // filter... return $value; }
- $value(разное)
- The value to return, either a single metadata value or an array of values depending on the value of $single.
По умолчанию: null - $object_id(int)
- ID of the object metadata is for.
- $meta_key(строка)
- Metadata key.
- $single(true|false)
- Whether to return only the first value of the specified $meta_key.
- $meta_type(строка)
- Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', or any other object type with an associated meta table.
Список изменений
С версии 3.1.0 | Введена. |
С версии 5.5.0 | Added the $meta_type parameter. |
Где вызывается хук
wp-includes/meta.php 636
$check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single, $meta_type );
Где используется хук в WordPress
wp-includes/default-filters.php 136
add_filter( 'get_term_metadata', 'wp_check_term_meta_support_prefilter' );