40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?php
|
|
if ( !function_exists( 'sportspress_player_metrics' ) ) {
|
|
function sportspress_player_metrics( $id = null ) {
|
|
|
|
if ( ! $id )
|
|
$id = get_the_ID();
|
|
|
|
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 );
|
|
|
|
$common = array(
|
|
__( 'Number', 'sportspress' ) => $number,
|
|
__( 'Nationality', 'sportspress' ) => sportspress_array_value( $sportspress_countries, $nationality, '—' ),
|
|
);
|
|
|
|
$data = array_merge( $common, $metrics );
|
|
|
|
$output = '<div class="sp-table-wrapper">' .
|
|
'<table class="sp-player-metrics sp-data-table sp-responsive-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>' . '</div>';
|
|
|
|
return apply_filters( 'sportspress_player_metrics', $output );
|
|
|
|
}
|
|
}
|