query by parent, not child_of, in get_nested_categories(). see #4189

git-svn-id: https://develop.svn.wordpress.org/trunk@5622 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2007-06-01 02:24:07 +00:00
parent 43483ef854
commit 9aae8013a8
2 changed files with 11 additions and 6 deletions

View File

@ -100,7 +100,7 @@ function get_nested_categories( $default = 0, $parent = 0 ) {
} }
} }
$cats = get_categories("child_of=$parent&hide_empty=0&fields=ids"); $cats = get_categories("parent=$parent&hide_empty=0&fields=ids");
$result = array (); $result = array ();
if ( is_array( $cats ) ) { if ( is_array( $cats ) ) {

View File

@ -480,13 +480,12 @@ function &get_terms($taxonomies, $args = '') {
'hierarchical' => true, 'child_of' => 0, 'get' => ''); 'hierarchical' => true, 'child_of' => 0, 'get' => '');
$args = wp_parse_args( $args, $defaults ); $args = wp_parse_args( $args, $defaults );
$args['number'] = (int) $args['number']; $args['number'] = (int) $args['number'];
if ( ! $single_taxonomy ) { if ( !$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) ||
$args['child_of'] = 0; '' != $args['parent'] ) {
$args['hierarchical'] = false;
} else if ( !is_taxonomy_hierarchical($taxonomies[0]) ) {
$args['child_of'] = 0; $args['child_of'] = 0;
$args['hierarchical'] = false; $args['hierarchical'] = false;
} }
if ( 'all' == $args['get'] ) { if ( 'all' == $args['get'] ) {
$args['child_of'] = 0; $args['child_of'] = 0;
$args['hide_empty'] = 0; $args['hide_empty'] = 0;
@ -500,6 +499,12 @@ function &get_terms($taxonomies, $args = '') {
return array(); return array();
} }
if ( $parent ) {
$hierarchy = _get_term_hierarchy($taxonomies[0]);
if ( !isset($hierarchy[$parent]) )
return array();
}
$key = md5( serialize( $args ) . serialize( $taxonomies ) ); $key = md5( serialize( $args ) . serialize( $taxonomies ) );
if ( $cache = wp_cache_get( 'get_terms', 'terms' ) ) { if ( $cache = wp_cache_get( 'get_terms', 'terms' ) ) {
if ( isset( $cache[ $key ] ) ) if ( isset( $cache[ $key ] ) )
@ -555,7 +560,7 @@ function &get_terms($taxonomies, $args = '') {
$where = " AND t.slug = '$slug'"; $where = " AND t.slug = '$slug'";
} }
if ( !empty($parent) ) { if ( '' != $parent ) {
$parent = (int) $parent; $parent = (int) $parent;
$where = " AND tt.parent = '$parent'"; $where = " AND tt.parent = '$parent'";
} }