diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php index a2d1205f..32c7bf8e 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php @@ -71,6 +71,7 @@ class SP_Meta_Box_Calendar_Details {

+ diff --git a/includes/class-sp-calendar.php b/includes/class-sp-calendar.php index 75ca80e7..81b44434 100644 --- a/includes/class-sp-calendar.php +++ b/includes/class-sp-calendar.php @@ -134,22 +134,54 @@ class SP_Calendar extends SP_Secondary_Post { ); if ( $this->date !== 0 ): - if ( $this->date == 'w' ): - $args['year'] = date_i18n('Y'); - $args['w'] = date_i18n('W'); - elseif ( $this->date == 'day' ): - $args['year'] = date_i18n('Y'); - $args['day'] = date_i18n('j'); - $args['monthnum'] = date_i18n('n'); - elseif ( $this->date == 'range' ): - if ( $this->relative ): - add_filter( 'posts_where', array( $this, 'relative' ) ); - else: - add_filter( 'posts_where', array( $this, 'range' ) ); - endif; - endif; + switch ( $this->date ): + case '-day': + $date = new DateTime( date_i18n('Y-m-d') ); + $date->modify( '-1 day' ); + $args['year'] = $date->format('Y'); + $args['day'] = $date->format('j'); + $args['monthnum'] = $date->format('n'); + break; + case 'day': + $args['year'] = date_i18n('Y'); + $args['day'] = date_i18n('j'); + $args['monthnum'] = date_i18n('n'); + break; + case '+day': + $date = new DateTime( date_i18n('Y-m-d') ); + $date->modify( '+1 day' ); + $args['year'] = $date->format('Y'); + $args['day'] = $date->format('j'); + $args['monthnum'] = $date->format('n'); + break; + case '-w': + $date = new DateTime( date_i18n('Y-m-d') ); + $date->modify( '-1 week' ); + $args['year'] = $date->format('Y'); + $args['w'] = $date->format('W'); + break; + case 'w': + $args['year'] = date_i18n('Y'); + $args['w'] = date_i18n('W'); + break; + case '+w': + $date = new DateTime( date_i18n('Y-m-d') ); + $date->modify( '+1 week' ); + $args['year'] = $date->format('Y'); + $args['w'] = $date->format('W'); + break; + case 'range': + if ( $this->relative ): + add_filter( 'posts_where', array( $this, 'relative' ) ); + else: + add_filter( 'posts_where', array( $this, 'range' ) ); + endif; + break; + endswitch; endif; + pr( $args ); + if ( $this->league ): $league_ids = array( $this->league ); endif; diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index 672b7a5b..9b8844ca 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -615,8 +615,12 @@ if ( !function_exists( 'sp_dropdown_dates' ) ) { $dates = apply_filters( 'sportspress_dates', array( 0 => __( 'All', 'sportspress' ), - 'w' => __( 'This week', 'sportspress' ), + '-day' => __( 'Yesterday', 'sportspress' ), 'day' => __( 'Today', 'sportspress' ), + '+day' => __( 'Tomorrow', 'sportspress' ), + '-w' => __( 'Last week', 'sportspress' ), + 'w' => __( 'This week', 'sportspress' ), + '+w' => __( 'Next week', 'sportspress' ), 'range' => __( 'Date range:', 'sportspress' ), ));