- Timestamp:
- 01/02/2015 09:33:33 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/category-template.php
r31006 r31024 377 377 $tab_index_attribute = " tabindex=\"$tab_index\""; 378 378 } 379 $categories = get_terms( $r['taxonomy'], $r ); 379 380 // Avoid clashes with the 'name' param of get_terms(). 381 $get_terms_args = $r; 382 unset( $get_terms_args['name'] ); 383 $categories = get_terms( $r['taxonomy'], $get_terms_args ); 384 380 385 $name = esc_attr( $r['name'] ); 381 386 $class = esc_attr( $r['class'] ); -
trunk/src/wp-includes/taxonomy.php
r31012 r31024 1549 1549 * 1550 1550 * @since 2.3.0 1551 * @since 4.2.0 Introduced 'name' parameter. 1551 1552 * 1552 1553 * @global wpdb $wpdb WordPress database abstraction object. … … 1579 1580 * term objects), 'ids' or 'names' (returns an array of integers 1580 1581 * or strings, respectively. Default 'all'. 1582 * @type string|array $name Optional. Name or array of names to return term(s) for. Default empty. 1581 1583 * @type string|array $slug Optional. Slug or array of slugs to return term(s) for. Default empty. 1582 1584 * @type bool $hierarchical Whether to include terms that have non-empty descendants (even … … 1619 1621 $defaults = array('orderby' => 'name', 'order' => 'ASC', 1620 1622 'hide_empty' => true, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(), 1621 'number' => '', 'fields' => 'all', ' slug' => '', 'parent' => '',1623 'number' => '', 'fields' => 'all', 'name' => '', 'slug' => '', 'parent' => '', 1622 1624 'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '', 'description__like' => '', 1623 1625 'pad_counts' => false, 'offset' => '', 'search' => '', 'cache_domain' => 'core' ); … … 1794 1796 if ( ! empty( $exclusions ) ) { 1795 1797 $where .= $exclusions; 1798 } 1799 1800 if ( ! empty( $args['name'] ) ) { 1801 if ( is_array( $args['name'] ) ) { 1802 $name = array_map( 'sanitize_text_field', $args['name'] ); 1803 $where .= " AND t.name IN ('" . implode( "', '", $name ) . "')"; 1804 } else { 1805 $name = sanitize_text_field( $args['name'] ); 1806 $where .= $wpdb->prepare( " AND t.name = %s", $name ); 1807 } 1796 1808 } 1797 1809 -
trunk/tests/phpunit/tests/term/getTerms.php
r30688 r31024 423 423 424 424 $this->assertEquals( array( $t1, $t3 ), $found ); 425 } 426 427 /** 428 * @ticket 30611 429 */ 430 public function test_get_terms_by_name() { 431 $t1 = $this->factory->tag->create( array( 'name' => 'Foo' ) ); 432 $t2 = $this->factory->tag->create( array( 'name' => 'Bar' ) ); 433 434 $found = get_terms( 'post_tag', array( 435 'hide_empty' => false, 436 'fields' => 'ids', 437 'name' => 'Foo', 438 ) ); 439 440 $this->assertEquals( array( $t1 ), $found ); 441 } 442 443 /** 444 * @ticket 30611 445 */ 446 public function test_get_terms_by_multiple_names() { 447 $t1 = $this->factory->tag->create( array( 'name' => 'Foo' ) ); 448 $t2 = $this->factory->tag->create( array( 'name' => 'Bar' ) ); 449 $t3 = $this->factory->tag->create( array( 'name' => 'Barry' ) ); 450 451 $found = get_terms( 'post_tag', array( 452 'hide_empty' => false, 453 'fields' => 'ids', 454 'name' => array( 'Foo', 'Barry' ) 455 ) ); 456 457 $this->assertEqualSets( array( $t3, $t1 ), $found ); 425 458 } 426 459
Note: See TracChangeset
for help on using the changeset viewer.