WordPress.org

Make WordPress Core

Ticket #8214: 8214.001.diff

File 8214.001.diff, 4.6 KB (added by AaronCampbell, 10 years ago)

Adds descriptionlike arg to get_terms

  • trunk/wp-includes/taxonomy.php

     
    527527 *
    528528 * hide_empty - Default is true. Will not return empty terms, which means
    529529 * terms whose count is 0 according to the given taxonomy.
    530  * 
     530 *
    531531 * exclude - Default is an empty string.  A comma- or space-delimited string
    532  * of term ids to exclude from the return array.  If 'include' is non-empty, 
     532 * of term ids to exclude from the return array.  If 'include' is non-empty,
    533533 * 'exclude' is ignored.
    534534 *
    535535 * include - Default is an empty string.  A comma- or space-delimited string
    536536 * of term ids to include in the return array.
    537  * 
     537 *
    538538 * number - The maximum number of terms to return.  Default is empty.
    539  * 
     539 *
    540540 * offset - The number by which to offset the terms query.
    541541 *
    542  * fields - Default is 'all', which returns an array of term objects. 
     542 * fields - Default is 'all', which returns an array of term objects.
    543543 * If 'fields' is 'ids' or 'names', returns an array of
    544544 * integers or strings, respectively.
    545545 *
    546546 * slug - Returns terms whose "slug" matches this value. Default is empty string.
    547  * 
     547 *
    548548 * hierarchical - Whether to include terms that have non-empty descendants
    549549 * (even if 'hide_empty' is set to true).
    550  * 
     550 *
    551551 * search - Returned terms' names will contain the value of 'search',
    552552 * case-insensitive.  Default is an empty string.
    553553 *
     
    561561 * returns terms regardless of ancestry or whether the terms are empty.
    562562 *
    563563 * The 'child_of' argument, when used, should be set to the integer of a term ID.  Its default
    564  * is 0.  If set to a non-zero value, all returned terms will be descendants 
    565  * of that term according to the given taxonomy.  Hence 'child_of' is set to 0 
    566  * if more than one taxonomy is passed in $taxonomies, because multiple taxonomies 
     564 * is 0.  If set to a non-zero value, all returned terms will be descendants
     565 * of that term according to the given taxonomy.  Hence 'child_of' is set to 0
     566 * if more than one taxonomy is passed in $taxonomies, because multiple taxonomies
    567567 * make term ancestry ambiguous.
    568568 *
    569569 * The 'parent' argument, when used, should be set to the integer of a term ID.  Its default is
    570570 * the empty string '', which has a different meaning from the integer 0.
    571  * If set to an integer value, all returned terms will have as an immediate 
     571 * If set to an integer value, all returned terms will have as an immediate
    572572 * ancestor the term whose ID is specified by that integer according to the given taxonomy.
    573573 * The 'parent' argument is different from 'child_of' in that a term X is considered a 'parent'
    574574 * of term Y only if term X is the father of term Y, not its grandfather or great-grandfather, etc.
     
    605605                'hide_empty' => true, 'exclude' => '', 'include' => '',
    606606                'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
    607607                'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '',
    608                 'pad_counts' => false, 'offset' => '', 'search' => '');
     608                'description__like'=>'', 'pad_counts' => false, 'offset' => '',
     609                'search' => '');
    609610        $args = wp_parse_args( $args, $defaults );
    610611        $args['number'] = absint( $args['number'] );
    611612        $args['offset'] = absint( $args['offset'] );
     
    707708        if ( !empty($name__like) )
    708709                $where .= " AND t.name LIKE '{$name__like}%'";
    709710
     711        if ( !empty($description__like) )
     712                $where .= " AND tt.description LIKE '{$description__like}%'";
     713
    710714        if ( '' != $parent ) {
    711715                $parent = (int) $parent;
    712716                $where .= " AND tt.parent = '$parent'";
     
    779783                }
    780784        }
    781785        reset ( $terms );
    782        
     786
    783787        $_terms = array();
    784788        if ( 'ids' == $fields ) {
    785789                while ( $term = array_shift($terms) )
     
    19451949 * @param int $term_id The ancestor term: all returned terms should be descendants of $term_id.
    19461950 * @param array $terms The set of terms---either an array of term objects or term IDs---from which those that are descendants of $term_id will be chosen.
    19471951 * @param string $taxonomy The taxonomy which determines the hierarchy of the terms.
    1948  * @return array The subset of $terms that are descendants of $term_id. 
     1952 * @return array The subset of $terms that are descendants of $term_id.
    19491953 */
    19501954function &_get_term_children($term_id, $terms, $taxonomy) {
    19511955        $empty_array = array();
     
    20292033                $id = $term_ids[$row->term_taxonomy_id];
    20302034                $term_items[$id][$row->object_id] = isset($term_items[$id][$row->object_id]) ? ++$term_items[$id][$row->object_id] : 1;
    20312035        }
    2032        
     2036
    20332037        // Touch every ancestor's lookup row for each post in each term
    20342038        foreach ( $term_ids as $term_id ) {
    20352039                $child = $term_id;