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
1350           /**
1351            * Filter the given taxonomy's terms cache.
1352            *
1353            * @since 2.3.0
1354            *
1355            * @param array        $cache      Cached array of terms for the given taxonomy.
1356            * @param string|array $taxonomies A taxonomy or array of taxonomies.
1357            * @param array        $args       An array of arguments to get terms.
1358            */
1359           $cache = apply_filters( 'get_terms', $cache, $taxonomies, $args );
1360           return $cache;
1361      }
1362
1363      $_orderby = strtolower($orderby);
1364      if ( 'count' == $_orderby )
1365           $orderby = 'tt.count';
1366      else if ( 'name' == $_orderby )
1367           $orderby = 't.name';
1368      else if ( 'slug' == $_orderby )
 
Line Code
1555      $terms = $wpdb->get_results($query);
1556      if ( 'all' == $fields ) {
1557           update_term_cache($terms);
1558      }
1559
1560      if ( empty($terms) ) {
1561           wp_cache_add( $cache_key, array(), 'terms', DAY_IN_SECONDS );
1562
1563           /** This filter is documented in wp-includes/taxonomy.php */
1564           $terms = apply_filters( 'get_terms', array(), $taxonomies, $args );
1565           return $terms;
1566      }
1567
1568      if ( $child_of ) {
1569           $children = _get_term_hierarchy( reset( $taxonomies ) );
1570           if ( ! empty( $children ) )
1571                $terms = _get_term_children( $child_of, $terms, reset( $taxonomies ) );
1572      }
1573
 
Line Code
1617      if ( ! empty( $_terms ) )
1618           $terms = $_terms;
1619
1620      if ( $number && is_array( $terms ) && count( $terms ) > $number )
1621           $terms = array_slice( $terms, $offset, $number );
1622
1623      wp_cache_add( $cache_key, $terms, 'terms', DAY_IN_SECONDS );
1624
1625      /** This filter is documented in wp-includes/taxonomy */
1626      $terms = apply_filters( 'get_terms', $terms, $taxonomies, $args );
1627      return $terms;
1628 }
1629
1630 /**
1631  * Check if Term exists.
1632  *
1633  * Formerly is_term(), introduced in 2.3.0.
1634  *
1635  * @since 3.0.0