Add positions to statistics and metrics

This commit is contained in:
Brian Miyaji
2014-01-21 20:35:13 +11:00
parent 08ce1eea27
commit 9cde21de71
33 changed files with 2922 additions and 2685 deletions

View File

@@ -0,0 +1,42 @@
<?php
if ( !function_exists( 'sportspress_player_metrics' ) ) {
function sportspress_player_metrics( $id = null ) {
if ( ! $id ):
global $post;
$id = $post->ID;
endif;
global $sportspress_countries;
$number = get_post_meta( $id, 'sp_number', true );
$nationality = get_post_meta( $id, 'sp_nationality', true );
$metrics = sportspress_get_player_metrics_data( $id );
$flag_image = '<img src="' . SPORTSPRESS_PLUGIN_URL . 'assets/images/flags/' . strtolower( $nationality ) . '.png" class="sp-flag">';
$common = array(
__( 'Number', 'sportspress' ) => $number,
__( 'Nationality', 'sportspress' ) => $flag_image . ' ' . sportspress_array_value( $sportspress_countries, $nationality, '—' ),
);
$data = array_merge( $common, $metrics );
$output = '<table class="sp-player-metrics sp-data-table">' . '<tbody>';
$i = 0;
foreach( $data as $label => $value ):
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '"><th>' . $label . '</th><td>' . $value . '</td></tr>';
$i++;
endforeach;
$output .= '</tbody>' . '</table>';
return apply_filters( 'sportspress_player_metrics', $output );
}
}