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
577      if ( $parent ) {
578           $hierarchy = _get_term_hierarchy($taxonomies[0]);
579           if ( !isset($hierarchy[$parent]) )
580                return $empty_array;
581      }
582
583      $key = md5( serialize( $args ) . serialize( $taxonomies ) );
584      if ( $cache = wp_cache_get( 'get_terms', 'terms' ) ) {
585           if ( isset( $cache[ $key ] ) )
586                return apply_filters('get_terms', $cache[$key], $taxonomies, $args);
587      }
588
589      if ( 'count' == $orderby )
590           $orderby = 'tt.count';
591      else if ( 'name' == $orderby )
592           $orderby = 't.name';
593      else if ( 'slug' == $orderby )
594           $orderby = 't.slug';
595      else if ( 'term_group' == $orderby )
 
Line Code
678           $terms = $wpdb->get_results($query);
679           update_term_cache($terms);
680      } else if ( ('ids' == $fields) || ('names' == $fields) ) {
681           $terms = $wpdb->get_col($query);
682      }
683
684      if ( empty($terms) ) {
685           $cache[ $key ] = array();
686           wp_cache_set( 'get_terms', $cache, 'terms' );
687           return apply_filters('get_terms', array(), $taxonomies, $args);
688      }
689
690      if ( $child_of || $hierarchical ) {
691           $children = _get_term_hierarchy($taxonomies[0]);
692           if ( ! empty($children) )
693                $terms = & _get_term_children($child_of, $terms, $taxonomies[0]);
694      }
695
696      // Update term counts to include children.
 
Line Code
710                     unset($terms[$k]);
711                }
712           }
713      }
714      reset ( $terms );
715
716      $cache[ $key ] = $terms;
717      wp_cache_set( 'get_terms', $cache, 'terms' );
718
719      $terms = apply_filters('get_terms', $terms, $taxonomies, $args);
720      return $terms;
721 }
722
723 /**
724  * is_term() - Check if Term exists
725  *
726  * Returns the index of a defined term, or 0 (false) if the term doesn't exist.
727  *
728  * @package WordPress