Merge pull request #360 from ThemeBoy/feature-player-list-nationality

Enable Player List filtering by Nationality
This commit is contained in:
Brian Miyaji
2020-04-04 13:23:15 +11:00
committed by GitHub
2 changed files with 32 additions and 1 deletions

View File

@@ -59,6 +59,7 @@ class SP_Player_List extends SP_Secondary_Post {
$crop = get_post_meta( $this->ID, 'sp_crop', true );
$order = get_post_meta( $this->ID, 'sp_order', true );
$select = get_post_meta( $this->ID, 'sp_select', true );
$nationalities = get_post_meta( $this->ID, 'sp_nationality', false );
$this->date = $this->__get( 'date' );
@@ -110,6 +111,9 @@ class SP_Player_List extends SP_Secondary_Post {
'tax_query' => array(
'relation' => 'AND',
),
'meta_query' => array(
'relation' => 'AND',
),
);
if ( $league_ids ):
@@ -138,7 +142,7 @@ class SP_Player_List extends SP_Secondary_Post {
$team_key = 'sp_past_team';
break;
endswitch;
$args['meta_query'] = array(
$args['meta_query'][] = array(
array(
'key' => $team_key,
'value' => $team
@@ -153,6 +157,16 @@ class SP_Player_List extends SP_Secondary_Post {
'terms' => $position_ids
);
endif;
if ( $nationalities ):
$args['meta_query'][] = array(
array(
'key' => 'sp_nationality',
'value' => $nationalities,
'compare' => 'IN'
),
);
endif;
$args = apply_filters( 'sportspress_player_list_args', $args, $team );