Add Layout Selection and modify the Event Filtering
This commit is contained in:
@@ -40,6 +40,12 @@ class SP_Calendar extends SP_Secondary_Post {
|
|||||||
/** @var int The team ID. */
|
/** @var int The team ID. */
|
||||||
public $team;
|
public $team;
|
||||||
|
|
||||||
|
/** @var array The teams IDs. */
|
||||||
|
public $teams_past;
|
||||||
|
|
||||||
|
/** @var string The event date. */
|
||||||
|
public $date_before;
|
||||||
|
|
||||||
/** @var int The player ID. */
|
/** @var int The player ID. */
|
||||||
public $player;
|
public $player;
|
||||||
|
|
||||||
@@ -203,6 +209,23 @@ class SP_Calendar extends SP_Secondary_Post {
|
|||||||
);
|
);
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
if ( $this->teams_past ):
|
||||||
|
foreach ( $this->teams_past as $team_past ):
|
||||||
|
$args['meta_query'][] = array(
|
||||||
|
'key' => 'sp_team',
|
||||||
|
'value' => $team_past,
|
||||||
|
'compare' => 'IN',
|
||||||
|
);
|
||||||
|
endforeach;
|
||||||
|
$args['date_query'] = array(
|
||||||
|
array(
|
||||||
|
'before' => $this->date_before,
|
||||||
|
'inclusive' => false,
|
||||||
|
)
|
||||||
|
|
||||||
|
);
|
||||||
|
endif;
|
||||||
|
|
||||||
if ( $this->player ):
|
if ( $this->player ):
|
||||||
$args['meta_query'][] = array(
|
$args['meta_query'][] = array(
|
||||||
'key' => 'sp_player',
|
'key' => 'sp_player',
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class SportsPress_Event_Past_Meetings {
|
|||||||
// Filters
|
// Filters
|
||||||
add_filter( 'sportspress_event_templates', array( $this, 'templates' ) );
|
add_filter( 'sportspress_event_templates', array( $this, 'templates' ) );
|
||||||
add_filter( 'sportspress_text', array( $this, 'add_text_options' ) );
|
add_filter( 'sportspress_text', array( $this, 'add_text_options' ) );
|
||||||
|
add_filter( 'sportspress_event_settings', array( $this, 'add_settings' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,21 +74,23 @@ class SportsPress_Event_Past_Meetings {
|
|||||||
*/
|
*/
|
||||||
public function output() {
|
public function output() {
|
||||||
// Get timelines format option
|
// Get timelines format option
|
||||||
$format = get_option( 'sportspress_team_events_format', 'blocks' );
|
$format = get_option( 'sportspress_past_meetings_format', 'blocks' );
|
||||||
if ( 'calendar' === $format ):
|
$teams = get_post_meta( get_the_ID(),'sp_team' );
|
||||||
sp_get_template( 'event-calendar.php', array( 'team' => $id ) );
|
if ( 'list' === $format ):
|
||||||
elseif ( 'list' === $format ):
|
|
||||||
sp_get_template( 'event-list.php', array(
|
sp_get_template( 'event-list.php', array(
|
||||||
'team' => $id,
|
'teams_past' => $teams,
|
||||||
'league' => apply_filters( 'sp_team_events_league', 0 ),
|
'date_before' => get_post_time('Y-m-d', true),
|
||||||
'season' => apply_filters( 'sp_team_events_season', 0 ),
|
|
||||||
'title_format' => 'homeaway',
|
'title_format' => 'homeaway',
|
||||||
'time_format' => 'separate',
|
'time_format' => 'separate',
|
||||||
'columns' => array( 'event', 'time', 'results' ),
|
'columns' => array( 'event', 'time', 'results' ),
|
||||||
'order' => 'DESC',
|
'order' => 'DESC',
|
||||||
) );
|
) );
|
||||||
else:
|
else:
|
||||||
sp_get_template( 'event-fixtures-results.php', array( 'team' => $id ) );
|
sp_get_template( 'event-blocks.php', array(
|
||||||
|
'teams_past' => $teams,
|
||||||
|
'date_before' => get_post_time('Y-m-d', true),
|
||||||
|
'order' => 'DESC',
|
||||||
|
) );
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +103,38 @@ class SportsPress_Event_Past_Meetings {
|
|||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add settings.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function add_settings( $settings ) {
|
||||||
|
|
||||||
|
$settings = array_merge( $settings,
|
||||||
|
array(
|
||||||
|
array( 'title' => __( 'Past Meetings', 'sportspress' ), 'type' => 'title', 'id' => 'past_meetings_options' ),
|
||||||
|
),
|
||||||
|
|
||||||
|
apply_filters( 'sportspress_past_meetings_options', array(
|
||||||
|
array(
|
||||||
|
'title' => __( 'Layout', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_past_meetings_format',
|
||||||
|
'default' => 'horizontal',
|
||||||
|
'type' => 'radio',
|
||||||
|
'options' => array(
|
||||||
|
'blocks'=> __( 'Blocks', 'sportspress' ),
|
||||||
|
'list' => __( 'List', 'sportspress' ),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
) ),
|
||||||
|
|
||||||
|
array(
|
||||||
|
array( 'type' => 'sectionend', 'id' => 'past_meetings_options' ),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ $defaults = array(
|
|||||||
'season' => null,
|
'season' => null,
|
||||||
'venue' => null,
|
'venue' => null,
|
||||||
'team' => null,
|
'team' => null,
|
||||||
|
'teams_past' => null,
|
||||||
|
'date_before' => null,
|
||||||
'player' => null,
|
'player' => null,
|
||||||
'number' => -1,
|
'number' => -1,
|
||||||
'show_team_logo' => get_option( 'sportspress_event_blocks_show_logos', 'yes' ) == 'yes' ? true : false,
|
'show_team_logo' => get_option( 'sportspress_event_blocks_show_logos', 'yes' ) == 'yes' ? true : false,
|
||||||
@@ -73,6 +75,10 @@ if ( $venue )
|
|||||||
$calendar->venue = $venue;
|
$calendar->venue = $venue;
|
||||||
if ( $team )
|
if ( $team )
|
||||||
$calendar->team = $team;
|
$calendar->team = $team;
|
||||||
|
if ( $teams_past )
|
||||||
|
$calendar->teams_past = $teams_past;
|
||||||
|
if ( $date_before )
|
||||||
|
$calendar->date_before = $date_before;
|
||||||
if ( $player )
|
if ( $player )
|
||||||
$calendar->player = $player;
|
$calendar->player = $player;
|
||||||
if ( $order != 'default' )
|
if ( $order != 'default' )
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ $defaults = array(
|
|||||||
'season' => null,
|
'season' => null,
|
||||||
'venue' => null,
|
'venue' => null,
|
||||||
'team' => null,
|
'team' => null,
|
||||||
|
'teams_past' => null,
|
||||||
|
'date_before' => null,
|
||||||
'player' => null,
|
'player' => null,
|
||||||
'number' => -1,
|
'number' => -1,
|
||||||
'show_team_logo' => get_option( 'sportspress_event_list_show_logos', 'no' ) == 'yes' ? true : false,
|
'show_team_logo' => get_option( 'sportspress_event_list_show_logos', 'no' ) == 'yes' ? true : false,
|
||||||
@@ -71,6 +73,10 @@ if ( $venue )
|
|||||||
$calendar->venue = $venue;
|
$calendar->venue = $venue;
|
||||||
if ( $team )
|
if ( $team )
|
||||||
$calendar->team = $team;
|
$calendar->team = $team;
|
||||||
|
if ( $teams_past )
|
||||||
|
$calendar->teams_past = $teams_past;
|
||||||
|
if ( $date_before )
|
||||||
|
$calendar->date_before = $date_before;
|
||||||
if ( $player )
|
if ( $player )
|
||||||
$calendar->player = $player;
|
$calendar->player = $player;
|
||||||
if ( $order != 'default' )
|
if ( $order != 'default' )
|
||||||
|
|||||||
Reference in New Issue
Block a user