WordPress.org

Make WordPress Core

Changeset 11037


Ignore:
Timestamp:
04/21/09 22:13:44 (5 years ago)
Author:
ryan
Message:

get_terms_orderby, get_terms_fields, and tag_clooud-sort filters. Props jhodgdon, filosofo. fixes #9004

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/category-template.php

    r10946 r11037  
    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 
     
    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 ); 
  • trunk/wp-includes/taxonomy.php

    r11013 r11037  
    526526 * The 'list_terms_exclusions' filter passes the compiled exclusions along with 
    527527 * the $args. 
     528 * 
     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. 
    528534 * 
    529535 * The list of arguments that $args can contain, which will overwrite the defaults: 
     
    674680    else 
    675681        $orderby = 't.term_id'; 
     682        $orderby = apply_filters( 'get_terms_orderby', $orderby, $args ); 
    676683 
    677684    $where = ''; 
     
    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"; 
Note: See TracChangeset for help on using the changeset viewer.