Make WordPress Core


Ignore:
Timestamp:
03/04/2009 07:53:17 PM (17 years ago)
Author:
ryan
Message:

Deprecate get_category_children(). Props filosofo. fixes #9007

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/category-template.php

    r10636 r10703  
    66 * @subpackage Template
    77 */
    8 
    9 /**
    10  * Retrieve category children list separated before and after the term IDs.
    11  *
    12  * @since 1.2.0
    13  *
    14  * @param int $id Category ID to retrieve children.
    15  * @param string $before Optional. Prepend before category term ID.
    16  * @param string $after Optional, default is empty string. Append after category term ID.
    17  * @param array $visited Optional. Category Term IDs that have already been added.
    18  * @return string
    19  */
    20 function get_category_children( $id, $before = '/', $after = '', $visited = array() ) {
    21     if ( 0 == $id )
    22         return '';
    23 
    24     $chain = '';
    25     /** TODO: consult hierarchy */
    26     $cat_ids = get_all_category_ids();
    27     foreach ( (array) $cat_ids as $cat_id ) {
    28         if ( $cat_id == $id )
    29             continue;
    30 
    31         $category = get_category( $cat_id );
    32         if ( is_wp_error( $category ) )
    33             return $category;
    34         if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) {
    35             $visited[] = $category->term_id;
    36             $chain .= $before.$category->term_id.$after;
    37             $chain .= get_category_children( $category->term_id, $before, $after );
    38         }
    39     }
    40     return $chain;
    41 }
    428
    439/**
Note: See TracChangeset for help on using the changeset viewer.