Ticket #29839: 20141116_01-taxonomy.2.diff
File 20141116_01-taxonomy.2.diff, 2.6 KB (added by , 10 years ago) |
---|
-
src/wp-includes/taxonomy.php
1616 1616 * @type int $child_of Term ID to retrieve child terms of. If multiple taxonomies 1617 1617 * are passed, $child_of is ignored. Default 0. 1618 1618 * @type int|string $parent Parent term ID to retrieve direct-child terms of. Default empty. 1619 * @type bool $childless Returns terms that have no children. Null if taxonomy is not 1620 * hierarchical. Default false 1619 1621 * @type string $cache_domain Unique cache key to be produced when this query is stored in an 1620 1622 * object cache. Default is 'core'. 1621 1623 * } … … 1640 1642 1641 1643 $defaults = array('orderby' => 'name', 'order' => 'ASC', 1642 1644 'hide_empty' => true, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(), 1643 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '', 1645 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '', 'childless' => false, 1644 1646 'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '', 'description__like' => '', 1645 1647 'pad_counts' => false, 'offset' => '', 'search' => '', 'cache_domain' => 'core' ); 1646 1648 $args = wp_parse_args( $args, $defaults ); … … 1659 1661 } 1660 1662 1661 1663 if ( 'all' == $args['get'] ) { 1664 $args['childless'] = false; 1662 1665 $args['child_of'] = 0; 1663 1666 $args['hide_empty'] = 0; 1664 1667 $args['hierarchical'] = false; … … 1798 1801 } 1799 1802 } 1800 1803 1804 $childless = (bool) $args['childless']; // boolean 1805 if ( $childless ) { 1806 $terms_to_exclude = ""; 1807 $term_hierarchy = _get_term_hierarchy( reset( $taxonomies ) ); 1808 1809 // If $term_hierarchy is empty, then there are no exclusions because either the 1810 // $taxonomy is flat, or it's hierarchical but has no child terms. In both cases, 1811 // return everything 1812 if ( ! empty( $term_hierarchy ) ) { 1813 // Any term listed in $term_hierarchy has by definition a child term, so exclude it 1814 foreach ( array_keys($term_hierarchy) as $excluded_index=>$excluded_id ) { 1815 if ( empty($terms_to_exclude) ) { 1816 $terms_to_exclude = intval( $excluded_id ); 1817 } else { 1818 $terms_to_exclude .= ', ' . intval( $excluded_id ); 1819 } 1820 } 1821 if ( empty( $exclusions ) ) { 1822 $exclusions = $terms_to_exclude; 1823 } else { 1824 $exclusions .= ', ' . $terms_to_exclude; 1825 } 1826 } 1827 } 1828 1801 1829 if ( ! empty( $exclusions ) ) { 1802 1830 $exclusions = ' AND t.term_id NOT IN (' . $exclusions . ')'; 1803 1831 }