diff --git a/globals.php b/globals.php index bcdfecbb..2d7fc26e 100644 --- a/globals.php +++ b/globals.php @@ -1,4 +1,289 @@ array( + 'team' => + 'P' . ': $played' . "\r\n" . + 'W' . ': $wins' . "\r\n" . + 'D' . ': $ties' . "\r\n" . + 'L' . ': $losses' . "\r\n" . + 'F' . ': $for' . "\r\n" . + 'A' . ': $against' . "\r\n" . + 'GD' . ': $for - $against' . "\r\n" . + 'PTS' . ': 3 * $wins + $ties', + 'event' => + '1' . ': $first' . "\r\n" . + '2' . ': $second' . "\r\n" . + '3' . ': $third' . "\r\n" . + '4' . ': $fourth' . "\r\n" . + '5' . ': $fifth' . "\r\n" . + '6' . ': $sixth' . "\r\n" . + '7' . ': $seventh' . "\r\n" . + '8' . ': $eigth' . "\r\n" . + '9' . ': $ninth' . "\r\n" . + ' ' . ': $extra' . "\r\n" . + 'R' . ': $runs' . "\r\n" . + 'H' . ': $hits' . "\r\n" . + 'E' . ': $errors:' . "\r\n" . + 'LOB' . ': $lob', + 'player' => + array( + 'G' . ': $played' . "\r\n" . + 'AB' . ': $ab' . "\r\n" . + 'R' . ': $runs' . "\r\n" . + 'H' . ': $hits' . "\r\n" . + '2B' . ': $double' . "\r\n" . + '3B' . ': $triple' . "\r\n" . + 'HR' . ': $hr' . "\r\n" . + 'RBI' . ': $rbi' . "\r\n" . + 'BB' . ': $bb' . "\r\n" . + 'SO' . ': $so' . "\r\n" . + 'SB' . ': $sb' . "\r\n" . + 'CS' . ': $cs' . "\r\n" . + 'AVG' . ': $hits / $ab' . "\r\n" . + 'OBP' . ': ( $hits + $bb + $hbp ) / ( $ab + $bb + $hbp + $sf )' . "\r\n" . + 'SLG' . ': $tb / $ab' . "\r\n" . + 'OPS' . ': ( $hits + $bb + $hbp ) / ( $ab + $bb + $hbp + $sf ) + ( $tb / $ab )' + ), + array( + 'W' . ': $wins' . "\r\n" . + 'L' . ': $losses' . "\r\n" . + 'ERA' . ': ( $er * 9 ) / $ip' . "\r\n" . + 'G' . ': $played' . "\r\n" . + 'GS' . ': $gs' . "\r\n" . + 'SV' . ': $sv' . "\r\n" . + 'SVO' . ': $svo' . "\r\n" . + 'IP' . ': $ip' . "\r\n" . + 'H' . ': $hits' . "\r\n" . + 'R' . ': $runs' . "\r\n" . + 'ER' . ': $er' . "\r\n" . + 'HR' . ': $hr' . "\r\n" . + 'BB' . ': $bb' . "\r\n" . + 'SO' . ': $so' . "\r\n" . + 'AVG' . ': $hits / $ab' . "\r\n" . + 'WHIP' . ': ( $hits + $walks ) / $ip' + ), + array( + 'W' . ': $wins' . "\r\n" . + 'L' . ': $losses' . "\r\n" . + 'ERA' . ': ( $er * 9 ) / $ip' . "\r\n" . + 'G' . ': $played' . "\r\n" . + 'AB' . ': $ab' . "\r\n" . + 'R' . ': $runs' . "\r\n" . + 'H' . ': $hits' . "\r\n" . + '2B' . ': $double' . "\r\n" . + '3B' . ': $triple' . "\r\n" . + 'HR' . ': $hr' . "\r\n" . + 'RBI' . ': $rbi' . "\r\n" . + 'BB' . ': $bb' . "\r\n" . + 'SO' . ': $so' . "\r\n" . + 'SB' . ': $sb' . "\r\n" . + 'CS' . ': $cs' . "\r\n" . + 'AVG' . ': $hits / $ab' . "\r\n" . + 'OBP' . ': ( $hits + $bb + $hbp ) / ( $ab + $bb + $hbp + $sf )' . "\r\n" . + 'SLG' . ': $tb / $ab' . "\r\n" . + 'OPS' . ': ( $hits + $bb + $hbp ) / ( $ab + $bb + $hbp + $sf ) + ( $tb / $ab )' + ) + ), + 'Basketball' => array( + 'team' => + 'W' . ': $wins' . "\r\n" . + 'L' . ': $losses' . "\r\n" . + 'Pct' . ': $wins / $played' . "\r\n" . + 'GB' . ': ( $leadwins - $leadlosses + $wins - $losses ) / 2' . "\r\n" . + 'Home' . ': $homewins $homelosses' . "\r\n" . + 'Road' . ': $awaywins $awaylosses' . "\r\n" . + 'L10' . ': $lastten' . "\r\n" . + 'Streak' . ': $streak', + 'event' => + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow Cards' . ': $yellowcards' . "\r\n" . + 'Red Cards' . ': $redcards', + 'player' => + 'Attendances' . ': $played' . "\r\n" . + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow Cards' . ': $yellowcards' . "\r\n" . + 'Red Cards' . ': $redcards' + ), + 'Cricket' => array( + 'team' => + 'P' . ': $played' . "\r\n" . + 'W' . ': $wins' . "\r\n" . + 'D' . ': $ties' . "\r\n" . + 'L' . ': $losses' . "\r\n" . + 'F' . ': $for' . "\r\n" . + 'A' . ': $against' . "\r\n" . + 'GD' . ': $for - $against' . "\r\n" . + 'PTS' . ': 3 * $wins + $ties', + 'event' => + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow Cards' . ': $yellowcards' . "\r\n" . + 'Red Cards' . ': $redcards', + 'player' => + 'Attendances' . ': $played' . "\r\n" . + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow Cards' . ': $yellowcards' . "\r\n" . + 'Red Cards' . ': $redcards' + ), + 'Football (USA)' => array( + 'team' => + 'P' . ': $played' . "\r\n" . + 'W' . ': $wins' . "\r\n" . + 'D' . ': $ties' . "\r\n" . + 'L' . ': $losses' . "\r\n" . + 'F' . ': $for' . "\r\n" . + 'A' . ': $against' . "\r\n" . + 'GD' . ': $for - $against' . "\r\n" . + 'PTS' . ': 3 * $wins + $ties', + 'event' => + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow Cards' . ': $yellowcards' . "\r\n" . + 'Red Cards' . ': $redcards', + 'player' => + 'Attendances' . ': $played' . "\r\n" . + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow Cards' . ': $yellowcards' . "\r\n" . + 'Red Cards' . ': $redcards' + ), + 'Footy (Australia)' => array( + 'team' => + 'P' . ': $played' . "\r\n" . + 'W' . ': $wins' . "\r\n" . + 'D' . ': $ties' . "\r\n" . + 'L' . ': $losses' . "\r\n" . + 'F' . ': $for' . "\r\n" . + 'A' . ': $against' . "\r\n" . + 'GD' . ': $for - $against' . "\r\n" . + 'PTS' . ': 3 * $wins + $ties', + 'event' => + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow Cards' . ': $yellowcards' . "\r\n" . + 'Red Cards' . ': $redcards', + 'player' => + 'Attendances' . ': $played' . "\r\n" . + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow Cards' . ': $yellowcards' . "\r\n" . + 'Red Cards' . ': $redcards' + ), + 'Hockey' => array( + 'team' => + 'P' . ': $played' . "\r\n" . + 'W' . ': $wins' . "\r\n" . + 'D' . ': $ties' . "\r\n" . + 'L' . ': $losses' . "\r\n" . + 'F' . ': $for' . "\r\n" . + 'A' . ': $against' . "\r\n" . + 'GD' . ': $for - $against' . "\r\n" . + 'PTS' . ': 3 * $wins + $ties', + 'event' => + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow Cards' . ': $yellowcards' . "\r\n" . + 'Red Cards' . ': $redcards', + 'player' => + 'Attendances' . ': $played' . "\r\n" . + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow Cards' . ': $yellowcards' . "\r\n" . + 'Red Cards' . ': $redcards' + ), + 'Rugby' => array( + 'team' => + 'P' . ': $played' . "\r\n" . + 'W' . ': $wins' . "\r\n" . + 'D' . ': $ties' . "\r\n" . + 'L' . ': $losses' . "\r\n" . + 'F' . ': $for' . "\r\n" . + 'A' . ': $against' . "\r\n" . + 'GD' . ': $for - $against' . "\r\n" . + 'PTS' . ': 3 * $wins + $ties', + 'event' => + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow' . ' Cards: $yellowcards' . "\r\n" . + 'Red' . ' Cards: $redcards', + 'player' => + 'Attendances' . ': $played' . "\r\n" . + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow' . ' Cards: $yellowcards' . "\r\n" . + 'Red' . ' Cards: $redcards' + ), + 'soccer' => array( + 'team' => + 'P' . ': $played' . "\r\n" . + 'W' . ': $wins' . "\r\n" . + 'D' . ': $ties' . "\r\n" . + 'L' . ': $losses' . "\r\n" . + 'F' . ': $for' . "\r\n" . + 'A' . ': $against' . "\r\n" . + 'GD' . ': $for - $against' . "\r\n" . + 'PTS' . ': 3 * $wins + $ties', + 'event' => + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow Cards' . ': $yellowcards' . "\r\n" . + 'Red Cards' . ': $redcards', + 'player' => + 'Attendances' . ': $played' . "\r\n" . + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow Cards' . ': $yellowcards' . "\r\n" . + 'Red Cards' . ': $redcards' + ), + 'Tennis' => array( + 'team' => + 'P' . ': $played' . "\r\n" . + 'W' . ': $wins' . "\r\n" . + 'D' . ': $ties' . "\r\n" . + 'L' . ': $losses' . "\r\n" . + 'F' . ': $for' . "\r\n" . + 'A' . ': $against' . "\r\n" . + 'GD' . ': $for - $against' . "\r\n" . + 'PTS' . ': 3 * $wins + $ties', + 'event' => + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow' . ' Cards: $yellowcards' . "\r\n" . + 'Red' . ' Cards: $redcards', + 'player' => + 'Attendances' . ': $played' . "\r\n" . + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow' . ' Cards: $yellowcards' . "\r\n" . + 'Red' . ' Cards: $redcards' + ), + 'Volleyball' => array( + 'team' => + 'P' . ': $played' . "\r\n" . + 'W' . ': $wins' . "\r\n" . + 'D' . ': $ties' . "\r\n" . + 'L' . ': $losses' . "\r\n" . + 'F' . ': $for' . "\r\n" . + 'A' . ': $against' . "\r\n" . + 'GD' . ': $for - $against' . "\r\n" . + 'PTS' . ': 3 * $wins + $ties', + 'event' => + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow' . ' Cards: $yellowcards' . "\r\n" . + 'Red' . ' Cards: $redcards', + 'player' => + 'Attendances' . ': $played' . "\r\n" . + 'Goals' . ': $goals' . "\r\n" . + 'Assists' . ': $assists' . "\r\n" . + 'Yellow' . ' Cards: $yellowcards' . "\r\n" . + 'Red' . ' Cards: $redcards' + ) +); + $sportspress_texts = array( 'sp_team' => array( 'Enter title here' => __( 'Team', 'sportspress' ), @@ -54,23 +339,9 @@ $sportspress_thumbnail_texts = array( $sportspress_options = array( 'settings' => array( 'sp_event_team_count' => 2, - 'sp_team_stats_columns' => 'P: $played - W: $wins - D: $ties - L: $losses - F: $for - A: $against - GD: $for-$against - PTS: 3$wins+$ties', - 'sp_event_stats_columns' => 'Goals: $goals - Assists: $assists - Yellow Cards: $yellowcards - Red Cards: $redcards', - 'sp_player_stats_columns' => 'Attendances: $played - Goals: $goals - Assists: $assists - Yellow Cards: $yellowcards - Red Cards: $redcards' + 'sp_team_stats_columns' => $sportspress_sports['soccer']['team'], + 'sp_event_stats_columns' => $sportspress_sports['soccer']['event'], + 'sp_player_stats_columns' => $sportspress_sports['soccer']['player'] ) ); diff --git a/helpers.php b/helpers.php index c143a1ac..f63a9ffc 100644 --- a/helpers.php +++ b/helpers.php @@ -307,6 +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 ): + if ( !array_key_exists( $key, $stats_keys ) || !array_key_exists( $stats_keys[ $key ], $vars ) ) continue; $vars[ $stats_keys[ $key ] ] += $value; endforeach; endforeach; @@ -478,6 +479,19 @@ if ( !function_exists( 'sp_stats_table' ) ) { } } +if ( !function_exists( 'sp_team_stats_sport_choice' ) ) { + function sp_team_stats_sport_choice( $selected = null ) { + global $sportspress_sports; + ?> + + + +
-