summaryrefslogtreecommitdiffstats
path: root/wp-includes/category.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-11-24 16:16:44 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-11-24 16:16:44 +0000
commit600b71019494e1c29898a620e58c0d2602f37b74 (patch)
tree21181d77ad4ebbcd42cd883e509c08a568d29514 /wp-includes/category.php
parent7935d0bd9ef23d32ae29a95bd6c3ea0b6eab2973 (diff)
downloadwordpress-mu-600b71019494e1c29898a620e58c0d2602f37b74.tar.gz
wordpress-mu-600b71019494e1c29898a620e58c0d2602f37b74.tar.xz
wordpress-mu-600b71019494e1c29898a620e58c0d2602f37b74.zip
WP Merge to 4524
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@810 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/category.php')
-rw-r--r--wp-includes/category.php31
1 files changed, 16 insertions, 15 deletions
diff --git a/wp-includes/category.php b/wp-includes/category.php
index 1d3f6e4..7b3e7ca 100644
--- a/wp-includes/category.php
+++ b/wp-includes/category.php
@@ -30,6 +30,11 @@ function &get_categories($args = '') {
$r['number'] = (int) $r['number'];
extract($r);
+ $key = md5( serialize( $r ) );
+ if ( $cache = wp_cache_get( 'get_categories', 'category' ) )
+ if ( isset( $cache[ $key ] ) )
+ return $cache[ $key ];
+
$where = 'cat_ID > 0';
$inclusions = '';
if ( !empty($include) ) {
@@ -119,9 +124,20 @@ function &get_categories($args = '') {
}
reset ( $categories );
+ $cache[ $key ] = $categories;
+ wp_cache_set( 'get_categories', $cache, 'category' );
+
return apply_filters('get_categories', $categories, $r);
}
+function delete_get_categories_cache() {
+ wp_cache_delete('get_categories', 'category');
+}
+add_action( 'wp_insert_post', 'delete_get_categories_cache' );
+add_action( 'edit_category', 'delete_get_categories_cache' );
+add_action( 'add_category', 'delete_get_categories_cache' );
+add_action( 'delete_category', 'delete_get_categories_cache' );
+
// Retrieves category data given a category ID or category object.
// Handles category caching.
function &get_category(&$category, $output = OBJECT) {
@@ -232,19 +248,4 @@ function &_get_cat_children($category_id, $categories) {
return $category_list;
}
-function cat_is_ancestor_of($cat1, $cat2) {
- if ( is_int($cat1) )
- $cat1 = & get_category($cat1);
- if ( is_int($cat2) )
- $cat2 = & get_category($cat2);
-
- if ( !$cat1->cat_ID || !$cat2->category_parent )
- return false;
-
- if ( $cat2->category_parent == $cat1->cat_ID )
- return true;
-
- return cat_is_ancestor_of($cat1, get_category($cat2->parent_category));
-}
-
?>