diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
index 6760ffe..2f46b2e 100644
|
|
function get_terms( $taxonomies, $args = '' ) { |
1842 | 1842 | } |
1843 | 1843 | |
1844 | 1844 | if ( ! empty( $args['name'] ) ) { |
1845 | | if ( is_array( $args['name'] ) ) { |
1846 | | $name = array_map( 'sanitize_text_field', $args['name'] ); |
1847 | | $where .= " AND t.name IN ('" . implode( "', '", array_map( 'esc_sql', $name ) ) . "')"; |
1848 | | } else { |
1849 | | $name = sanitize_text_field( $args['name'] ); |
1850 | | $where .= $wpdb->prepare( " AND t.name = %s", $name ); |
| 1845 | $names = (array) $args['name']; |
| 1846 | foreach ( $names as &$_name ) { |
| 1847 | $_name = sanitize_term_field( 'name', $_name, 0, reset( $taxonomies ), 'db' ); |
1851 | 1848 | } |
| 1849 | |
| 1850 | $where .= " AND t.name IN ('" . implode( "', '", array_map( 'esc_sql', $names ) ) . "')"; |
1852 | 1851 | } |
1853 | 1852 | |
1854 | 1853 | if ( ! empty( $args['slug'] ) ) { |
diff --git tests/phpunit/tests/term/getTerms.php tests/phpunit/tests/term/getTerms.php
index 2dbbaff..333e87e 100644
|
|
class Tests_Term_getTerms extends WP_UnitTestCase { |
541 | 541 | } |
542 | 542 | |
543 | 543 | /** |
| 544 | * @ticket 32248 |
| 545 | */ |
| 546 | public function test_name_should_match_encoded_html_entities() { |
| 547 | register_taxonomy( 'wptests_tax', 'post' ); |
| 548 | |
| 549 | $t = $this->factory->term->create( array( |
| 550 | 'taxonomy' => 'wptests_tax', |
| 551 | 'name' => 'Foo & Bar', |
| 552 | 'slug' => 'foo-and-bar', |
| 553 | ) ); |
| 554 | |
| 555 | $found = get_terms( 'wptests_tax', array( |
| 556 | 'hide_empty' => false, |
| 557 | 'fields' => 'ids', |
| 558 | 'name' => 'Foo & Bar', |
| 559 | ) ); |
| 560 | $this->assertEqualSets( array( $t ), $found ); |
| 561 | |
| 562 | // array format. |
| 563 | $found = get_terms( 'wptests_tax', array( |
| 564 | 'hide_empty' => false, |
| 565 | 'fields' => 'ids', |
| 566 | 'name' => array( 'Foo & Bar' ), |
| 567 | ) ); |
| 568 | $this->assertEqualSets( array( $t ), $found ); |
| 569 | } |
| 570 | |
| 571 | /** |
544 | 572 | * @ticket 29839 |
545 | 573 | */ |
546 | 574 | public function test_childless_should_return_all_terms_for_flat_hierarchy() { |