diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index cf024bcdd0..0721fc26f8 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -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 (); if ( is_array( $cats ) ) { diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 03b3345441..0199ad0c47 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -480,13 +480,12 @@ function &get_terms($taxonomies, $args = '') { 'hierarchical' => true, 'child_of' => 0, 'get' => ''); $args = wp_parse_args( $args, $defaults ); $args['number'] = (int) $args['number']; - if ( ! $single_taxonomy ) { - $args['child_of'] = 0; - $args['hierarchical'] = false; - } else if ( !is_taxonomy_hierarchical($taxonomies[0]) ) { + if ( !$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) || + '' != $args['parent'] ) { $args['child_of'] = 0; $args['hierarchical'] = false; } + if ( 'all' == $args['get'] ) { $args['child_of'] = 0; $args['hide_empty'] = 0; @@ -500,6 +499,12 @@ function &get_terms($taxonomies, $args = '') { return array(); } + if ( $parent ) { + $hierarchy = _get_term_hierarchy($taxonomies[0]); + if ( !isset($hierarchy[$parent]) ) + return array(); + } + $key = md5( serialize( $args ) . serialize( $taxonomies ) ); if ( $cache = wp_cache_get( 'get_terms', 'terms' ) ) { if ( isset( $cache[ $key ] ) ) @@ -555,7 +560,7 @@ function &get_terms($taxonomies, $args = '') { $where = " AND t.slug = '$slug'"; } - if ( !empty($parent) ) { + if ( '' != $parent ) { $parent = (int) $parent; $where = " AND tt.parent = '$parent'"; }