WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )apply_filters( "hook_name", "what_to_filter" ).Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 3 times in this file.
| Line | Code |
|---|---|
| 1311 | $key = md5( serialize( compact(array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key ); |
| 1312 | $last_changed = wp_cache_get( 'last_changed', 'terms' ); |
| 1313 | if ( ! $last_changed ) { |
| 1314 | $last_changed = microtime(); |
| 1315 | wp_cache_set( 'last_changed', $last_changed, 'terms' ); |
| 1316 | } |
| 1317 | $cache_key = "get_terms:$key:$last_changed"; |
| 1318 | $cache = wp_cache_get( $cache_key, 'terms' ); |
| 1319 | if ( false !== $cache ) { |
| 1320 | $cache = apply_filters('get_terms', $cache, $taxonomies, $args); |
| 1321 | return $cache; |
| 1322 | } |
| 1323 | |
| 1324 | $_orderby = strtolower($orderby); |
| 1325 | if ( 'count' == $_orderby ) |
| 1326 | $orderby = 'tt.count'; |
| 1327 | else if ( 'name' == $_orderby ) |
| 1328 | $orderby = 't.name'; |
| 1329 | else if ( 'slug' == $_orderby ) |
| Line | Code |
| 1477 | } |
| 1478 | |
| 1479 | $terms = $wpdb->get_results($query); |
| 1480 | if ( 'all' == $fields ) { |
| 1481 | update_term_cache($terms); |
| 1482 | } |
| 1483 | |
| 1484 | if ( empty($terms) ) { |
| 1485 | wp_cache_add( $cache_key, array(), 'terms', DAY_IN_SECONDS ); |
| 1486 | $terms = apply_filters('get_terms', array(), $taxonomies, $args); |
| 1487 | return $terms; |
| 1488 | } |
| 1489 | |
| 1490 | if ( $child_of ) { |
| 1491 | $children = _get_term_hierarchy( reset( $taxonomies ) ); |
| 1492 | if ( ! empty( $children ) ) |
| 1493 | $terms = _get_term_children( $child_of, $terms, reset( $taxonomies ) ); |
| 1494 | } |
| 1495 | |
| Line | Code |
| 1534 | |
| 1535 | if ( ! empty( $_terms ) ) |
| 1536 | $terms = $_terms; |
| 1537 | |
| 1538 | if ( $number && is_array( $terms ) && count( $terms ) > $number ) |
| 1539 | $terms = array_slice( $terms, $offset, $number ); |
| 1540 | |
| 1541 | wp_cache_add( $cache_key, $terms, 'terms', DAY_IN_SECONDS ); |
| 1542 | |
| 1543 | $terms = apply_filters( 'get_terms', $terms, $taxonomies, $args ); |
| 1544 | return $terms; |
| 1545 | } |
| 1546 | |
| 1547 | /** |
| 1548 | * Check if Term exists. |
| 1549 | * |
| 1550 | * Formerly is_term(), introduced in 2.3.0. |
| 1551 | * |
| 1552 | * @package WordPress |