get_terms хук-фильтрWP 2.3.0

Filters the found terms.

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

add_filter( 'get_terms', 'wp_kama_get_terms_filter', 10, 4 );

/**
 * Function for `get_terms` filter-hook.
 * 
 * @param array         $terms      Array of found terms.
 * @param array|null    $taxonomies An array of taxonomies if known.
 * @param array         $args       An array of get_terms() arguments.
 * @param WP_Term_Query $term_query The WP_Term_Query object.
 *
 * @return array
 */
function wp_kama_get_terms_filter( $terms, $taxonomies, $args, $term_query ){

	// filter...
	return $terms;
}
$terms(массив)
Array of found terms.
$taxonomies(массив|null)
An array of taxonomies if known.
$args(массив)
An array of get_terms() arguments.
$term_query(WP_Term_Query)
The WP_Term_Query object.

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

С версии 2.3.0 Введена.
С версии 4.6.0 Added the $term_query parameter.

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

get_terms()
get_terms
wp-includes/taxonomy.php 1330
return apply_filters( 'get_terms', $terms, $term_query->query_vars['taxonomy'], $term_query->query_vars, $term_query );

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

wp-includes/default-filters.php 547
add_filter( 'get_terms', '_post_format_get_terms', 10, 3 );