Add events to team pages

This commit is contained in:
Brian Miyaji
2016-04-08 15:26:59 +10:00
parent 36bc9bc622
commit 35ed9962d4
12 changed files with 227 additions and 38 deletions

View File

@@ -19,6 +19,7 @@ $defaults = array(
'date_to' => 'default',
'league' => null,
'season' => null,
'team' => null,
'initial' => true,
'caption_tag' => 'h4',
'show_all_events_link' => false,
@@ -26,32 +27,29 @@ $defaults = array(
extract( $defaults, EXTR_SKIP );
if ( isset( $id ) ):
$calendar = new SP_Calendar( $id );
if ( $status != 'default' )
$calendar->status = $status;
if ( $date != 'default' )
$calendar->date = $date;
if ( $date_from != 'default' )
$calendar->from = $date_from;
if ( $date_to != 'default' )
$calendar->to = $date_to;
if ( $league )
$calendar->league = $league;
if ( $season )
$calendar->season = $season;
$events = $calendar->data();
$event_ids = array();
foreach ( $events as $event ):
$event_ids[] = $event->ID;
endforeach;
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;
$calendar = new SP_Calendar( $id );
if ( $status != 'default' )
$calendar->status = $status;
if ( $date != 'default' )
$calendar->date = $date;
if ( $date_from != 'default' )
$calendar->from = $date_from;
if ( $date_to != 'default' )
$calendar->to = $date_to;
if ( $league )
$calendar->league = $league;
if ( $season )
$calendar->season = $season;
if ( $team )
$calendar->team = $team;
$events = $calendar->data();
if ( empty( $events ) ) {
$in = 'AND 1 = 0'; // False logic to prevent SQL error
} else {
$event_ids = wp_list_pluck( $events, 'ID' );
$in = 'AND ID IN (' . implode( ', ', $event_ids ) . ')';
}
// week_begins = 0 stands for Sunday
$week_begins = intval(get_option('start_of_week'));