Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: get_term

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 2 times in this file.

Line Code
525           $term = (int) $term;
526           if ( ! $_term = wp_cache_get($term, $taxonomy) ) {
527                $_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %s LIMIT 1", $taxonomy, $term) );
528                if ( ! $_term )
529                     return $null;
530                wp_cache_add($term, $_term, $taxonomy);
531           }
532      }
533
534      $_term = apply_filters('get_term', $_term, $taxonomy);
535      $_term = apply_filters("get_$taxonomy", $_term, $taxonomy);
536      $_term = sanitize_term($_term, $taxonomy, $filter);
537
538      if ( $output == OBJECT ) {
539           return $_term;
540      } elseif ( $output == ARRAY_A ) {
541           $__term = get_object_vars($_term);
542           return $__term;
543      } elseif ( $output == ARRAY_N ) {
 
Line Code
594           return get_term( (int) $value, $taxonomy, $output, $filter);
595      }
596
597      $term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND $field = %s LIMIT 1", $taxonomy, $value) );
598      if ( !$term )
599           return false;
600
601      wp_cache_add($term->term_id, $term, $taxonomy);
602
603      $term = apply_filters('get_term', $term, $taxonomy);
604      $term = apply_filters("get_$taxonomy", $term, $taxonomy);
605      $term = sanitize_term($term, $taxonomy, $filter);
606
607      if ( $output == OBJECT ) {
608           return $term;
609      } elseif ( $output == ARRAY_A ) {
610           return get_object_vars($term);
611      } elseif ( $output == ARRAY_N ) {
612           return array_values(get_object_vars($term));