Make WordPress Core

Ticket #9004: term-sort.diff

File term-sort.diff, 2.2 KB (added by jhodgdon, 16 years ago)

Patch that adds filters for custom term sorting (patch is relative to the wp-includes directory)

  • category-template.php

     
    611611 * 'format' argument will format the tags in a UL HTML list. The array value for
    612612 * the 'format' argument will return in PHP array type format.
    613613 *
     614 * The 'tag_cloud_sort' filter allows you to override the sorting done
     615 * by the 'orderby' argument; passed to the filter: $tags array and $args array.
     616 *
    614617 * The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'.
    615618 * The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC' or
    616619 * 'RAND'.
     
    656659        else
    657660                uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);') );
    658661
     662        $tags = apply_filters( 'tag_cloud_sort', $tags, $args );
     663   
    659664        if ( 'DESC' == $order )
    660665                $tags = array_reverse( $tags, true );
    661666        elseif ( 'RAND' == $order ) {
  • taxonomy.php

     
    520520 * The 'list_terms_exclusions' filter passes the compiled exclusions along with
    521521 * the $args.
    522522 *
     523 * The 'get_terms_orderby' filter passes the ORDER BY clause for the query
     524 * along with the $args array.
     525
     526 * The 'get_terms_fields' filter passes the fields for the SELECT query
     527 * along with the $args array.
     528 *
    523529 * The list of arguments that $args can contain, which will overwrite the defaults:
    524530 *
    525531 * orderby - Default is 'name'. Can be name, count, or nothing (will use
     
    667673                $orderby = 't.term_group';
    668674        else
    669675                $orderby = 't.term_id';
     676        $orderby = apply_filters( 'get_terms_orderby', $orderby, $args );
    670677
    671678        $where = '';
    672679        $inclusions = '';
     
    758765                $select_this = 't.term_id, tt.parent, tt.count';
    759766        else if ( 'names' == $fields )
    760767                $select_this = 't.term_id, tt.parent, tt.count, t.name';
     768        $select_this = apply_filters( 'get_terms_fields', $select_this, $args );
    761769
    762770        $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";
    763771