Ticket #15773: 15773.diff
| File 15773.diff, 5.3 KB (added by scribu, 2 years ago) |
|---|
-
wp-includes/query.php
1063 1063 var $is_attachment = false; 1064 1064 1065 1065 /** 1066 * Set if is single, is a page, or is an attachment.1067 *1068 * @since 2.1.01069 * @access public1070 * @var bool1071 */1072 var $is_singular = false;1073 1074 /**1075 1066 * Set if query is for robots. 1076 1067 * 1077 1068 * @since 2.1.0 … … 1101 1092 var $is_post_type_archive = false; 1102 1093 1103 1094 /** 1095 * Used by comments_template() 1096 * 1097 * @since 3.2.0 1098 * @access public 1099 * @var bool 1100 */ 1101 var $comments_by_type; 1102 1103 /** 1104 * Overloading, to access deprecated query flags 1105 * 1106 * The query flags are what page info WordPress was able to figure out. 1107 * 1108 * @since 3.2.0 1109 * @access public 1110 */ 1111 function __get( $key ) { 1112 if ( 'is_singular' == $key ) { 1113 _deprecated_argument( __CLASS__, '3.2', 'Use the is_singular() method instead.' ); 1114 return $this->is_singular(); 1115 } 1116 } 1117 1118 /** 1104 1119 * Resets query flags to false. 1105 1120 * 1106 1121 * The query flags are what page info WordPress was able to figure out. … … 1132 1147 $this->is_paged = false; 1133 1148 $this->is_admin = false; 1134 1149 $this->is_attachment = false; 1135 $this->is_singular = false;1136 1150 $this->is_robots = false; 1137 1151 $this->is_posts_page = false; 1138 1152 $this->is_post_type_archive = false; … … 1402 1416 $qv['withcomments'] = 1; 1403 1417 } 1404 1418 1405 $this->is_singular = $this->is_single || $this->is_page || $this->is_attachment; 1406 1407 if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) ) 1419 if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular() ) ) ) 1408 1420 $this->is_comment_feed = true; 1409 1421 1410 if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup || $this->is_robots ) )1422 if ( !( $this->is_singular() || $this->is_archive || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup || $this->is_robots ) ) 1411 1423 $this->is_home = true; 1412 1424 1413 1425 // Correct is_* for page_on_front and page_for_posts … … 1460 1472 if ( $this->is_posts_page && ( ! isset($qv['withcomments']) || ! $qv['withcomments'] ) ) 1461 1473 $this->is_comment_feed = false; 1462 1474 1463 $this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;1464 1475 // Done correcting is_* for page_on_front and page_for_posts 1465 1476 1466 1477 if ( '404' == $qv['error'] ) … … 1523 1534 } 1524 1535 1525 1536 // Category stuff 1526 if ( !empty($q['cat']) && '0' != $q['cat'] && !$this->is_singular ) {1537 if ( !empty($q['cat']) && '0' != $q['cat'] && !$this->is_singular() ) { 1527 1538 $q['cat'] = ''.urldecode($q['cat']).''; 1528 1539 $q['cat'] = addslashes_gpc($q['cat']); 1529 1540 $cat_array = preg_split('/[,\s]+/', $q['cat']); … … 2187 2198 } 2188 2199 foreach ( $statuswheres as $statuswhere ) 2189 2200 $where .= " AND $statuswhere"; 2190 } elseif ( !$this->is_singular ) {2201 } elseif ( !$this->is_singular() ) { 2191 2202 $where .= " AND ($wpdb->posts.post_status = 'publish'"; 2192 2203 2193 2204 // Add public states. … … 2229 2240 } 2230 2241 2231 2242 // Paging 2232 if ( empty($q['nopaging']) && !$this->is_singular ) {2243 if ( empty($q['nopaging']) && !$this->is_singular() ) { 2233 2244 $page = absint($q['paged']); 2234 2245 if ( empty($page) ) 2235 2246 $page = 1; … … 2246 2257 } 2247 2258 2248 2259 // Comments feeds 2249 if ( $this->is_comment_feed && ( $this->is_archive || $this->is_search || !$this->is_singular ) ) {2260 if ( $this->is_comment_feed && ( $this->is_archive || $this->is_search || !$this->is_singular() ) ) { 2250 2261 if ( $this->is_archive || $this->is_search ) { 2251 2262 $cjoin = "JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) $join "; 2252 2263 $cwhere = "WHERE comment_approved = '1' $where"; … … 2358 2369 if ( !$q['suppress_filters'] ) 2359 2370 $this->posts = apply_filters_ref_array('posts_results', array( $this->posts, &$this ) ); 2360 2371 2361 if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {2372 if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular() ) { 2362 2373 $cjoin = apply_filters_ref_array('comment_feed_join', array( '', &$this ) ); 2363 2374 $cwhere = apply_filters_ref_array('comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) ); 2364 2375 $cgroupby = apply_filters_ref_array('comment_feed_groupby', array( '', &$this ) ); … … 2674 2685 $page_for_posts = get_option('page_for_posts'); 2675 2686 $this->queried_object = & get_page( $page_for_posts ); 2676 2687 $this->queried_object_id = (int) $this->queried_object->ID; 2677 } elseif ( $this->is_singular && !is_null($this->post) ) {2688 } elseif ( $this->is_singular() && !is_null($this->post) ) { 2678 2689 $this->queried_object = $this->post; 2679 2690 $this->queried_object_id = (int) $this->post->ID; 2680 2691 } elseif ( $this->is_author ) { … … 3147 3158 * @return bool 3148 3159 */ 3149 3160 function is_singular( $post_types = '' ) { 3150 if ( empty( $post_types ) || !$this->is_singular ) 3151 return (bool) $this->is_singular; 3161 $is_singular = $this->is_single || $this->is_page || $this->is_attachment; 3152 3162 3163 if ( empty( $post_types ) || !$is_singular ) 3164 return $is_singular; 3165 3153 3166 $post_obj = $this->get_queried_object(); 3154 3167 3155 3168 return in_array( $post_obj->post_type, (array) $post_types );
