Make WordPress Core

Ticket #9004: get_terms_fields_as_array.9004.diff

File get_terms_fields_as_array.9004.diff, 2.6 KB (added by filosofo, 16 years ago)
  • wp-includes/taxonomy.php

     
    526526 * The 'list_terms_exclusions' filter passes the compiled exclusions along with
    527527 * the $args.
    528528 *
     529 * The 'get_terms_orderby' filter passes the ORDER BY clause for the query
     530 * along with the $args array.
     531
     532 * The 'get_terms_fields' filter passes the fields for the SELECT query
     533 * along with the $args array.
     534 *
    529535 * The list of arguments that $args can contain, which will overwrite the defaults:
    530536 *
    531537 * orderby - Default is 'name'. Can be name, count, or nothing (will use
     
    673679                $orderby = 't.term_group';
    674680        else
    675681                $orderby = 't.term_id';
     682        $orderby = apply_filters( 'get_terms_orderby', $orderby, $args );
    676683
    677684        $where = '';
    678685        $inclusions = '';
     
    757764                $where .= " AND (t.name LIKE '%$search%')";
    758765        }
    759766
    760         $select_this = '';
     767        $selects = array();
    761768        if ( 'all' == $fields )
    762                 $select_this = 't.*, tt.*';
     769                $selects = array('t.*', 'tt.*');
    763770        else if ( 'ids' == $fields )
    764                 $select_this = 't.term_id, tt.parent, tt.count';
     771                $selects = array('t.term_id', 'tt.parent', 'tt.count');
    765772        else if ( 'names' == $fields )
    766                 $select_this = 't.term_id, tt.parent, tt.count, t.name';
     773                $selects = array('t.term_id', 'tt.parent', 'tt.count', 't.name');
     774        $select_this = implode(', ', apply_filters( 'get_terms_fields', $selects, $args ));
    767775
    768776        $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";
    769777
  • wp-includes/category-template.php

     
    573573 * 'format' argument will format the tags in a UL HTML list. The array value for
    574574 * the 'format' argument will return in PHP array type format.
    575575 *
     576 * The 'tag_cloud_sort' filter allows you to override the sorting done
     577 * by the 'orderby' argument; passed to the filter: $tags array and $args array.
     578 *
    576579 * The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'.
    577580 * The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC' or
    578581 * 'RAND'.
     
    618621        else
    619622                uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);') );
    620623
     624        $tags = apply_filters( 'tag_cloud_sort', $tags, $args );
     625   
    621626        if ( 'DESC' == $order )
    622627                $tags = array_reverse( $tags, true );
    623628        elseif ( 'RAND' == $order ) {