Changeset 29863
- Timestamp:
- 10/09/2014 02:48:47 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r29862 r29863 1656 1656 * @param int|string $term The term to check 1657 1657 * @param string $taxonomy The taxonomy name to use 1658 * @param int $parent ID of parent term under which to confine the exists search.1658 * @param int $parent Optional. ID of parent term under which to confine the exists search. 1659 1659 * @return mixed Returns 0 if the term does not exist. Returns the term ID if no taxonomy is specified 1660 1660 * and the term ID exists. Returns an array of the term ID and the term taxonomy ID 1661 1661 * if the taxonomy is specified and the pairing exists. 1662 1662 */ 1663 function term_exists( $term, $taxonomy = '', $parent = 0) {1663 function term_exists( $term, $taxonomy = '', $parent = null ) { 1664 1664 global $wpdb; 1665 1665 … … 1687 1687 $else_where_fields = array($term); 1688 1688 if ( !empty($taxonomy) ) { 1689 $parent = (int) $parent;1690 if ( $parent > 0 ) {1689 if ( is_numeric( $parent ) ) { 1690 $parent = (int) $parent; 1691 1691 $where_fields[] = $parent; 1692 1692 $else_where_fields[] = $parent; -
trunk/tests/phpunit/tests/term.php
r29862 r29863 137 137 $this->assertInternalType( 'array', $found ); 138 138 $this->assertEquals( $t, $found['term_id'] ); 139 } 140 141 /** 142 * @ticket 29851 143 */ 144 public function test_term_exists_taxonomy_nonempty_parent_0_should_return_false_for_child_term() { 145 register_taxonomy( 'foo', 'post', array( 146 'hierarchical' => true, 147 ) ); 148 149 $parent_term = $this->factory->term->create( array( 150 'taxonomy' => 'foo', 151 ) ); 152 153 $t = $this->factory->term->create( array( 154 'taxonomy' => 'foo', 155 'parent' => $parent_term, 156 'slug' => 'child-term', 157 ) ); 158 159 $found = term_exists( 'child-term', 'foo', 0 ); 160 161 _unregister_taxonomy( 'foo' ); 162 163 $this->assertSame( null, $found['term_id'] ); 139 164 } 140 165
Note: See TracChangeset
for help on using the changeset viewer.