diff --git src/wp-includes/class-wp-term-query.php src/wp-includes/class-wp-term-query.php
index 37aecfd33b..8aba70a747 100644
|
|
|
class WP_Term_Query { |
| 616 | 616 | $selects = array( 'COUNT(*)' ); |
| 617 | 617 | break; |
| 618 | 618 | case 'id=>name': |
| 619 | | $selects = array( 't.term_id', 't.name', 'tt.count', 'tt.taxonomy' ); |
| | 619 | $selects = array( 't.term_id', 't.name', 'tt.parent', 'tt.count', 'tt.taxonomy' ); |
| 620 | 620 | break; |
| 621 | 621 | case 'id=>slug': |
| 622 | | $selects = array( 't.term_id', 't.slug', 'tt.count', 'tt.taxonomy' ); |
| | 622 | $selects = array( 't.term_id', 't.slug', 'tt.parent', 'tt.count', 'tt.taxonomy' ); |
| 623 | 623 | break; |
| 624 | 624 | } |
| 625 | 625 | |
diff --git tests/phpunit/tests/term/getTerms.php tests/phpunit/tests/term/getTerms.php
index 2c20a191eb..d7d3cd6e81 100644
|
|
|
class Tests_Term_getTerms extends WP_UnitTestCase { |
| 719 | 719 | $this->assertEquals( 1, count( $terms ) ); |
| 720 | 720 | } |
| 721 | 721 | |
| | 722 | /** |
| | 723 | * @ticket 46768 |
| | 724 | */ |
| | 725 | function test_get_terms_child_of_fields_id_name() { |
| | 726 | $parent = self::factory()->category->create(); |
| | 727 | $child = self::factory()->category->create( |
| | 728 | array( |
| | 729 | 'parent' => $parent, |
| | 730 | 'slug' => 'test-1', |
| | 731 | 'name' => 'Test 1', |
| | 732 | ) |
| | 733 | ); |
| | 734 | $child2 = self::factory()->category->create( |
| | 735 | array( |
| | 736 | 'parent' => $parent, |
| | 737 | 'slug' => 'test-2', |
| | 738 | 'name' => 'Test 2', |
| | 739 | ) |
| | 740 | ); |
| | 741 | |
| | 742 | $terms = get_terms( |
| | 743 | 'category', |
| | 744 | array( |
| | 745 | 'child_of' => $parent, |
| | 746 | 'hide_empty' => false, |
| | 747 | 'fields' => 'id=>name', |
| | 748 | ) |
| | 749 | ); |
| | 750 | |
| | 751 | $this->assertEquals( |
| | 752 | array( |
| | 753 | $child => 'Test 1', |
| | 754 | $child2 => 'Test 2', |
| | 755 | ), |
| | 756 | $terms |
| | 757 | ); |
| | 758 | |
| | 759 | } |
| | 760 | |
| | 761 | /** |
| | 762 | * @ticket 46768 |
| | 763 | */ |
| | 764 | function test_get_terms_child_of_fields_id_slug() { |
| | 765 | $parent = self::factory()->category->create(); |
| | 766 | $child = self::factory()->category->create( |
| | 767 | array( |
| | 768 | 'parent' => $parent, |
| | 769 | 'slug' => 'test-1', |
| | 770 | 'name' => 'Test 1', |
| | 771 | ) |
| | 772 | ); |
| | 773 | $child2 = self::factory()->category->create( |
| | 774 | array( |
| | 775 | 'parent' => $parent, |
| | 776 | 'slug' => 'test-2', |
| | 777 | 'name' => 'Test 2', |
| | 778 | ) |
| | 779 | ); |
| | 780 | |
| | 781 | $terms = get_terms( |
| | 782 | 'category', |
| | 783 | array( |
| | 784 | 'child_of' => $parent, |
| | 785 | 'hide_empty' => false, |
| | 786 | 'fields' => 'id=>slug', |
| | 787 | ) |
| | 788 | ); |
| | 789 | |
| | 790 | $this->assertEquals( |
| | 791 | array( |
| | 792 | $child => 'test-1', |
| | 793 | $child2 => 'test-2', |
| | 794 | ), |
| | 795 | $terms |
| | 796 | ); |
| | 797 | } |
| | 798 | |
| 722 | 799 | /** |
| 723 | 800 | * @ticket 31118 |
| 724 | 801 | */ |