diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
index 5846844..4175481 100644
|
|
function get_terms( $taxonomies, $args = '' ) { |
1655 | 1655 | * @param int|string $term The term to check |
1656 | 1656 | * @param string $taxonomy The taxonomy name to use |
1657 | 1657 | * @param int $parent ID of parent term under which to confine the exists search. |
1658 | | * @return mixed Returns 0 if the term does not exist. Returns the term ID if no taxonomy is specified |
1659 | | * and the term ID exists. Returns an array of the term ID and the term taxonomy ID |
1660 | | * if the taxonomy is specified and the pairing exists. |
| 1658 | * @return mixed Returns null if the term does not exist. Returns the term ID |
| 1659 | * if no taxonomy is specified and the term ID exists. Returns |
| 1660 | * an array of the term ID and the term taxonomy ID if the |
| 1661 | * taxonomy is specified and the pairing exists. |
1661 | 1662 | */ |
1662 | 1663 | function term_exists($term, $taxonomy = '', $parent = 0) { |
1663 | 1664 | global $wpdb; |
… |
… |
function term_exists($term, $taxonomy = '', $parent = 0) { |
1676 | 1677 | } |
1677 | 1678 | |
1678 | 1679 | $term = trim( wp_unslash( $term ) ); |
1679 | | |
1680 | | if ( '' === $slug = sanitize_title($term) ) |
1681 | | return 0; |
| 1680 | $slug = sanitize_title( $term ); |
1682 | 1681 | |
1683 | 1682 | $where = 't.slug = %s'; |
1684 | 1683 | $else_where = 't.name = %s'; |
diff --git tests/phpunit/tests/term.php tests/phpunit/tests/term.php
index 2576157..9ad8969 100644
|
|
class Tests_Term extends WP_UnitTestCase { |
112 | 112 | } |
113 | 113 | |
114 | 114 | public function test_term_exists_term_trimmed_to_empty_string() { |
115 | | $this->assertSame( 0, term_exists( ' ' ) ); |
| 115 | $this->assertNull( term_exists( ' ' ) ); |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * @ticket 29589 |
| 120 | */ |
| 121 | public function test_term_exists_existing_term_that_sanitizes_to_empty() { |
| 122 | wp_insert_term( '//', 'category' ); |
| 123 | $this->assertNotEmpty( term_exists( '//' ) ); |
| 124 | $this->assertNotEmpty( term_exists( '//', 'category' ) ); |
| 125 | |
| 126 | wp_insert_term( '>>', 'category' ); |
| 127 | $this->assertNotEmpty( term_exists( '>>' ) ); |
| 128 | $this->assertNotEmpty( term_exists( '>>', 'category' ) ); |
116 | 129 | } |
117 | 130 | |
118 | 131 | public function test_term_exists_taxonomy_nonempty_parent_nonempty_match_slug() { |