Enable events filtering in calendars based on Players participated (either team vs team or player vs player)

This commit is contained in:
savvasha
2019-06-16 14:21:04 +03:00
parent 6e15f341ed
commit e1bfbac3a2
2 changed files with 31 additions and 0 deletions

View File

@@ -334,6 +334,7 @@ class SP_Calendar extends SP_Secondary_Post {
$seasons = get_the_terms( $this->ID, 'sp_season' );
$venues = get_the_terms( $this->ID, 'sp_venue' );
$teams = array_filter( get_post_meta( $this->ID, 'sp_team', false ) );
$players = array_filter( get_post_meta( $this->ID, 'sp_player', false ) );
$table = get_post_meta( $this->ID, 'sp_table', true );
if ( ! isset( $league_ids ) ) $league_ids = array();
@@ -395,6 +396,16 @@ class SP_Calendar extends SP_Secondary_Post {
),
);
}
if ( ! empty( $players ) ) {
$args['meta_query'] = array(
array(
'key' => 'sp_player',
'value' => $players,
'compare' => 'IN',
),
);
}
if ( $this->event) {
$args['p'] = $this->event;