From 7abc853b0bc649115e41536459afab7d439ed310 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Mon, 17 Mar 2014 20:23:07 +1100 Subject: [PATCH] Display all events in calendar when no ID is given --- admin/templates/events-calendar.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/admin/templates/events-calendar.php b/admin/templates/events-calendar.php index 466764d0..b5df163b 100644 --- a/admin/templates/events-calendar.php +++ b/admin/templates/events-calendar.php @@ -5,9 +5,20 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) { global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; // Quick check. If we have no posts at all, abort! - if ( !$posts ) + if ( ! $posts ) return; + if ( $id ): + $events = sportspress_get_calendar_data( $id ); + $event_ids = array(); + foreach ( $events as $event ): + $event_ids[] = $event->ID; + endforeach; + $in = 'AND ID IN (' . implode( ', ', $event_ids ) . ')'; + else: + $in = ''; + endif; + $caption_tag = ( $single ? 'h4' : 'caption' ); // week_begins = 0 stands for Sunday @@ -45,12 +56,14 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) { FROM $wpdb->posts WHERE post_date < '$thisyear-$thismonth-01' AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' ) + $in ORDER BY post_date DESC LIMIT 1"); $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year FROM $wpdb->posts WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59' AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' ) + $in ORDER BY post_date ASC LIMIT 1"); @@ -106,6 +119,7 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) { $dayswithposts = $wpdb->get_results("SELECT DAYOFMONTH(post_date), ID FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' ) + $in AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N); if ( $dayswithposts ) { foreach ( (array) $dayswithposts as $daywith ) { @@ -125,7 +139,8 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) { ."FROM $wpdb->posts " ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' " ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' " - ."AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' )" + ."AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' ) " + ."$in" ); if ( $ak_post_titles ) { foreach ( (array) $ak_post_titles as $ak_post_title ) {