Remove unnecessary `array_shift()` usage in `get_terms()` for better performance.
props bswatson, VolodymyrC. fixes #31182. Built from https://develop.svn.wordpress.org/trunk@31365 git-svn-id: http://core.svn.wordpress.org/trunk@31346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
137204b033
commit
09c1d34b96
|
@ -2013,28 +2013,27 @@ function get_terms( $taxonomies, $args = '' ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reset( $terms );
|
|
||||||
|
|
||||||
$_terms = array();
|
$_terms = array();
|
||||||
if ( 'id=>parent' == $_fields ) {
|
if ( 'id=>parent' == $_fields ) {
|
||||||
while ( $term = array_shift( $terms ) ) {
|
foreach ( $terms as $term ) {
|
||||||
$_terms[$term->term_id] = $term->parent;
|
$_terms[ $term->term_id ] = $term->parent;
|
||||||
}
|
}
|
||||||
} elseif ( 'ids' == $_fields ) {
|
} elseif ( 'ids' == $_fields ) {
|
||||||
while ( $term = array_shift( $terms ) ) {
|
foreach ( $terms as $term ) {
|
||||||
$_terms[] = $term->term_id;
|
$_terms[] = $term->term_id;
|
||||||
}
|
}
|
||||||
} elseif ( 'names' == $_fields ) {
|
} elseif ( 'names' == $_fields ) {
|
||||||
while ( $term = array_shift( $terms ) ) {
|
foreach ( $terms as $term ) {
|
||||||
$_terms[] = $term->name;
|
$_terms[] = $term->name;
|
||||||
}
|
}
|
||||||
} elseif ( 'id=>name' == $_fields ) {
|
} elseif ( 'id=>name' == $_fields ) {
|
||||||
while ( $term = array_shift( $terms ) ) {
|
foreach ( $terms as $term ) {
|
||||||
$_terms[$term->term_id] = $term->name;
|
$_terms[ $term->term_id ] = $term->name;
|
||||||
}
|
}
|
||||||
} elseif ( 'id=>slug' == $_fields ) {
|
} elseif ( 'id=>slug' == $_fields ) {
|
||||||
while ( $term = array_shift( $terms ) ) {
|
foreach ( $terms as $term ) {
|
||||||
$_terms[$term->term_id] = $term->slug;
|
$_terms[ $term->term_id ] = $term->slug;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.2-alpha-31364';
|
$wp_version = '4.2-alpha-31365';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue