diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index f64aac0da9..4fdd4888a2 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -1366,9 +1366,9 @@ function get_terms($taxonomies, $args = '') { $limits = ''; } - if ( !empty($search) ) { - $search = like_escape($search); - $where .= $wpdb->prepare( " AND (t.name LIKE %s)", '%' . $search . '%'); + if ( ! empty( $search ) ) { + $search = like_escape( $search ); + $where .= $wpdb->prepare( ' AND ((t.name LIKE %s) OR (t.slug LIKE %s))', '%' . $search . '%', '%' . $search . '%' ); } $selects = array(); diff --git a/tests/tests/term/getTerms.php b/tests/tests/term/getTerms.php index 82ce9a7dbf..2a946be693 100644 --- a/tests/tests/term/getTerms.php +++ b/tests/tests/term/getTerms.php @@ -139,4 +139,15 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ) ); $this->assertEquals( array(), wp_list_pluck( $exc_terms, 'term_id' ) ); } + + /** + * @ticket 13992 + */ + function test_get_terms_search() { + $term_id1 = $this->factory->tag->create( array( 'slug' => 'burrito' ) ); + $term_id2 = $this->factory->tag->create( array( 'name' => 'Wilbur' ) ); + + $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'search' => 'bur', 'fields' => 'ids' ) ); + $this->assertEqualSets( array( $term_id1, $term_id2 ), $terms ); + } }