From 9b274f27becf22b694c8c9fb53cba75b54a2ca9b Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 21 Jul 2006 19:03:21 +0000 Subject: [PATCH] Don't let get_calendar travel into the future. Props Mark Jaquith. fixes #2961 git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@4025 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/template-functions-general.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wp-includes/template-functions-general.php b/wp-includes/template-functions-general.php index 42ef3a2143..84d83175ae 100644 --- a/wp-includes/template-functions-general.php +++ b/wp-includes/template-functions-general.php @@ -399,9 +399,11 @@ function calendar_week_mod($num) { function get_calendar($daylength = 1) { global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts; - // Quick check. If we have no posts at all, abort! + $now = current_time('mysql'); + + // Quick check. If we have no posts yet published, abort! if ( !$posts ) { - $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1"); + $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' AND post_date < '$now' ORDER BY post_date DESC LIMIT 1"); if ( !$gotsome ) return; } @@ -447,6 +449,7 @@ function get_calendar($daylength = 1) { $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year FROM $wpdb->posts WHERE post_date > '$thisyear-$thismonth-01' + AND post_date < '$now' AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) AND post_status = 'publish' ORDER BY post_date ASC