Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: get_terms

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 3 times in this file.

Line Code
1309      $key = md5( serialize( compact(array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key );
1310      $last_changed = wp_cache_get( 'last_changed', 'terms' );
1311      if ( ! $last_changed ) {
1312           $last_changed = microtime();
1313           wp_cache_set( 'last_changed', $last_changed, 'terms' );
1314      }
1315      $cache_key = "get_terms:$key:$last_changed";
1316      $cache = wp_cache_get( $cache_key, 'terms' );
1317      if ( false !== $cache ) {
1318           $cache = apply_filters('get_terms', $cache, $taxonomies, $args);
1319           return $cache;
1320      }
1321
1322      $_orderby = strtolower($orderby);
1323      if ( 'count' == $_orderby )
1324           $orderby = 'tt.count';
1325      else if ( 'name' == $_orderby )
1326           $orderby = 't.name';
1327      else if ( 'slug' == $_orderby )
 
Line Code
1475      }
1476
1477      $terms = $wpdb->get_results($query);
1478      if ( 'all' == $fields ) {
1479           update_term_cache($terms);
1480      }
1481
1482      if ( empty($terms) ) {
1483           wp_cache_add( $cache_key, array(), 'terms', DAY_IN_SECONDS );
1484           $terms = apply_filters('get_terms', array(), $taxonomies, $args);
1485           return $terms;
1486      }
1487
1488      if ( $child_of ) {
1489           $children = _get_term_hierarchy( reset( $taxonomies ) );
1490           if ( ! empty( $children ) )
1491                $terms = _get_term_children( $child_of, $terms, reset( $taxonomies ) );
1492      }
1493
 
Line Code
1532
1533      if ( ! empty( $_terms ) )
1534           $terms = $_terms;
1535
1536      if ( $number && is_array( $terms ) && count( $terms ) > $number )
1537           $terms = array_slice( $terms, $offset, $number );
1538
1539      wp_cache_add( $cache_key, $terms, 'terms', DAY_IN_SECONDS );
1540
1541      $terms = apply_filters( 'get_terms', $terms, $taxonomies, $args );
1542      return $terms;
1543 }
1544
1545 /**
1546  * Check if Term exists.
1547  *
1548  * Formerly is_term(), introduced in 2.3.0.
1549  *
1550  * @package WordPress