WordPress.org

Make WordPress Core

Changeset 11115


Ignore:
Timestamp:
04/28/09 19:49:21 (5 years ago)
Author:
ryan
Message:

get_term_children phpdoc and var naming improvements. Props simonwheatley. fixes #9667

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r11109 r11115  
    413413 
    414414/** 
    415  * Merge all term children into a single array. 
     415 * Merge all term children into a single array of their IDs. 
    416416 * 
    417417 * 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. 
    419419 * 
    420420 * Will return an empty array if $term does not exist in $taxonomy. 
     
    428428 * @uses get_term_children() Used to get the children of both $taxonomy and the parent $term 
    429429 * 
    430  * @param string $term Name of Term to get children 
     430 * @param string $term ID of Term to get children 
    431431 * @param string $taxonomy Taxonomy Name 
    432432 * @return array|WP_Error List of Term Objects. WP_Error returned if $taxonomy does not exist 
    433433 */ 
    434 function get_term_children( $term, $taxonomy ) { 
     434function get_term_children( $term_id, $taxonomy ) { 
    435435    if ( ! is_taxonomy($taxonomy) ) 
    436436        return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); 
    437437 
     438    $term_id = intval( $term_id ); 
     439 
    438440    $terms = _get_term_hierarchy($taxonomy); 
    439441 
    440     if ( ! isset($terms[$term]) ) 
     442    if ( ! isset($terms[$term_id]) ) 
    441443        return array(); 
    442444 
    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 ) { 
    446448        if ( isset($terms[$child]) ) 
    447449            $children = array_merge($children, get_term_children($child, $taxonomy)); 
     
    19661968 
    19671969/** 
    1968  * Retrieves children of taxonomy. 
     1970 * Retrieves children of taxonomy as Term IDs. 
    19691971 * 
    19701972 * @package WordPress 
     
    19771979 * 
    19781980 * @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. 
    19801982 */ 
    19811983function _get_term_hierarchy($taxonomy) { 
Note: See TracChangeset for help on using the changeset viewer.