diff --git wp-admin/includes/taxonomy.php wp-admin/includes/taxonomy.php
index 12e231a..d44de2f 100644
|
|
function wp_insert_category($catarr, $wp_error = false) { |
117 | 117 | if ( $parent < 0 ) |
118 | 118 | $parent = 0; |
119 | 119 | |
120 | | if ( empty($parent) || !category_exists( $parent ) || ($cat_ID && cat_is_ancestor_of($cat_ID, $parent) ) ) |
| 120 | if ( empty( $parent ) || ! term_exists( $parent, $taxonomy ) || ( $cat_ID && term_is_ancestor_of( $cat_ID, $parent, $taxonomy ) ) ) |
121 | 121 | $parent = 0; |
122 | 122 | |
123 | 123 | $args = compact('name', 'slug', 'parent', 'description'); |
diff --git wp-includes/category.php wp-includes/category.php
index 4d02277..819d1f8 100644
|
|
function get_cat_name( $cat_id ) { |
207 | 207 | * @return bool Whether $cat2 is child of $cat1 |
208 | 208 | */ |
209 | 209 | function cat_is_ancestor_of( $cat1, $cat2 ) { |
210 | | if ( ! isset($cat1->term_id) ) |
211 | | $cat1 = &get_category( $cat1 ); |
212 | | if ( ! isset($cat2->parent) ) |
213 | | $cat2 = &get_category( $cat2 ); |
214 | | |
215 | | if ( empty($cat1->term_id) || empty($cat2->parent) ) |
216 | | return false; |
217 | | if ( $cat2->parent == $cat1->term_id ) |
218 | | return true; |
219 | | |
220 | | return cat_is_ancestor_of( $cat1, get_category( $cat2->parent ) ); |
| 210 | return term_is_ancestor_of( $cat1, $cat2, 'category' ); |
221 | 211 | } |
222 | 212 | |
223 | 213 | |
diff --git wp-includes/taxonomy.php wp-includes/taxonomy.php
index 72d387a..b3fae51 100644
|
|
function term_exists($term, $taxonomy = '', $parent = 0) { |
1431 | 1431 | } |
1432 | 1432 | |
1433 | 1433 | /** |
| 1434 | * Check if a term is an ancestor of another term. |
| 1435 | * |
| 1436 | * You can use either an id or the term object for both parameters. If you |
| 1437 | * use an integer the term will be retrieved. |
| 1438 | * |
| 1439 | * @since 3.2.0 |
| 1440 | * |
| 1441 | * @param int|object $term1 ID or object to check if this is the parent term. |
| 1442 | * @param int|object $term2 The child term. |
| 1443 | * @param string $taxonomy Taxonomy name that $term1 and $term2 belong to. |
| 1444 | * @return bool Whether $term2 is child of $term1 |
| 1445 | */ |
| 1446 | function term_is_ancestor_of( $term1, $term2, $taxonomy ) { |
| 1447 | if ( ! isset($term1->term_id) ) |
| 1448 | $term1 = &get_term( $term1, $taxonomy ); |
| 1449 | if ( ! isset($term2->parent) ) |
| 1450 | $term2 = &get_term( $term2, $taxonomy ); |
| 1451 | |
| 1452 | if ( empty($term1->term_id) || empty($term2->parent) ) |
| 1453 | return false; |
| 1454 | if ( $term2->parent == $term1->term_id ) |
| 1455 | return true; |
| 1456 | |
| 1457 | return term_is_ancestor_of( $cat1, get_term( $cat2->parent, $taxonomy ) ); |
| 1458 | } |
| 1459 | |
| 1460 | /** |
1434 | 1461 | * Sanitize Term all fields. |
1435 | 1462 | * |
1436 | 1463 | * Relys on sanitize_term_field() to sanitize the term. The difference is that |