Deprecate get_category_children(). Props filosofo. fixes #9007

git-svn-id: http://svn.automattic.com/wordpress/trunk@10703 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-03-04 19:53:17 +00:00
parent a867852888
commit bf0796d4f8
2 changed files with 35 additions and 34 deletions

View File

@ -6,40 +6,6 @@
* @subpackage Template
*/
/**
* Retrieve category children list separated before and after the term IDs.
*
* @since 1.2.0
*
* @param int $id Category ID to retrieve children.
* @param string $before Optional. Prepend before category term ID.
* @param string $after Optional, default is empty string. Append after category term ID.
* @param array $visited Optional. Category Term IDs that have already been added.
* @return string
*/
function get_category_children( $id, $before = '/', $after = '', $visited = array() ) {
if ( 0 == $id )
return '';
$chain = '';
/** TODO: consult hierarchy */
$cat_ids = get_all_category_ids();
foreach ( (array) $cat_ids as $cat_id ) {
if ( $cat_id == $id )
continue;
$category = get_category( $cat_id );
if ( is_wp_error( $category ) )
return $category;
if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) {
$visited[] = $category->term_id;
$chain .= $before.$category->term_id.$after;
$chain .= get_category_children( $category->term_id, $before, $after );
}
}
return $chain;
}
/**
* Retrieve category link URL.
*

View File

@ -1303,4 +1303,39 @@ function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = fals
return get_comment($comment_ID, ARRAY_A);
}
/**
* Retrieve category children list separated before and after the term IDs.
*
* @since 1.2.0
*
* @param int $id Category ID to retrieve children.
* @param string $before Optional. Prepend before category term ID.
* @param string $after Optional, default is empty string. Append after category term ID.
* @param array $visited Optional. Category Term IDs that have already been added.
* @return string
*/
function get_category_children( $id, $before = '/', $after = '', $visited = array() ) {
_deprecated_function(__FUNCTION__, '2.8', 'get_term_children()');
if ( 0 == $id )
return '';
$chain = '';
/** TODO: consult hierarchy */
$cat_ids = get_all_category_ids();
foreach ( (array) $cat_ids as $cat_id ) {
if ( $cat_id == $id )
continue;
$category = get_category( $cat_id );
if ( is_wp_error( $category ) )
return $category;
if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) {
$visited[] = $category->term_id;
$chain .= $before.$category->term_id.$after;
$chain .= get_category_children( $category->term_id, $before, $after );
}
}
return $chain;
}
?>