Better way of getting ID

This commit is contained in:
Brian Miyaji
2014-01-22 21:01:58 +11:00
parent 7555d78739
commit d7509b8614
12 changed files with 41 additions and 53 deletions

View File

@@ -2,10 +2,11 @@
if ( !function_exists( 'sportspress_player_league_statistics' ) ) {
function sportspress_player_league_statistics( $league, $id = null ) {
if ( ! $id ):
global $post;
$id = $post->ID;
endif;
if ( ! $league )
return false;
if ( ! $id )
$id = get_the_ID();
$data = sportspress_get_player_statistics_data( $id, $league->term_id );
@@ -15,8 +16,12 @@ if ( !function_exists( 'sportspress_player_league_statistics' ) ) {
// Remove the first row to leave us with the actual data
unset( $data[0] );
$output = '<table class="sp-player-statistics sp-data-table">' .
'<caption>' . $league->name . '</caption>' . '<thead>' . '<tr>';
// Skip if there are no rows in the table
if ( empty( $data ) )
return false;
$output = '<h4 class="sp-table-caption">' . $league->name . '</h4>' .
'<table class="sp-player-statistics sp-data-table">' . '<thead>' . '<tr>';
foreach( $labels as $key => $label ):
$output .= '<th class="data-' . $key . '">' . $label . '</th>';