Changeset 31284
- Timestamp:
- 01/26/2015 06:08:59 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r31276 r31284 1630 1630 1631 1631 // Save queries by not crawling the tree in the case of multiple taxes or a flat tax. 1632 if ( ! $single_taxonomy || ! is_taxonomy_hierarchical( reset( $taxonomies ) ) ) { 1632 $has_hierarchical_tax = false; 1633 foreach ( $taxonomies as $_tax ) { 1634 if ( is_taxonomy_hierarchical( $_tax ) ) { 1635 $has_hierarchical_tax = true; 1636 } 1637 } 1638 1639 if ( ! $has_hierarchical_tax ) { 1633 1640 $args['hierarchical'] = false; 1634 1641 $args['pad_counts'] = false; … … 1964 1971 // Update term counts to include children. 1965 1972 if ( $args['pad_counts'] && 'all' == $_fields ) { 1966 _pad_term_counts( $terms, reset( $taxonomies ) ); 1973 foreach ( $taxonomies as $_tax ) { 1974 _pad_term_counts( $terms, $_tax ); 1975 } 1967 1976 } 1968 1977 // Make sure we show empty categories that have children. -
trunk/tests/phpunit/tests/term/getTerms.php
r31280 r31284 1350 1350 } 1351 1351 1352 /** 1353 * @ticket 31118 1354 */ 1355 public function test_pad_counts_should_work_when_first_taxonomy_is_nonhierarchical_and_second_taxonomy_is_hierarchical() { 1356 register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => false ) ); 1357 register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); 1358 1359 $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); 1360 $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); 1361 $t3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); 1362 1363 $posts = $this->factory->post->create_many( 3 ); 1364 wp_set_object_terms( $posts[0], $t1, 'wptests_tax1' ); 1365 wp_set_object_terms( $posts[1], $t2, 'wptests_tax2' ); 1366 wp_set_object_terms( $posts[2], $t3, 'wptests_tax2' ); 1367 1368 $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array( 1369 'pad_counts' => true, 1370 ) ); 1371 1372 $this->assertEqualSets( array( $t1, $t2, $t3 ), wp_list_pluck( $found, 'term_id' ) ); 1373 1374 foreach ( $found as $f ) { 1375 if ( $t1 == $f->term_id ) { 1376 $this->assertEquals( 1, $f->count ); 1377 } elseif ( $t2 == $f->term_id ) { 1378 $this->assertEquals( 2, $f->count ); 1379 } else { 1380 $this->assertEquals( 1, $f->count ); 1381 } 1382 } 1383 } 1384 1352 1385 protected function create_hierarchical_terms_and_posts() { 1353 1386 $terms = array();
Note: See TracChangeset
for help on using the changeset viewer.