WordPress.org

Make WordPress Core

Changeset 6851


Ignore:
Timestamp:
02/14/08 17:17:57 (7 years ago)
Author:
ryan
Message:

Support ordering for term relationships. Props andy. fixes #5857

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/schema.php

    r6825 r6851  
    3232 object_id bigint(20) NOT NULL default 0, 
    3333 term_taxonomy_id bigint(20) NOT NULL default 0, 
     34 term_order int(11) NOT NULL default 0, 
    3435 PRIMARY KEY  (object_id,term_taxonomy_id), 
    3536 KEY term_taxonomy_id (term_taxonomy_id) 
  • trunk/wp-includes/taxonomy.php

    r6843 r6851  
    10341034    else if ( 'term_group' == $orderby ) 
    10351035        $orderby = 't.term_group'; 
     1036    else if ( 'term_order' == $orderby ) 
     1037        $orderby = 'tr.term_order'; 
    10361038    else 
    10371039        $orderby = 't.term_id'; 
     
    12481250            wp_update_term_count($delete_terms, $taxonomy); 
    12491251        } 
     1252    } 
     1253 
     1254    $t = get_taxonomy($taxonomy); 
     1255    if ( ! $append && $t->sort ) { 
     1256        $values = array(); 
     1257        $term_order = 0; 
     1258        $final_term_ids = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids'); 
     1259        foreach ( $term_ids as $term_id ) 
     1260            if ( in_array($term_id, $final_term_ids) ) 
     1261                $values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $term_id, ++$term_order); 
     1262        if ( $values ) 
     1263            $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)"); 
    12501264    } 
    12511265 
  • trunk/wp-includes/version.php

    r6825 r6851  
    1717 * @global int $wp_db_version 
    1818 */ 
    19 $wp_db_version = 6825; 
     19$wp_db_version = 6846; 
    2020 
    2121?> 
Note: See TracChangeset for help on using the changeset viewer.