Changeset 2478 for trunk/wp-includes/template-functions-category.php
- Timestamp:
- 03/27/2005 08:45:01 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/template-functions-category.php
r2450 r2478 2 2 3 3 function get_the_category($id = false) { 4 global $post, $ wpdb, $category_cache;4 global $post, $category_cache; 5 5 6 6 if ( !$id ) 7 7 $id = $post->ID; 8 8 9 if ( $category_cache[$id] ) { 10 $categories = $category_cache[$id]; 11 } else { 12 $categories = $wpdb->get_results(" 13 SELECT category_id, cat_name, category_nicename, category_description, category_parent 14 FROM $wpdb->categories, $wpdb->post2cat 15 WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$id' 16 "); 17 } 9 if ( ! isset($category_cache[$id]) ) 10 update_post_category_cache($id); 11 12 $categories = $category_cache[$id]; 18 13 19 14 if (!empty($categories)) … … 26 21 27 22 function get_category_link($category_id) { 28 global $wp db, $wp_rewrite, $querystring_start, $querystring_equal, $cache_categories;23 global $wp_rewrite; 29 24 $catlink = $wp_rewrite->get_category_permastruct(); 30 25 … … 33 28 $catlink = $file . '?cat=' . $category_id; 34 29 } else { 35 if ($cache_categories[$category_id]->category_nicename) 36 $category_nicename = $cache_categories[$category_id]->category_nicename; 37 else 38 $category_nicename = $wpdb->get_var('SELECT category_nicename FROM ' . $wpdb->categories . ' WHERE cat_ID=' . $category_id); 39 40 if ($parent = $cache_categories[$category_id]->category_parent) 30 $category = &get_category($category_id); 31 $category_nicename = $category->category_nicename; 32 33 if ($parent = $category->category_parent) 41 34 $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/'; 42 35 … … 109 102 110 103 function get_the_category_by_ID($cat_ID) { 111 global $cache_categories, $wpdb; 112 if ( !$cache_categories[$cat_ID] ) { 113 $cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE cat_ID = '$cat_ID'"); 114 $cache_categories[$cat_ID]->cat_name = $cat_name; 115 } else { 116 $cat_name = $cache_categories[$cat_ID]->cat_name; 117 } 118 return($cat_name); 104 $category = &get_category($cat_ID); 105 return $category->cat_name; 119 106 } 120 107 121 108 function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){ 122 global $cache_categories;123 109 $chain = ''; 124 $parent = $cache_categories[$id];110 $parent = &get_category($id); 125 111 if ($nicename) { 126 112 $name = $parent->category_nicename; … … 176 162 177 163 function category_description($category = 0) { 178 global $cat , $wpdb, $cache_categories;164 global $cat; 179 165 if (!$category) $category = $cat; 180 $category_description = $cache_categories[$category]->category_description; 181 $category_description = apply_filters('category_description', $category_description, $category); 182 return $category_description; 166 $category = & get_category($category); 167 return apply_filters('category_description', $category->category_description, $category->cat_ID); 183 168 } 184 169
Note: See TracChangeset
for help on using the changeset viewer.