Display career totals if available

This commit is contained in:
Brian Miyaji
2015-03-28 11:27:35 +11:00
parent f99097f006
commit 2ef8ff584a

View File

@@ -16,7 +16,6 @@ if ( ! isset( $id ) )
$player = new SP_Player( $id );
$scrollable = get_option( 'sportspress_enable_scrollable_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
@@ -69,53 +68,51 @@ if ( is_array( $leagues ) ):
endforeach;
endif;
if ( $show_total ):
$data = $player->data( 0 );
// Career total
$data = $player->data( 0 );
// The first row should be column labels
$labels = $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] );
// 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;
// Skip if there are no rows in the table
if ( empty( $data ) )
return false;
$output = '<h4 class="sp-table-caption">' . __( 'Career Total', 'sportspress' ) . '</h4>' .
'<div class="sp-table-wrapper">' .
'<table class="sp-player-statistics sp-data-table' . ( $scrollable ? ' sp-scrollable-table' : '' ) . '">' . '<thead>' . '<tr>';
$output = '<h4 class="sp-table-caption">' . __( 'Career Total', 'sportspress' ) . '</h4>' .
'<div class="sp-table-wrapper">' .
'<table class="sp-player-statistics sp-data-table' . ( $scrollable ? ' sp-scrollable-table' : '' ) . '">' . '<thead>' . '<tr>';
foreach( $labels as $key => $label ):
foreach( $labels as $key => $label ):
if ( 'team' == $key )
continue;
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
endforeach;
$output .= '</tr>' . '</thead>' . '<tbody>';
$i = 0;
foreach( $data as $season_id => $row ):
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
foreach( $labels as $key => $value ):
if ( 'team' == $key )
continue;
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
$output .= '<td class="data-' . $key . '">' . sp_array_value( $row, $key, '&mdash;' ) . '</td>';
endforeach;
$output .= '</tr>' . '</thead>' . '<tbody>';
$output .= '</tr>';
$i = 0;
$i++;
foreach( $data as $season_id => $row ):
endforeach;
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
foreach( $labels as $key => $value ):
if ( 'team' == $key )
continue;
$output .= '<td class="data-' . $key . '">' . sp_array_value( $row, $key, '&mdash;' ) . '</td>';
endforeach;
$output .= '</tr>';
$i++;
endforeach;
$output .= '</tbody>' . '</table>' . '</div>';
?>
<div class="sp-template sp-template-player-statistics sp-template-player-total">
<?php echo $output; ?>
</div>
<?php
endif;
$output .= '</tbody>' . '</table>' . '</div>';
?>
<div class="sp-template sp-template-player-statistics sp-template-player-total">
<?php echo $output; ?>
</div>