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/deprecated.php

    r10348 r10703  
    13041304}
    13051305
     1306/**
     1307 * Retrieve category children list separated before and after the term IDs.
     1308 *
     1309 * @since 1.2.0
     1310 *
     1311 * @param int $id Category ID to retrieve children.
     1312 * @param string $before Optional. Prepend before category term ID.
     1313 * @param string $after Optional, default is empty string. Append after category term ID.
     1314 * @param array $visited Optional. Category Term IDs that have already been added.
     1315 * @return string
     1316 */
     1317function get_category_children( $id, $before = '/', $after = '', $visited = array() ) {
     1318    _deprecated_function(__FUNCTION__, '2.8', 'get_term_children()');
     1319    if ( 0 == $id )
     1320        return '';
     1321
     1322    $chain = '';
     1323    /** TODO: consult hierarchy */
     1324    $cat_ids = get_all_category_ids();
     1325    foreach ( (array) $cat_ids as $cat_id ) {
     1326        if ( $cat_id == $id )
     1327            continue;
     1328
     1329        $category = get_category( $cat_id );
     1330        if ( is_wp_error( $category ) )
     1331            return $category;
     1332        if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) {
     1333            $visited[] = $category->term_id;
     1334            $chain .= $before.$category->term_id.$after;
     1335            $chain .= get_category_children( $category->term_id, $before, $after );
     1336        }
     1337    }
     1338    return $chain;
     1339}
     1340
    13061341?>
Note: See TracChangeset for help on using the changeset viewer.