From f49d282eb3627a251f5c37e518d4e048fac82ac3 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Mon, 27 May 2019 20:07:06 +1000 Subject: [PATCH] Simplify fix for events other than publish and future being queried in calendar --- includes/class-sp-calendar.php | 2 +- includes/sp-core-functions.php | 3 +-- templates/event-list.php | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/includes/class-sp-calendar.php b/includes/class-sp-calendar.php index cebd060e..6a4aee61 100644 --- a/includes/class-sp-calendar.php +++ b/includes/class-sp-calendar.php @@ -154,7 +154,6 @@ class SP_Calendar extends SP_Secondary_Post { 'posts_per_page' => $this->number, 'orderby' => $this->orderby, 'order' => $this->order, - 'post_status' => $this->status, 'meta_query' => array( 'relation' => 'AND' ), @@ -416,6 +415,7 @@ class SP_Calendar extends SP_Secondary_Post { $events = array_merge_recursive( $results, $fixtures ); } else { + $args['post_status'] = $this->status == 'any' ? array('publish', 'future') : explode ( ',', $this->status ); $events = get_posts( $args ); } diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index 21c6a6f7..e1649e9c 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -653,8 +653,7 @@ if ( !function_exists( 'sp_dropdown_statuses' ) ) { $statuses = apply_filters( 'sportspress_statuses', array( 'any' => __( 'All', 'sportspress' ), 'publish' => __( 'Published', 'sportspress' ), - 'future' => __( 'Scheduled', 'sportspress' ), - 'publish,future' => __( 'Published + Scheduled', 'sportspress' ) + 'future' => __( 'Scheduled', 'sportspress' ) )); foreach ( $statuses as $value => $label ): diff --git a/templates/event-list.php b/templates/event-list.php index f0fa9bf9..1e68632e 100644 --- a/templates/event-list.php +++ b/templates/event-list.php @@ -49,8 +49,7 @@ $defaults = array( extract( $defaults, EXTR_SKIP ); $calendar = new SP_Calendar( $id ); -$status = explode ( ',', $status ); -if ( $status[0] != 'default' ) +if ( $status != 'default' ) $calendar->status = $status; if ( $format != 'default' ) $calendar->event_format = $format;