WordPress.org

Make WordPress Core

Changeset 5590


Ignore:
Timestamp:
05/29/07 04:54:45 (7 years ago)
Author:
markjaquith
Message:

switch to term_id and name for category sorting. see #4189. sort by term_id for category permalinks, by name for get_the_category(). fixes #4335 for trunk. Props Erik Barzeski for the find.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r5568 r5590  
    7070 
    7171    if ( !empty($categories) ) 
    72         usort($categories, '_get_the_category_usort'); 
     72        usort($categories, '_usort_terms_by_name'); 
    7373    else 
    7474        $categories = array(); 
     
    7777} 
    7878 
    79 function _get_the_category_usort($a, $b) { 
    80     return strcmp($a->category_name, $b->category_name); 
     79function _usort_terms_by_name($a, $b) { 
     80    return strcmp($a->name, $b->name); 
     81} 
     82 
     83function _usort_terms_by_ID($a, $b) {  
     84    if ( $a->term_id > $b->term_id )  
     85        return 1;  
     86    elseif ( $a->term_id < $b->term_id )  
     87        return -1;  
     88    else  
     89        return 0;  
    8190} 
    8291 
  • trunk/wp-includes/link-template.php

    r5576 r5590  
    7474        if (strpos($permalink, '%category%') !== false) { 
    7575            $cats = get_the_category($post->ID); 
     76            if ( $cats ) 
     77                usort($cats, '_usort_terms_by_ID'); // order by ID 
    7678            $category = $cats[0]->slug; 
    7779            if ( $parent=$cats[0]->parent ) 
Note: See TracChangeset for help on using the changeset viewer.