Ticket #3387: patch.txt

File patch.txt, 1.3 kB (added by donncha, 2 years ago)
Line 
1 Index: wp-admin/admin-db.php
2 ===================================================================
3 --- wp-admin/admin-db.php       (revision 4523)
4 +++ wp-admin/admin-db.php       (working copy)
5 @@ -108,7 +108,7 @@
6         $category_description = apply_filters('pre_category_description', $category_description);
7  
8         $category_parent = (int) $category_parent;
9 -       if ( empty($category_parent) || !get_category( $category_parent ) || $category_parent == $cat_ID )
10 +       if ( empty($category_parent) || !get_category( $category_parent ) || ($cat_ID && _cat_is_ancestor_of($cat_ID, $category_parent) ) )
11                 $category_parent = 0;
12  
13         if ( isset($posts_private) )
14 Index: wp-includes/category.php
15 ===================================================================
16 --- wp-includes/category.php    (revision 4523)
17 +++ wp-includes/category.php    (working copy)
18 @@ -225,6 +225,21 @@
19         return $category->cat_name;
20  }
21  
22 +function cat_is_ancestor_of($cat1, $cat2) {
23 +       if ( is_int($cat1) )
24 +               $cat1 = & get_category($cat1);
25 +       if ( is_int($cat2) )
26 +               $cat2 = & get_category($cat2);
27 +
28 +       if ( !$cat1->cat_ID || !$cat2->category_parent )
29 +               return false;
30 +
31 +       if ( $cat2->category_parent == $cat1->cat_ID )
32 +               return true;
33 +
34 +       return cat_is_ancestor_of($cat1, get_category($cat2->parent_category));
35 +}
36 +
37  //
38  // Private
39  //