summaryrefslogtreecommitdiffstats
path: root/wp-includes/category.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-10-06 14:28:06 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-10-06 14:28:06 +0000
commitca036ad95fc44c318275ab539a52f1eb6fddf060 (patch)
treec2caa110214b14e30570b34f25ac245702031f18 /wp-includes/category.php
parent27893d032fa693cece9531111771a5653f7f31ed (diff)
downloadwordpress-mu-ca036ad95fc44c318275ab539a52f1eb6fddf060.tar.gz
wordpress-mu-ca036ad95fc44c318275ab539a52f1eb6fddf060.tar.xz
wordpress-mu-ca036ad95fc44c318275ab539a52f1eb6fddf060.zip
Add cat_is_ancestor_of() function to help stop recursive categories
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@796 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/category.php')
-rw-r--r--wp-includes/category.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/wp-includes/category.php b/wp-includes/category.php
index 76382ad..1d3f6e4 100644
--- a/wp-includes/category.php
+++ b/wp-includes/category.php
@@ -232,4 +232,19 @@ 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));
+}
+
?>