Use `reset()` to grab the first taxonomy in an array, not by numerical index. Cleans up whitespace. Props webord, nbachiyski. Fixes #23506.

Built from https://develop.svn.wordpress.org/trunk@25108


git-svn-id: http://core.svn.wordpress.org/trunk@25090 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2013-08-23 21:29:10 +00:00
parent 3c3ec6dd8c
commit a97dfd3009
1 changed files with 15 additions and 15 deletions

View File

@ -1235,14 +1235,14 @@ function get_terms($taxonomies, $args = '') {
extract($args, EXTR_SKIP); extract($args, EXTR_SKIP);
if ( $child_of ) { if ( $child_of ) {
$hierarchy = _get_term_hierarchy($taxonomies[0]); $hierarchy = _get_term_hierarchy( reset( $taxonomies ) );
if ( !isset($hierarchy[$child_of]) ) if ( ! isset( $hierarchy[ $child_of ] ) )
return $empty_array; return $empty_array;
} }
if ( $parent ) { if ( $parent ) {
$hierarchy = _get_term_hierarchy($taxonomies[0]); $hierarchy = _get_term_hierarchy( reset( $taxonomies ) );
if ( !isset($hierarchy[$parent]) ) if ( ! isset( $hierarchy[ $parent ] ) )
return $empty_array; return $empty_array;
} }
@ -1307,13 +1307,13 @@ function get_terms($taxonomies, $args = '') {
$where .= $inclusions; $where .= $inclusions;
$exclusions = ''; $exclusions = '';
if ( !empty( $exclude_tree ) ) { if ( ! empty( $exclude_tree ) ) {
$excluded_trunks = wp_parse_id_list($exclude_tree); $excluded_trunks = wp_parse_id_list( $exclude_tree );
foreach ( $excluded_trunks as $extrunk ) { foreach ( $excluded_trunks as $extrunk ) {
$excluded_children = (array) get_terms($taxonomies[0], array('child_of' => intval($extrunk), 'fields' => 'ids', 'hide_empty' => 0)); $excluded_children = (array) get_terms( reset( $taxonomies ), array( 'child_of' => intval( $extrunk ), 'fields' => 'ids', 'hide_empty' => 0 ) );
$excluded_children[] = $extrunk; $excluded_children[] = $extrunk;
foreach( $excluded_children as $exterm ) { foreach( $excluded_children as $exterm ) {
if ( empty($exclusions) ) if ( empty( $exclusions ) )
$exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' '; $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' ';
else else
$exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' '; $exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' ';
@ -1419,21 +1419,21 @@ function get_terms($taxonomies, $args = '') {
} }
if ( $child_of ) { if ( $child_of ) {
$children = _get_term_hierarchy($taxonomies[0]); $children = _get_term_hierarchy( reset( $taxonomies ) );
if ( ! empty($children) ) if ( ! empty( $children ) )
$terms = _get_term_children($child_of, $terms, $taxonomies[0]); $terms = _get_term_children( $child_of, $terms, reset( $taxonomies ) );
} }
// Update term counts to include children. // Update term counts to include children.
if ( $pad_counts && 'all' == $fields ) if ( $pad_counts && 'all' == $fields )
_pad_term_counts($terms, $taxonomies[0]); _pad_term_counts( $terms, reset( $taxonomies ) );
// Make sure we show empty categories that have children. // Make sure we show empty categories that have children.
if ( $hierarchical && $hide_empty && is_array($terms) ) { if ( $hierarchical && $hide_empty && is_array( $terms ) ) {
foreach ( $terms as $k => $term ) { foreach ( $terms as $k => $term ) {
if ( ! $term->count ) { if ( ! $term->count ) {
$children = _get_term_children($term->term_id, $terms, $taxonomies[0]); $children = _get_term_children( $term->term_id, $terms, reset( $taxonomies ) );
if ( is_array($children) ) if ( is_array( $children ) )
foreach ( $children as $child ) foreach ( $children as $child )
if ( $child->count ) if ( $child->count )
continue 2; continue 2;