Ticket #15581: 15581.diff
File 15581.diff, 3.1 KB (added by , 13 years ago) |
---|
-
wp-includes/category.php
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 224 213 /** 225 214 * Sanitizes category data based on context. 226 215 * … … 235 224 return sanitize_term( $category, 'category', $context ); 236 225 } 237 226 238 239 227 /** 240 228 * Sanitizes data in single category key field. 241 229 * … … 254 242 255 243 /* Tags */ 256 244 257 258 245 /** 259 246 * Retrieves all post tags. 260 247 * … … 277 264 return $tags; 278 265 } 279 266 280 281 267 /** 282 268 * Retrieve post tag by tag ID or tag object. 283 269 * … … 301 287 return get_term( $tag, 'post_tag', $output, $filter ); 302 288 } 303 289 304 305 290 /* Cache */ 306 291 307 308 292 /** 309 293 * Remove the category cache data based on ID. 310 294 * … … 317 301 clean_term_cache( $id, 'category' ); 318 302 } 319 303 320 321 304 /** 322 305 * Update category structure to old pre 2.3 from new taxonomy structure. 323 306 * … … 355 338 } 356 339 } 357 340 358 359 341 ?> -
wp-includes/taxonomy.php
1495 1495 } 1496 1496 1497 1497 /** 1498 * Check if a term is an ancestor of another term. 1499 * 1500 * You can use either an id or the term object for both parameters. 1501 * 1502 * @since 3.4.0 1503 * 1504 * @param int|object $term1 ID or object to check if this is the parent term. 1505 * @param int|object $term2 The child term. 1506 * @param string $taxonomy Taxonomy name that $term1 and $term2 belong to. 1507 * @return bool Whether $term2 is child of $term1 1508 */ 1509 function term_is_ancestor_of( $term1, $term2, $taxonomy ) { 1510 if ( ! isset( $term1->term_id ) ) 1511 $term1 = get_term( $term1, $taxonomy ); 1512 if ( ! isset( $term2->parent ) ) 1513 $term2 = get_term( $term2, $taxonomy ); 1514 1515 if ( empty( $term1->term_id ) || empty( $term2->parent ) ) 1516 return false; 1517 if ( $term2->parent == $term1->term_id ) 1518 return true; 1519 1520 return term_is_ancestor_of( $term1, get_term( $term2->parent, $taxonomy ), $taxonomy ); 1521 } 1522 1523 /** 1498 1524 * Sanitize Term all fields. 1499 1525 * 1500 1526 * Relies on sanitize_term_field() to sanitize the term. The difference is that -
wp-admin/includes/taxonomy.php
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');