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
1248      $key = md5( serialize( compact(array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key );
1249      $last_changed = wp_cache_get( 'last_changed', 'terms' );
1250      if ( ! $last_changed ) {
1251           $last_changed = microtime();
1252           wp_cache_set( 'last_changed', $last_changed, 'terms' );
1253      }
1254      $cache_key = "get_terms:$key:$last_changed";
1255      $cache = wp_cache_get( $cache_key, 'terms' );
1256      if ( false !== $cache ) {
1257           $cache = apply_filters('get_terms', $cache, $taxonomies, $args);
1258           return $cache;
1259      }
1260
1261      $_orderby = strtolower($orderby);
1262      if ( 'count' == $_orderby )
1263           $orderby = 'tt.count';
1264      else if ( 'name' == $_orderby )
1265           $orderby = 't.name';
1266      else if ( 'slug' == $_orderby )
 
Line Code
1405      }
1406
1407      $terms = $wpdb->get_results($query);
1408      if ( 'all' == $fields ) {
1409           update_term_cache($terms);
1410      }
1411
1412      if ( empty($terms) ) {
1413           wp_cache_add( $cache_key, array(), 'terms', DAY_IN_SECONDS );
1414           $terms = apply_filters('get_terms', array(), $taxonomies, $args);
1415           return $terms;
1416      }
1417
1418      if ( $child_of ) {
1419           $children = _get_term_hierarchy($taxonomies[0]);
1420           if ( ! empty($children) )
1421                $terms = _get_term_children($child_of, $terms, $taxonomies[0]);
1422      }
1423
 
Line Code
1456                $_terms[] = $term->name;
1457           $terms = $_terms;
1458      }
1459
1460      if ( $number && is_array( $terms ) && count( $terms ) > $number )
1461           $terms = array_slice( $terms, $offset, $number );
1462
1463      wp_cache_add( $cache_key, $terms, 'terms', DAY_IN_SECONDS );
1464
1465      $terms = apply_filters('get_terms', $terms, $taxonomies, $args);
1466      return $terms;
1467 }
1468
1469 /**
1470  * Check if Term exists.
1471  *
1472  * Formerly is_term(), introduced in 2.3.0.
1473  *
1474  * @package WordPress