Changeset 25287
- Timestamp:
- 09/06/2013 05:26:04 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/query.php
r25280 r25287 247 247 * @uses $wp_query 248 248 * 249 * @param mixed $ slug Optional. Tag slug or array ofslugs.249 * @param mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs. 250 250 * @return bool 251 251 */ 252 function is_tag( $ slug = '' ) {252 function is_tag( $tag = '' ) { 253 253 global $wp_query; 254 254 … … 258 258 } 259 259 260 return $wp_query->is_tag( $ slug );260 return $wp_query->is_tag( $tag ); 261 261 } 262 262 … … 3239 3239 * @since 3.1.0 3240 3240 * 3241 * @param mixed $ slug Optional. Tag slug or array ofslugs.3241 * @param mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs. 3242 3242 * @return bool 3243 3243 */ 3244 function is_tag( $ slug = '' ) {3245 if ( ! $this->is_tag )3244 function is_tag( $tag = '' ) { 3245 if ( ! $this->is_tag ) 3246 3246 return false; 3247 3247 3248 if ( empty( $ slug ) )3248 if ( empty( $tag ) ) 3249 3249 return true; 3250 3250 3251 3251 $tag_obj = $this->get_queried_object(); 3252 3252 3253 $slug = (array) $slug; 3254 3255 if ( in_array( $tag_obj->slug, $slug ) ) 3253 $tag = (array) $tag; 3254 3255 if ( in_array( $tag_obj->term_id, $tag ) ) 3256 return true; 3257 elseif ( in_array( $tag_obj->name, $tag ) ) 3258 return true; 3259 elseif ( in_array( $tag_obj->slug, $tag ) ) 3256 3260 return true; 3257 3261 -
trunk/tests/phpunit/tests/query/conditionals.php
r25280 r25287 429 429 // 'tag/(.+?)/?$' => 'index.php?tag=$matches[1]', 430 430 function test_tag() { 431 $t his->factory->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) );431 $term_id = $this->factory->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) ); 432 432 $this->go_to('/tag/tag-a/'); 433 433 $this->assertQueryTrue('is_archive', 'is_tag'); 434 435 $tag = get_term( $term_id, 'post_tag' ); 436 437 $this->assertTrue( is_tag() ); 438 $this->assertTrue( is_tag( $tag->name ) ); 439 $this->assertTrue( is_tag( $tag->slug ) ); 440 $this->assertTrue( is_tag( $tag->term_id ) ); 441 $this->assertTrue( is_tag( array() ) ); 442 $this->assertTrue( is_tag( array( $tag->name ) ) ); 443 $this->assertTrue( is_tag( array( $tag->slug ) ) ); 444 $this->assertTrue( is_tag( array( $tag->term_id ) ) ); 434 445 } 435 446
Note: See TracChangeset
for help on using the changeset viewer.