summaryrefslogtreecommitdiffstats
path: root/wp-includes
diff options
context:
space:
mode:
Diffstat (limited to 'wp-includes')
-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));
+}
+
?>