Avoid counting events the player didnt participate with the selected team.

This commit is contained in:
savvasha
2020-08-26 08:06:53 +03:00
parent 0dac5c28b4
commit 2a38d08951

View File

@@ -375,6 +375,24 @@ class SP_Player_List extends SP_Secondary_Post {
); );
endif; endif;
$team_key = 'sp_team';
if ( $team ):
switch ( $era ):
case 'current':
$team_key = 'sp_current_team';
break;
case 'past':
$team_key = 'sp_past_team';
break;
endswitch;
$args['meta_query'][] = array(
array(
'key' => $team_key,
'value' => $team
),
);
endif;
if ( $this->date !== 0 ): if ( $this->date !== 0 ):
if ( $this->date == 'w' ): if ( $this->date == 'w' ):
$args['year'] = date_i18n('Y'); $args['year'] = date_i18n('Y');
@@ -412,6 +430,7 @@ class SP_Player_List extends SP_Secondary_Post {
// Add all team performance // Add all team performance
if ( is_array( $team_performance ) ): foreach ( $team_performance as $team_id => $players ): if ( is_array( $team_performance ) ): foreach ( $team_performance as $team_id => $players ):
( $team && $team_id != $team ) continue;
if ( is_array( $players ) ): foreach ( $players as $player_id => $player_performance ): if ( is_array( $players ) ): foreach ( $players as $player_id => $player_performance ):
if ( array_key_exists( $player_id, $totals ) && is_array( $totals[ $player_id ] ) ): if ( array_key_exists( $player_id, $totals ) && is_array( $totals[ $player_id ] ) ):