Changeset 11115
- Timestamp:
- 04/28/2009 07:49:21 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/taxonomy.php
r11109 r11115 413 413 414 414 /** 415 * Merge all term children into a single array .415 * Merge all term children into a single array of their IDs. 416 416 * 417 417 * This recursive function will merge all of the children of $term into the same 418 * array . Only useful for taxonomies which are hierarchical.418 * array of term IDs. Only useful for taxonomies which are hierarchical. 419 419 * 420 420 * Will return an empty array if $term does not exist in $taxonomy. … … 428 428 * @uses get_term_children() Used to get the children of both $taxonomy and the parent $term 429 429 * 430 * @param string $term Nameof Term to get children430 * @param string $term ID of Term to get children 431 431 * @param string $taxonomy Taxonomy Name 432 432 * @return array|WP_Error List of Term Objects. WP_Error returned if $taxonomy does not exist 433 433 */ 434 function get_term_children( $term , $taxonomy ) {434 function get_term_children( $term_id, $taxonomy ) { 435 435 if ( ! is_taxonomy($taxonomy) ) 436 436 return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); 437 437 438 $term_id = intval( $term_id ); 439 438 440 $terms = _get_term_hierarchy($taxonomy); 439 441 440 if ( ! isset($terms[$term ]) )442 if ( ! isset($terms[$term_id]) ) 441 443 return array(); 442 444 443 $children = $terms[$term ];444 445 foreach ( (array) $terms[$term ] as $child ) {445 $children = $terms[$term_id]; 446 447 foreach ( (array) $terms[$term_id] as $child ) { 446 448 if ( isset($terms[$child]) ) 447 449 $children = array_merge($children, get_term_children($child, $taxonomy)); … … 1966 1968 1967 1969 /** 1968 * Retrieves children of taxonomy .1970 * Retrieves children of taxonomy as Term IDs. 1969 1971 * 1970 1972 * @package WordPress … … 1977 1979 * 1978 1980 * @param string $taxonomy Taxonomy Name 1979 * @return array Empty if $taxonomy isn't hierarachical or returns children .1981 * @return array Empty if $taxonomy isn't hierarachical or returns children as Term IDs. 1980 1982 */ 1981 1983 function _get_term_hierarchy($taxonomy) {
Note: See TracChangeset
for help on using the changeset viewer.