Make WordPress Core

Changeset 5818


Ignore:
Timestamp:
07/25/2007 03:04:46 AM (17 years ago)
Author:
ryan
Message:

In your cats, making them back compat.

File:
1 edited

Legend:

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

    r5642 r5818  
    1919    if ( 'link' == $args['type'] )
    2020        $taxonomy = 'link_category';
    21     return get_terms($taxonomy, $args);
     21    $categories = get_terms($taxonomy, $args);
     22
     23    foreach ( $categories as $category )
     24        _make_cat_compat($category);
     25
     26    return $categories;
    2227}
    2328
     
    2530// Handles category caching.
    2631function &get_category(&$category, $output = OBJECT) {
    27     return get_term($category, 'category', $output);
     32    $category = get_term($category, 'category', $output);
     33
     34    _make_cat_compat($category);
     35
     36    return $category;
    2837}
    2938
     
    6574
    6675function get_category_by_slug( $slug  ) {
    67     return get_term_by('slug', $slug, 'category');
     76    $category = get_term_by('slug', $slug, 'category');
     77    if ( $category )
     78        _make_cat_compat($category);
     79
     80    return $category;
    6881}
    6982
     
    140153}
    141154
     155//
     156// Private helpers
     157//
     158
     159function _make_cat_compat( &$category) {
     160    if ( is_object($category) ) {
     161        $category->cat_ID = &$category->term_id;
     162        $category->category_count = &$category->count;
     163        $category->category_description = &$category->description;
     164        $category->cat_name = &$category->name;
     165        $category->category_nicename = &$category->slug;
     166        $category->category_parent = &$category->parent;
     167    } else if ( is_array($category) && isset($category['term_id']) ) {
     168        $category['cat_ID'] = &$category['term_id'];
     169        $category['category_count'] = &$category['count'];
     170        $category['category_description'] = &$category['description'];
     171        $category['cat_name'] = &$category['name'];
     172        $category['category_nicename'] = &$category['slug'];
     173        $category['category_parent'] = &$category['parent'];
     174    }
     175}
     176
    142177?>
Note: See TracChangeset for help on using the changeset viewer.