mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-16 19:46:21 +00:00
query by parent, not child_of, in get_nested_categories(). see #4189
git-svn-id: http://svn.automattic.com/wordpress/trunk@5622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fb6ce027e1
commit
9e8bfa7f7b
@ -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 ) ) {
|
||||
|
@ -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'";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user