WordPress.org

Make WordPress Core

Changeset 11457


Ignore:
Timestamp:
05/25/2009 06:18:06 PM (9 years ago)
Author:
ryan
Message:

Add orderby = none option to wp_get_object_terms(). Props vladimir_kolesnikov. fixes #9937

File:
1 edited

Legend:

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

    r11450 r11457  
    11441144
    11451145    foreach ( (array) $objects as $object ) {
    1146         $terms = wp_get_object_terms($object, $taxonomy, 'fields=ids');
     1146        $terms = wp_get_object_terms($object, $taxonomy, array('fields' => 'ids', 'orderby' => 'none'));
    11471147        if ( 1 == count($terms) && isset($default) ) {
    11481148            $terms = array($default);
     
    12471247    else if ( 'term_order' == $orderby )
    12481248        $orderby = 'tr.term_order';
    1249     else
     1249    else if ( 'none' == $orderby ) {
     1250        $orderby = '';
     1251        $order = '';
     1252    } else {
    12501253        $orderby = 't.term_id';
     1254    }
     1255
     1256    if ( !empty($orderby) )
     1257        $orderby = "ORDER BY $orderby";
    12511258
    12521259    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
     
    12631270        $select_this = 't.*, tt.*, tr.object_id';
    12641271
    1265     $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tr.object_id IN ($object_ids) ORDER BY $orderby $order";
     1272    $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tr.object_id IN ($object_ids) $orderby $order";
    12661273
    12671274    if ( 'all' == $fields || 'all_with_object_id' == $fields ) {
     
    12711278        $terms = array_merge($terms, $wpdb->get_col($query));
    12721279    } else if ( 'tt_ids' == $fields ) {
    1273         $terms = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) ORDER BY tr.term_taxonomy_id $order");
     1280        if ( !empty($order_by) )
     1281            $orderby = "ORDER BY tr.term_taxonomy_id";
     1282        $terms = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) $orderby $order");
    12741283    }
    12751284
     
    14451454
    14461455    if ( ! $append )
    1447         $old_tt_ids =  wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
     1456        $old_tt_ids =  wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids', 'orderby' => 'none'));
    14481457
    14491458    $tt_ids = array();
Note: See TracChangeset for help on using the changeset viewer.