WordPress.org

Make WordPress Core

Changeset 4525


Ignore:
Timestamp:
11/24/06 16:37:44 (7 years ago)
Author:
ryan
Message:

cat_is_ancestor_of(). fixes #3387

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-db.php

    r4524 r4525  
    109109 
    110110    $category_parent = (int) $category_parent; 
    111     if ( empty($category_parent) || !get_category( $category_parent ) || $category_parent == $cat_ID ) 
     111    if ( empty($category_parent) || !get_category( $category_parent ) || ($cat_ID && _cat_is_ancestor_of($cat_ID, $category_parent) ) ) 
    112112        $category_parent = 0; 
    113113 
  • trunk/wp-includes/category.php

    r4519 r4525  
    226226} 
    227227 
     228function cat_is_ancestor_of($cat1, $cat2) {  
     229    if ( is_int($cat1) )  
     230        $cat1 = & get_category($cat1);  
     231    if ( is_int($cat2) )  
     232        $cat2 = & get_category($cat2);  
     233 
     234    if ( !$cat1->cat_ID || !$cat2->category_parent )  
     235        return false;  
     236 
     237    if ( $cat2->category_parent == $cat1->cat_ID )  
     238        return true;  
     239 
     240    return cat_is_ancestor_of($cat1, get_category($cat2->parent_category));  
     241}  
     242 
    228243// 
    229244// Private 
Note: See TracChangeset for help on using the changeset viewer.