Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r10417 r10159  
    535535 * 'exclude' is ignored.
    536536 *
    537  * exclude_tree - A comma- or space-delimited string of term ids to exclude
    538  * from the return array, along with all of their descendant terms according to
    539  * the primary taxonomy.  If 'include' is non-empty, 'exclude_tree' is ignored.
    540  *
    541537 * include - Default is an empty string.  A comma- or space-delimited string
    542538 * of term ids to include in the return array.
     
    609605
    610606    $defaults = array('orderby' => 'name', 'order' => 'ASC',
    611         'hide_empty' => true, 'exclude' => '', 'exclude_tree' => '', 'include' => '',
     607        'hide_empty' => true, 'exclude' => '', 'include' => '',
    612608        'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
    613609        'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '',
     
    673669    if ( !empty($include) ) {
    674670        $exclude = '';
    675         $exclude_tree = '';
    676671        $interms = preg_split('/[\s,]+/',$include);
    677672        if ( count($interms) ) {
     
    690685
    691686    $exclusions = '';
    692     if ( ! empty( $exclude_tree ) ) {
    693         $excluded_trunks = preg_split('/[\s,]+/',$exclude_tree);
    694         foreach( (array) $excluded_trunks as $extrunk ) {
    695             $excluded_children = (array) get_terms($taxonomies[0], array('child_of' => intval($extrunk), 'fields' => 'ids'));   
    696             $excluded_children[] = $extrunk;
    697             foreach( (array) $excluded_children as $exterm ) {
    698                 if ( empty($exclusions) )
    699                     $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' ';
    700                 else
    701                     $exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' ';
    702 
    703             }
    704         }
    705     }
    706687    if ( !empty($exclude) ) {
    707688        $exterms = preg_split('/[\s,]+/',$exclude);
    708689        if ( count($exterms) ) {
    709690            foreach ( (array) $exterms as $exterm ) {
    710                 if ( empty($exclusions) )
     691                if (empty($exclusions))
    711692                    $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' ';
    712693                else
     
    737718        $where .= ' AND tt.count > 0';
    738719
    739     // don't limit the query results when we have to descend the family tree
    740     if ( ! empty($number) && ! $hierarchical && empty( $child_of ) && '' == $parent ) {
     720    if ( !empty($number) ) {
    741721        if( $offset )
    742             $limit = 'LIMIT ' . $offset . ',' . $number;
     722            $number = 'LIMIT ' . $offset . ',' . $number;
    743723        else
    744             $limit = 'LIMIT ' . $number;
     724            $number = 'LIMIT ' . $number;
    745725
    746726    } else
    747         $limit = '';
     727        $number = '';
    748728
    749729    if ( !empty($search) ) {
     
    760740        $select_this = 't.term_id, tt.parent, tt.count, t.name';
    761741
    762     $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $limit";
    763 
    764     $terms = $wpdb->get_results($query);
     742    $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $number";
     743
    765744    if ( 'all' == $fields ) {
     745        $terms = $wpdb->get_results($query);
    766746        update_term_cache($terms);
     747    } else if ( ('ids' == $fields) || ('names' == $fields) ) {
     748        $terms = $wpdb->get_results($query);
    767749    }
    768750
     
    810792            $_terms[] = $term->name;
    811793        $terms = $_terms;
    812     }
    813 
    814     if ( 0 < $number && intval(@count($terms)) > $number ) {
    815         $terms = array_slice($terms, $offset, $number);
    816794    }
    817795
Note: See TracChangeset for help on using the changeset viewer.