Changeset 34998
- Timestamp:
- 10/10/2015 02:12:40 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy-functions.php
r34997 r34998 992 992 * @since 4.2.0 Introduced 'name' and 'childless' parameters. 993 993 * @since 4.4.0 Introduced the ability to pass 'term_id' as an alias of 'id' for the `orderby` parameter. 994 * Introduced the 'meta_query' and 'update_term_meta_cache' parameters. 994 * Introduced the 'meta_query' and 'update_term_meta_cache' parameters. Converted to return 995 * a list of WP_Term objects. 995 996 * 996 997 * @global wpdb $wpdb WordPress database abstraction object. … … 1053 1054 * See `WP_Meta_Query`. Default empty. 1054 1055 * } 1055 * @return array|int|WP_Error List of Term Objects and their children. Will return WP_Error, if any of $taxonomies1056 * do not exist.1056 * @return array|int|WP_Error List of WP_Term instances and their children. Will return WP_Error, if any of $taxonomies 1057 * do not exist. 1057 1058 */ 1058 1059 function get_terms( $taxonomies, $args = '' ) { … … 1494 1495 $_terms[ $term->term_id ] = $term->slug; 1495 1496 } 1497 } else { 1498 $_terms = array_map( 'get_term', $terms ); 1496 1499 } 1497 1500 -
trunk/tests/phpunit/tests/term/getTerms.php
r34828 r34998 1573 1573 } 1574 1574 1575 /** 1576 * @ticket 14162 1577 */ 1578 public function test_should_return_wp_term_objects() { 1579 register_taxonomy( 'wptests_tax', 'post' ); 1580 $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); 1581 1582 $found = get_terms( 'wptests_tax', array( 1583 'hide_empty' => false, 1584 'fields' => 'all', 1585 ) ); 1586 1587 $this->assertNotEmpty( $found ); 1588 1589 foreach ( $found as $term ) { 1590 $this->assertInstanceOf( 'WP_Term', $term ); 1591 } 1592 } 1593 1594 /** 1595 * @ticket 14162 1596 */ 1597 public function test_should_prime_individual_term_cache_when_fields_is_all() { 1598 global $wpdb; 1599 1600 register_taxonomy( 'wptests_tax', 'post' ); 1601 $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); 1602 1603 $found = get_terms( 'wptests_tax', array( 1604 'hide_empty' => false, 1605 'fields' => 'all', 1606 ) ); 1607 1608 $num_queries = $wpdb->num_queries; 1609 $term0 = get_term( $terms[0] ); 1610 $this->assertSame( $num_queries, $wpdb->num_queries ); 1611 1612 } 1613 1575 1614 protected function create_hierarchical_terms_and_posts() { 1576 1615 $terms = array();
Note: See TracChangeset
for help on using the changeset viewer.