Ticket #15202: 15202.2.patch
File 15202.2.patch, 2.5 KB (added by , 11 years ago) |
---|
-
src/wp-includes/general-template.php
1148 1148 if ( !is_array($cache) ) 1149 1149 $cache = array(); 1150 1150 1151 $join = apply_filters( 'getcalendar_join', '' ); 1152 $where = apply_filters( 'getcalendar_where', "AND post_type = 'post' AND post_status = 'publish'" ); 1153 1151 1154 // Quick check. If we have no posts at all, abort! 1152 1155 if ( !$posts ) { 1153 $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'LIMIT 1");1156 $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts $join WHERE 1=1 $where LIMIT 1"); 1154 1157 if ( !$gotsome ) { 1155 1158 $cache[ $key ] = ''; 1156 1159 wp_cache_set( 'get_calendar', $cache, 'calendar' ); … … 1189 1192 1190 1193 // Get the next and previous month and year with at least one post 1191 1194 $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year 1192 FROM $wpdb->posts 1195 FROM $wpdb->posts $join 1193 1196 WHERE post_date < '$thisyear-$thismonth-01' 1194 AND post_type = 'post' AND post_status = 'publish'1197 $where 1195 1198 ORDER BY post_date DESC 1196 1199 LIMIT 1"); 1197 1200 $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year 1198 FROM $wpdb->posts 1201 FROM $wpdb->posts $join 1199 1202 WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59' 1200 AND post_type = 'post' AND post_status = 'publish'1203 $where 1201 1204 ORDER BY post_date ASC 1202 1205 LIMIT 1"); 1203 1206 … … 1250 1253 1251 1254 // Get days with posts 1252 1255 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) 1253 FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' 1254 AND post_type = 'post' AND post_status = 'publish' 1256 FROM $wpdb->posts $join 1257 WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' 1258 $where 1255 1259 AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N); 1256 1260 if ( $dayswithposts ) { 1257 1261 foreach ( (array) $dayswithposts as $daywith ) { … … 1268 1272 1269 1273 $ak_titles_for_day = array(); 1270 1274 $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom " 1271 ."FROM $wpdb->posts "1275 ."FROM $wpdb->posts $join " 1272 1276 ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' " 1273 1277 ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' " 1274 . "AND post_type = 'post' AND post_status = 'publish'"1278 .$where 1275 1279 ); 1276 1280 if ( $ak_post_titles ) { 1277 1281 foreach ( (array) $ak_post_titles as $ak_post_title ) {