Changeset 27458
- Timestamp:
- 03/07/2014 07:29:01 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r27457 r27458 1478 1478 foreach ( $terms as $k => $term ) { 1479 1479 if ( ! $term->count ) { 1480 $children = _get_term_children( $term->term_id, $terms, reset( $taxonomies ) ); 1481 if ( is_array( $children ) ) 1482 foreach ( $children as $child ) 1483 if ( $child->count ) 1480 $children = get_term_children( $term->term_id, reset( $taxonomies ) ); 1481 if ( is_array( $children ) ) { 1482 foreach ( $children as $child_id ) { 1483 $child = get_term( $child_id, reset( $taxonomies ) ); 1484 if ( $child->count ) { 1484 1485 continue 2; 1486 } 1487 } 1488 } 1485 1489 1486 1490 // It really is empty … … 2924 2928 2925 2929 if ( $term->term_id == $term_id ) { 2926 if ( isset( $has_children[$term_id] ) ) {2927 $current_id = $term_id;2928 while ( $current_id > 0 ) {2929 foreach ( $has_children[$current_id] as $t_id ) {2930 if ( $use_id ) {2931 $term_list[] = $t_id;2932 } else {2933 $term_list[] = get_term( $t_id, $taxonomy );2934 }2935 }2936 2937 $current_id = isset( $has_children[$t_id] ) ? $t_id : 0;2938 }2939 }2940 2930 continue; 2941 2931 } -
trunk/tests/phpunit/tests/term/getTerms.php
r27197 r27458 277 277 278 278 $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) ); 279 $this->assert NotEmpty( $terms);279 $this->assertEquals( 2, count( $terms ) ); 280 280 $this->assertEquals( wp_list_pluck( $terms, 'name' ), array( 'Cheese', 'Crackers' ) ); 281 281 } … … 297 297 298 298 $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) ); 299 $this->assert NotEmpty( $terms);299 $this->assertEquals( 1, count( $terms ) ); 300 300 $this->assertEquals( array( 'Cheese' ), wp_list_pluck( $terms, 'name' ) ); 301 301 … … 321 321 322 322 $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) ); 323 $this->assert NotEmpty( $terms);323 $this->assertEquals( 1, count( $terms ) ); 324 324 $this->assertEquals( array( 'term1' ), wp_list_pluck( $terms, 'name' ) ); 325 325 326 326 _unregister_taxonomy( $tax ); 327 327 } 328 329 /** 330 * @ticket 27123 331 */ 332 function test_get_terms_child_of() { 333 $parent = $this->factory->category->create(); 334 $child = $this->factory->category->create( array( 'parent' => $parent ) ); 335 336 $terms = get_terms( 'category', array( 'child_of' => $parent, 'hide_empty' => false ) ); 337 $this->assertEquals( 1, count( $terms ) ); 338 } 328 339 }
Note: See TracChangeset
for help on using the changeset viewer.