Fix player statistics event query and filter by offense and defense
This commit is contained in:
@@ -261,7 +261,7 @@ class SP_Player extends SP_Custom_Post {
|
|||||||
$last10[ $key ] = 0;
|
$last10[ $key ] = 0;
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
// Get all events involving the team in current season
|
// Get all events involving the player in current season
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_event',
|
'post_type' => 'sp_event',
|
||||||
'numberposts' => -1,
|
'numberposts' => -1,
|
||||||
@@ -284,19 +284,40 @@ class SP_Player extends SP_Custom_Post {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( -1 !== $section ):
|
||||||
|
$args['meta_query'][] = array(
|
||||||
|
'key' => ( 1 === $section ? 'sp_defense' : 'sp_offense' ),
|
||||||
|
'value' => $this->ID
|
||||||
|
);
|
||||||
|
endif;
|
||||||
|
|
||||||
if ( $league_id ):
|
if ( $league_id ):
|
||||||
$args['tax_query'][] = array(
|
$args['tax_query'][] = array(
|
||||||
'taxonomy' => 'sp_league',
|
'relation' => 'OR',
|
||||||
'field' => 'term_id',
|
array(
|
||||||
'terms' => $league_id
|
'taxonomy' => 'sp_league',
|
||||||
|
'field' => 'term_id',
|
||||||
|
'terms' => $league_id
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'sp_league',
|
||||||
|
'operator' => 'NOT EXISTS',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $div_id ):
|
if ( $div_id ):
|
||||||
$args['tax_query'][] = array(
|
$args['tax_query'][] = array(
|
||||||
'taxonomy' => 'sp_season',
|
'relation' => 'OR',
|
||||||
'field' => 'term_id',
|
array(
|
||||||
'terms' => $div_id
|
'taxonomy' => 'sp_season',
|
||||||
|
'field' => 'term_id',
|
||||||
|
'terms' => $div_id
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'sp_season',
|
||||||
|
'operator' => 'NOT EXISTS',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user