Changeset 15819 for trunk/wp-includes/query.php
- Timestamp:
- 10/15/2010 07:44:57 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/query.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r15803 r15819 122 122 123 123 /** 124 * Is the query for a post type archive page? 125 * 126 * @see WP_Query::is_post_type_archive() 127 * @since 3.1.0 128 * @uses $wp_query 129 * 130 * @param mixed $post_types Optional. Post type or array of posts types to check against. 131 * @return bool 132 */ 133 function is_post_type_archive( $post_types = '' ) { 134 global $wp_query; 135 136 return $wp_query->is_post_type_archive( $post_types ); 137 } 138 139 /** 124 140 * Is the query for an attachment page? 125 141 * … … 1040 1056 */ 1041 1057 var $is_posts_page = false; 1058 1059 /** 1060 * Set if query is for a post type archive. 1061 * 1062 * @since 3.1.0 1063 * @access public 1064 * @var bool 1065 */ 1066 var $is_post_type_archive = false; 1042 1067 1043 1068 /** … … 1076 1101 $this->is_robots = false; 1077 1102 $this->is_posts_page = false; 1103 $this->is_post_type_archive = false; 1078 1104 } 1079 1105 … … 1235 1261 $this->is_single = false; 1236 1262 } else { 1237 // Look for archive queries. Dates, categories, authors, search .1263 // Look for archive queries. Dates, categories, authors, search, post type archives. 1238 1264 1239 1265 if ( !empty($qv['s']) ) { … … 1307 1333 $this->is_author = true; 1308 1334 1309 if ( !empty( $qv['post_type'] ) ) 1310 $this->is_archive = true; 1311 1312 if ( $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax ) 1335 if ( !empty( $qv['post_type'] ) && ! is_array( $qv['post_type'] ) ) { 1336 $post_type_obj = get_post_type_object( $qv['post_type'] ); 1337 if ( is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['archive'] ) 1338 $this->is_post_type_archive = true; 1339 } 1340 1341 if ( $this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax ) 1313 1342 $this->is_archive = true; 1314 1343 } … … 2637 2666 2638 2667 /** 2668 * Is the query for a post type archive page? 2669 * 2670 * @since 3.1.0 2671 * 2672 * @param mixed $post_types Optional. Post type or array of posts types to check against. 2673 * @return bool 2674 */ 2675 function is_post_type_archive( $post_types = '' ) { 2676 if ( empty( $post_types ) || !$this->is_post_type_archive ) 2677 return (bool) $this->is_post_type_archive; 2678 2679 if ( ! isset( $this->posts[0] ) ) 2680 return false; 2681 2682 $post = $this->posts[0]; 2683 2684 return in_array( $post->post_type, (array) $post_types ); 2685 } 2686 2687 /** 2639 2688 * Is the query for an attachment page? 2640 2689 *
Note: See TracChangeset
for help on using the changeset viewer.