Use variable slugs instead of generated stats keys in player stats

This commit is contained in:
Takumi
2013-08-07 03:08:16 +10:00
parent d704c6bc1b
commit 753a35f16c
2 changed files with 13 additions and 10 deletions

View File

@@ -62,15 +62,15 @@ $sportspress_options = array(
A: $against
GD: $for-$against
PTS: 3$wins+$ties',
'sp_event_stats_columns' => 'Goals: $statsa
Assists: $statsb
Yellow Cards: $statsc
Red Cards: $statsd',
'sp_event_stats_columns' => 'Goals: $goals
Assists: $assists
Yellow Cards: $yellowcards
Red Cards: $redcards',
'sp_player_stats_columns' => 'Attendances: $played
Goals: $statsa
Assists: $statsb
Yellow Cards: $statsc
Red Cards: $statsd',
Goals: $goals
Assists: $assists
Yellow Cards: $yellowcards
Red Cards: $redcards'
)
);

View File

@@ -293,7 +293,10 @@ if ( !function_exists( 'sp_get_stats_row' ) ) {
// Create array of event stats columns
$columns = sp_get_eos_array( get_option( 'sp_event_stats_columns' ) );
foreach ( $columns as $key => $value ):
$vars[ 'stats' . sp_num_to_letter( $key ) ] = 0;
$row = explode( ':', $value );
$var_name = strtolower( preg_replace( '~[^\p{L}]++~u', '', end( $row ) ) );
$vars[ $var_name ] = 0;
$stats_keys[ $key ] = $var_name;
endforeach;
// Populate columns with player stats from events
@@ -304,7 +307,7 @@ if ( !function_exists( 'sp_get_stats_row' ) ) {
$player_id = sp_array_value( $args['meta_query'][0], 'value', 0 );
if ( !array_key_exists( $player_id, $stat ) ) continue;
foreach ( $stat[ $player_id ] as $key => $value ):
$vars[ 'stats' . sp_num_to_letter( $key ) ] += $value;
$vars[ $stats_keys[ $key ] ] += $value;
endforeach;
endforeach;
endforeach;