Ticket #29839: 29839.diff
File 29839.diff, 2.4 KB (added by , 11 years ago) |
---|
-
wp-includes/taxonomy.php
1640 1640 1641 1641 $defaults = array('orderby' => 'name', 'order' => 'ASC', 1642 1642 'hide_empty' => true, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(), 1643 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '', 1643 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '', 'child' => '', 1644 1644 'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '', 'description__like' => '', 1645 1645 'pad_counts' => false, 'offset' => '', 'search' => '', 'cache_domain' => 'core' ); 1646 1646 $args = wp_parse_args( $args, $defaults ); … … 1654 1654 $args['pad_counts'] = false; 1655 1655 } 1656 1656 1657 // 'parent' overrides 'child_of'.1658 if ( 0 < intval( $args['parent'] ) ) {1657 // 'parent' and 'child' overrides 'child_of'. 1658 if ( 0 < intval( $args['parent'] ) || 0 < intval( $args['child'] ) ) { 1659 1659 $args['child_of'] = false; 1660 1660 } 1661 1661 … … 1692 1692 } 1693 1693 } 1694 1694 1695 $child = $args['child']; 1696 if ( $child ) { 1697 $hierarchy = _get_term_hierarchy( reset( $taxonomies ) ); 1698 if ( ! isset( $hierarchy[ $child ] ) ) { 1699 return $empty_array; 1700 } 1701 } 1702 1695 1703 // $args can be whatever, only use the args defined in defaults to compute the key 1696 1704 $filter_key = ( has_filter('list_terms_exclusions') ) ? serialize($GLOBALS['wp_filter']['list_terms_exclusions']) : ''; 1697 1705 $key = md5( serialize( wp_array_slice_assoc( $args, array_keys( $defaults ) ) ) . serialize( $taxonomies ) . $filter_key ); … … 1853 1861 $offset = $args['offset']; 1854 1862 1855 1863 // don't limit the query results when we have to descend the family tree 1856 if ( $number && ! $hierarchical && ! $child_of && '' === $parent ) {1864 if ( $number && ! $hierarchical && ! $child_of && '' === $parent && '' === $child ) { 1857 1865 if ( $offset ) { 1858 1866 $limits = 'LIMIT ' . $offset . ',' . $number; 1859 1867 } else { … … 1951 1959 } 1952 1960 } 1953 1961 1962 if ( $child ) { 1963 $children = _get_term_hierarchy( reset( $taxonomies ) ); 1964 if ( ! empty( $children ) ) { 1965 $terms = _get_term_children( $child, $terms, reset( $taxonomies ) ); 1966 foreach ( $terms as $k => $term ) { 1967 if ( isset( $children[$term->term_id] ) ) 1968 unset($terms[$k]); 1969 } 1970 } 1971 } 1972 1954 1973 // Update term counts to include children. 1955 1974 if ( $args['pad_counts'] && 'all' == $_fields ) { 1956 1975 _pad_term_counts( $terms, reset( $taxonomies ) );