diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-statistics.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-statistics.php index 80440cd0..0f48d13f 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-statistics.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-statistics.php @@ -36,7 +36,7 @@ class SP_Meta_Box_Player_Statistics { endforeach; endif; ?> -

+

data( 0, true ); self::table( $post->ID, 0, $columns, $data, $placeholders, $merged, $seasons_teams ); diff --git a/includes/admin/settings/class-sp-settings-players.php b/includes/admin/settings/class-sp-settings-players.php index bee6b0d9..0b8a41b2 100644 --- a/includes/admin/settings/class-sp-settings-players.php +++ b/includes/admin/settings/class-sp-settings-players.php @@ -60,6 +60,14 @@ class SP_Settings_Players extends SP_Settings_Page { 'id' => 'sportspress_player_show_details', 'default' => 'yes', 'type' => 'checkbox', + 'checkboxgroup' => '', + ), + + array( + 'desc' => __( 'Career Total', 'sportspress' ), + 'id' => 'sportspress_player_show_total', + 'default' => 'no', + 'type' => 'checkbox', 'checkboxgroup' => 'end', ), diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index fa2f14ef..6229a424 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -1148,6 +1148,7 @@ if ( !function_exists( 'sp_get_next_event' ) ) { function sp_get_text_options() { $strings = apply_filters( 'sportspress_text', array( __( 'Article', 'sportspress' ), + __( 'Career Total', 'sportspress' ), __( 'Current Team', 'sportspress' ), __( 'Current Teams', 'sportspress' ), __( 'Date', 'sportspress' ), diff --git a/templates/player-statistics.php b/templates/player-statistics.php index a0ab5b3b..12aa35ef 100644 --- a/templates/player-statistics.php +++ b/templates/player-statistics.php @@ -16,6 +16,7 @@ $player = new SP_Player( $id ); $scrollable = get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false; $responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false; +$show_total = get_option( 'sportspress_player_show_total', 'no' ) == 'yes' ? true : false; $leagues = get_the_terms( $id, 'sp_league' ); // Loop through statistics for each league @@ -31,7 +32,7 @@ if ( is_array( $leagues ) ): // Skip if there are no rows in the table if ( empty( $data ) ) - return false; + continue; $output = '

' . $league->name . '

' . '
' . @@ -67,3 +68,54 @@ if ( is_array( $leagues ) ): data( 0 ); + + // The first row should be column labels + $labels = $data[0]; + + // Remove the first row to leave us with the actual data + unset( $data[0] ); + + // Skip if there are no rows in the table + if ( empty( $data ) ) + return false; + + $output = '

' . __( 'Career Total', 'sportspress' ) . '

' . + '
' . + '' . '' . ''; + + foreach( $labels as $key => $label ): + if ( 'team' == $key ) + continue; + $output .= ''; + endforeach; + + $output .= '' . '' . ''; + + $i = 0; + + foreach( $data as $season_id => $row ): + + $output .= ''; + + foreach( $labels as $key => $value ): + if ( 'team' == $key ) + continue; + $output .= ''; + endforeach; + + $output .= ''; + + $i++; + + endforeach; + + $output .= '' . '
' . $label . '
' . sp_array_value( $row, $key, '—' ) . '
' . '
'; + ?> +
+ +
+