Make WordPress Core

Changeset 15654


Ignore:
Timestamp:
09/24/2010 02:08:07 PM (14 years ago)
Author:
scribu
Message:

get_objects_in_term(): include term children when querying by slug. See #12891

File:
1 edited

Legend:

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

    r15631 r15654  
    472472        $operator = 'IN';
    473473
     474    if ( is_taxonomy_hierarchical( $taxonomy ) && $include_children ) {
     475        $children = array();
     476        foreach ( $terms as $term ) {
     477            if ( 'term_id' != $field ) {
     478                if ( $term = get_term_by( $field, $term, $taxonomy ) )
     479                    $term = $term->term_id;
     480                else
     481                    continue;                   
     482            }
     483            $children = array_merge( $children, get_term_children( $term, $taxonomy ) );
     484            $children[] = $term;
     485        }
     486        $terms = $children;
     487        $field = 'term_id';
     488    }
     489
    474490    $taxonomies = "'" . implode( "', '", $taxonomies ) . "'";
    475491
     
    477493        case 'term_id':
    478494            $terms = array_map( 'intval', $terms );
    479 
    480             if ( is_taxonomy_hierarchical( $taxonomy ) && $include_children ) {
    481                 $children = $terms;
    482                 foreach ( $terms as $term )
    483                     $children = array_merge( $children, get_term_children( $term, $taxonomy ) );
    484                 $terms = $children;
    485             }
    486495
    487496            $terms = implode( ',', $terms );
Note: See TracChangeset for help on using the changeset viewer.