Changeset 19678
- Timestamp:
- 01/04/2012 10:44:19 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/taxonomy.php
r19593 r19678 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 -
trunk/wp-includes/category.php
r16412 r19678 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 ) ); 221 } 222 210 return term_is_ancestor_of( $cat1, $cat2, 'category' ); 211 } 223 212 224 213 /** … … 235 224 return sanitize_term( $category, 'category', $context ); 236 225 } 237 238 226 239 227 /** … … 255 243 /* Tags */ 256 244 257 258 245 /** 259 246 * Retrieves all post tags. … … 277 264 return $tags; 278 265 } 279 280 266 281 267 /** … … 302 288 } 303 289 304 305 290 /* Cache */ 306 307 291 308 292 /** … … 317 301 clean_term_cache( $id, 'category' ); 318 302 } 319 320 303 321 304 /** … … 356 339 } 357 340 358 359 341 ?> -
trunk/wp-includes/taxonomy.php
r19600 r19678 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 *
Note: See TracChangeset
for help on using the changeset viewer.