Ticket #12588: is_singular.3.diff
File is_singular.3.diff, 1.8 KB (added by , 14 years ago) |
---|
-
wp-includes/query.php
134 134 * @param string|int $author Optional. Is current page this author. 135 135 * @return bool True if page is author or $author (if set). 136 136 */ 137 function is_author 137 function is_author($author = '') { 138 138 global $wp_query; 139 139 140 140 if ( !$wp_query->is_author ) … … 169 169 * @param string|array $category Optional. 170 170 * @return bool 171 171 */ 172 function is_category 172 function is_category($category = '') { 173 173 global $wp_query; 174 174 175 175 if ( !$wp_query->is_category ) … … 398 398 * @param mixed $page Either page or list of pages to test against. 399 399 * @return bool 400 400 */ 401 function is_page 401 function is_page($page = '') { 402 402 global $wp_query; 403 403 404 404 if ( !$wp_query->is_page ) … … 518 518 if ( !$wp_query->is_single ) 519 519 return false; 520 520 521 if ( empty( 521 if ( empty($post) ) 522 522 return true; 523 523 524 524 $post_obj = $wp_query->get_queried_object(); … … 541 541 * @since 1.5.0 542 542 * @uses $wp_query 543 543 * 544 * @param string|array $post_types Optional. Post type or types to check in current query. 544 545 * @return bool 545 546 */ 546 function is_singular( ) {547 function is_singular($post_types = '') { 547 548 global $wp_query; 548 549 549 return $wp_query->is_singular; 550 if ( empty($post_types) ) 551 return $wp_query->is_singular; 552 553 $post_obj = $wp_query->get_queried_object(); 554 555 return $wp_query->is_single && in_array($post_obj->post_type, (array) $post_types); 550 556 } 551 557 552 558 /** … … 1226 1232 * 1227 1233 * @param string|array $query 1228 1234 */ 1229 function parse_query($query 1235 function parse_query($query) { 1230 1236 if ( !empty($query) || !isset($this->query) ) { 1231 1237 $this->init(); 1232 1238 if ( is_array($query) )