diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php index 28acfb73..f1d80110 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php @@ -80,82 +80,92 @@ class SP_Meta_Box_Calendar_Data {
0 ): - $main_result = get_option( 'sportspress_primary_result', null ); - $i = 0; - foreach ( $data as $event ): - $teams = get_post_meta( $event->ID, 'sp_team' ); - $results = get_post_meta( $event->ID, 'sp_results', true ); - $video = get_post_meta( $event->ID, 'sp_video', true ); - $main_results = array(); - ?> -+
+ 'sp_date', + 'id' => 'sp_date', + 'selected' => $date, + ); + sp_dropdown_dates( $args ); + ?> +
status = $this->__get( 'status' ); + $this->date = $this->__get( 'date' ); $this->order = $this->__get( 'order' ); if ( ! $this->status ) $this->status = 'any'; + if ( ! $this->date ) + $this->date = 0; + if ( ! $this->order ) $this->order = 'ASC'; } @@ -64,6 +71,16 @@ class SP_Calendar extends SP_Custom_Post { ), ); + if ( $this->date !== 0 ): + $args['year'] = date('Y'); + if ( $this->date == 'w' ): + $args['w'] = date('W'); + elseif ( $this->date == 'day' ): + $args['day'] = date('j'); + $args['monthnum'] = date('n'); + endif; + endif; + if ( $pagenow != 'post-new.php' ): if ( $this->ID ): $leagues = get_the_terms( $this->ID, 'sp_league' ); @@ -121,7 +138,7 @@ class SP_Calendar extends SP_Custom_Post { $events = get_posts( $args ); else: - $events = array(); + $events = null; endif; return $events; diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index 9ff23fec..5f51ba53 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -389,6 +389,37 @@ if ( !function_exists( 'sp_dropdown_statuses' ) ) { } } +if ( !function_exists( 'sp_dropdown_dates' ) ) { + function sp_dropdown_dates( $args = array() ) { + $defaults = array( + 'show_option_default' => false, + 'name' => 'sp_date', + 'id' => null, + 'selected' => null, + 'class' => null, + ); + $args = array_merge( $defaults, $args ); + + printf( '' ); + return true; + } +} + if ( !function_exists( 'sp_dropdown_taxonomies' ) ) { function sp_dropdown_taxonomies( $args = array() ) { $defaults = array( diff --git a/templates/event-calendar.php b/templates/event-calendar.php index 4952ee23..897325fb 100644 --- a/templates/event-calendar.php +++ b/templates/event-calendar.php @@ -34,7 +34,10 @@ if ( isset( $id ) ): foreach ( $events as $event ): $event_ids[] = $event->ID; endforeach; - $in = 'AND ID IN (' . implode( ', ', $event_ids ) . ')'; + if ( empty( $event_ids ) ) + $in = 'AND 1 = 0'; // False logic to prevent SQL error + else + $in = 'AND ID IN (' . implode( ', ', $event_ids ) . ')'; else: $in = ''; endif;