Make WordPress Core


Ignore:
Timestamp:
05/23/2007 06:07:53 PM (19 years ago)
Author:
ryan
Message:

Set and get post cats to taxonomy. see #4189

File:
1 edited

Legend:

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

    r5521 r5529  
    1313
    1414        $category = get_category($cat_id);
    15         if ( $category->category_parent == $id ) {
    16             $chain .= $before.$category->cat_ID.$after;
    17             $chain .= get_category_children($category->cat_ID, $before, $after);
     15        if ( $category->parent == $id ) {
     16            $chain .= $before.$category->term_id.$after;
     17            $chain .= get_category_children($category->term_id, $before, $after);
    1818        }
    1919    }
     
    3030    } else {
    3131        $category = &get_category($category_id);
    32         $category_nicename = $category->category_nicename;
    33 
    34         if ( $parent = $category->category_parent )
     32        $category_nicename = $category->slug;
     33
     34        if ( $parent = $category->parent )
    3535            $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename;
    3636
     
    4646
    4747    if ( $nicename )
    48         $name = $parent->category_nicename;
     48        $name = $parent->slug;
    4949    else
    5050        $name = $parent->cat_name;
    5151
    52     if ( $parent->category_parent && ($parent->category_parent != $parent->cat_ID) )
    53         $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename);
     52    if ( $parent->parent && ($parent->parent != $parent->term_id) )
     53        $chain .= get_category_parents($parent->parent, $link, $separator, $nicename);
    5454
    5555    if ( $link )
    56         $chain .= '<a href="' . get_category_link($parent->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $parent->cat_name) . '">'.$name.'</a>' . $separator;
     56        $chain .= '<a href="' . get_category_link($parent->term_id) . '" title="' . sprintf(__("View all posts in %s"), $parent->cat_name) . '">'.$name.'</a>' . $separator;
    5757    else
    5858        $chain .= $name.$separator;
     
    6161
    6262function get_the_category($id = false) {
    63 global $post, $category_cache, $blog_id;
     63    global $post, $category_cache, $blog_id;
    6464
    6565    $id = (int) $id;
     
    6767        $id = (int) $post->ID;
    6868
    69     if ( !isset($category_cache[$blog_id][$id]) )
    70         update_post_category_cache($id);
    71 
    72     $categories = $category_cache[$blog_id][$id];
     69    $categories = get_object_terms($id, 'category');
    7370
    7471    if ( !empty($categories) )
     
    8784    $cat_ID = (int) $cat_ID;
    8885    $category = &get_category($cat_ID);
    89     return $category->cat_name;
     86    return $category->name;
    9087}
    9188
     
    105102            switch ( strtolower($parents) ) {
    106103                case 'multiple':
    107                     if ($category->category_parent)
    108                         $thelist .= get_category_parents($category->category_parent, TRUE);
    109                     $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" ' . $rel . '>' . $category->cat_name.'</a></li>';
     104                    if ($category->parent)
     105                        $thelist .= get_category_parents($category->parent, TRUE);
     106                    $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>' . $category->name.'</a></li>';
    110107                    break;
    111108                case 'single':
    112                     $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" ' . $rel . '>';
    113                     if ($category->category_parent)
    114                         $thelist .= get_category_parents($category->category_parent, FALSE);
    115                     $thelist .= $category->cat_name.'</a></li>';
     109                    $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>';
     110                    if ($category->parent)
     111                        $thelist .= get_category_parents($category->parent, FALSE);
     112                    $thelist .= $category->name.'</a></li>';
    116113                    break;
    117114                case '':
    118115                default:
    119                     $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" ' . $rel . '>' . $category->cat_name.'</a></li>';
     116                    $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>' . $category->cat_name.'</a></li>';
    120117            }
    121118        }
     
    128125            switch ( strtolower($parents) ) {
    129126                case 'multiple':
    130                     if ( $category->category_parent )
    131                         $thelist .= get_category_parents($category->category_parent, TRUE);
    132                     $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" ' . $rel . '>' . $category->cat_name.'</a>';
     127                    if ( $category->parent )
     128                        $thelist .= get_category_parents($category->parent, TRUE);
     129                    $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>' . $category->cat_name.'</a>';
    133130                    break;
    134131                case 'single':
    135                     $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" ' . $rel . '>';
    136                     if ( $category->category_parent )
    137                         $thelist .= get_category_parents($category->category_parent, FALSE);
     132                    $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>';
     133                    if ( $category->parent )
     134                        $thelist .= get_category_parents($category->parent, FALSE);
    138135                    $thelist .= "$category->cat_name</a>";
    139136                    break;
    140137                case '':
    141138                default:
    142                     $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" ' . $rel . '>' . $category->cat_name.'</a>';
     139                    $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>' . $category->name.'</a>';
    143140            }
    144141            ++$i;
     
    166163        $category = $cat;
    167164    $category = & get_category($category);
    168     return apply_filters('category_description', $category->category_description, $category->cat_ID);
     165    return apply_filters('category_description', $category->description, $category->term_id);
    169166}
    170167
Note: See TracChangeset for help on using the changeset viewer.