Make WordPress Core


Ignore:
Timestamp:
11/07/2005 09:56:03 PM (19 years ago)
Author:
ryan
Message:

Object caching, round one.

File:
1 edited

Legend:

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

    r3001 r3011  
    444444                $cat_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
    445445
    446             $q['cat'] = array_reduce(
    447                 $cache_categories,
    448                 create_function('$a, $b', 'return ($b->fullpath == "'.$cat_path.'") ? $b->cat_ID : $a;'),
    449                 0
    450             );
    451 
    452             // If full path not found, look for last dir as category ignoring parent
    453             if($q['cat'] == 0) {
    454                 $q['cat'] = array_reduce(
    455                     $cache_categories,
    456                     create_function('$a, $b', 'return ($b->category_nicename == "'.$q['category_name'].'") ? $b->cat_ID : $a;'),
    457                     0
    458                 );
    459             }
    460            
     446            $all_cat_ids = get_all_category_ids();
     447            $q['cat'] = 0;         
     448            foreach ( $all_cat_ids as $cat_id ) {
     449                $cat = get_category($cat_id);
     450                if ( $cat->fullpath == $cat_path ) {
     451                    $q['cat'] = $cat_id;
     452                    break;
     453                }
     454            }
     455
    461456            $tables = ", $wpdb->post2cat, $wpdb->categories";
    462457            $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
Note: See TracChangeset for help on using the changeset viewer.