Use reset()
to access the first element of an array, don't assume there is an item at index 0
.
See #25282. git-svn-id: https://develop.svn.wordpress.org/trunk@25384 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6ced366e7c
commit
f9877147f6
@ -1238,7 +1238,7 @@ function get_terms($taxonomies, $args = '') {
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
$args['number'] = absint( $args['number'] );
|
||||
$args['offset'] = absint( $args['offset'] );
|
||||
if ( !$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) ||
|
||||
if ( !$single_taxonomy || ! is_taxonomy_hierarchical( reset( $taxonomies ) ) ||
|
||||
'' !== $args['parent'] ) {
|
||||
$args['child_of'] = 0;
|
||||
$args['hierarchical'] = false;
|
||||
|
@ -85,7 +85,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase {
|
||||
function test_get_terms_should_allow_arbitrary_indexed_taxonomies_array() {
|
||||
$term_id = $this->factory->tag->create();
|
||||
$terms = get_terms( array( '111' => 'post_tag' ), array( 'hide_empty' => false ) );
|
||||
$this->assertEquals( $term_id, $terms[0]->term_id );
|
||||
$this->assertEquals( $term_id, reset( $terms )->term_id );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user