$team_id ):
if ( ! $team_id ) continue;
// Get results for players in the team
$players = sportspress_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $key );
$data = sportspress_array_combine( $players, sportspress_array_value( $stats, $team_id, array() ) );
$output .= '
' . get_the_title( $team_id ) . '
';
$output .= '' . '' . '';
$output .= '| ' . __( '#', 'sportspress' ) . ' | ';
$output .= '' . __( 'Player', 'sportspress' ) . ' | ';
foreach( $statistic_labels as $key => $label ):
$output .= '' . $label . ' | ';
endforeach;
$output .= '
' . '' . '';
$i = 0;
foreach( $data as $player_id => $row ):
if ( ! $player_id )
continue;
$output .= '';
$number = get_post_meta( $player_id, 'sp_number', true );
// Player number
$output .= '| ' . $number . ' | ';
// Name as link
$permalink = get_post_permalink( $player_id );
$name = get_the_title( $player_id );
$output .= '' . '' . $name . ' | ';
foreach( $statistic_labels as $key => $label ):
if ( $key == 'name' )
continue;
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
$value = $row[ $key ];
else:
$value = 0;
endif;
$output .= '' . $value . ' | ';
endforeach;
$output .= '
';
$i++;
endforeach;
$output .= '';
if ( array_key_exists( 0, $data ) ):
$output .= '';
$number = get_post_meta( $player_id, 'sp_number', true );
// Player number
$output .= '| | ';
$output .= '' . __( 'Total', 'sportspress' ) . ' | ';
$row = $data[0];
foreach( $statistic_labels as $key => $label ):
if ( $key == 'name' ):
continue;
endif;
$output .= '' . sportspress_array_value( $row, $key, '—' ) . ' | ';
endforeach;
$output .= '
';
endif;
$output .= '
';
endforeach;
// Initialize and check
$table_rows = '';
$i = 0;
foreach( $results as $team_id => $result ):
if ( sportspress_array_value( $result, 'outcome', '-1' ) != '-1' ):
unset( $result['outcome'] );
$table_rows .= '';
$table_rows .= '| ' . get_the_title( $team_id ) . ' | ';
foreach( $result_labels as $key => $label ):
if ( $key == 'name' )
continue;
if ( array_key_exists( $key, $result ) && $result[ $key ] != '' ):
$value = $result[ $key ];
else:
$value = '—';
endif;
$table_rows .= '' . $value . ' | ';
endforeach;
$table_rows .= '
';
$i++;
endif;
endforeach;
if ( ! empty( $table_rows ) ):
$output .= '' . __( 'Results', 'sportspress' ) . '
';
$output .= '';
$output .= '| ' . __( 'Team', 'sportspress' ) . ' | ';
foreach( $result_labels as $key => $label ):
$output .= '' . $label . ' | ';
endforeach;
$output .= '' . '' . '';
$output .= $table_rows;
$output .= '
';
endif;
return $output;
}
}
if ( !function_exists( 'sportspress_league_table' ) ) {
function sportspress_league_table( $id ) {
$data = sportspress_get_league_table_data( $id );
$output = '' . '' . '';
// The first row should be column labels
$labels = $data[0];
// Remove the first row to leave us with the actual data
unset( $data[0] );
$output .= '| ' . __( '#', 'sportspress' ) . ' | ';
foreach( $labels as $key => $label ):
$output .= '' . $label . ' | ';
endforeach;
$output .= '
' . '' . '';
$i = 0;
foreach( $data as $team_id => $row ):
$output .= '';
// Position as number
$output .= '| ' . $i . ' | ';
// Thumbnail and name as link
$permalink = get_post_permalink( $team_id );
$thumbnail = get_the_post_thumbnail( $team_id, 'thumbnail', array( 'class' => 'logo' ) );
$name = sportspress_array_value( $row, 'name', sportspress_array_value( $row, 'name', ' ' ) );
$output .= '' . ( $thumbnail ? $thumbnail . ' ' : '' ) . '' . $name . ' | ';
foreach( $labels as $key => $value ):
if ( $key == 'name' )
continue;
$output .= '' . sportspress_array_value( $row, $key, '—' ) . ' | ';
endforeach;
$output .= '
';
$i++;
endforeach;
$output .= '' . '
';
return $output;
}
}
if ( !function_exists( 'sportspress_team_columns' ) ) {
function sportspress_team_columns( $id ) {
$leagues = get_the_terms( $id, 'sp_league' );
$output = '';
// Loop through data for each league
foreach ( $leagues as $league ):
if ( sizeof( $leagues ) > 1 )
$output .= '' . $league->name . '
';
$data = sportspress_get_team_columns_data( $id, $league->term_id );
// The first row should be column labels
$labels = $data[0];
// Remove the first row to leave us with the actual data
unset( $data[0] );
$output .= '' . '' . '';
foreach( $labels as $key => $label ):
$output .= '| ' . $label . ' | ';
endforeach;
$output .= '
' . '' . '';
$i = 0;
foreach( $data as $season_id => $row ):
$output .= '';
foreach( $labels as $key => $value ):
$output .= '| ' . sportspress_array_value( $row, $key, '—' ) . ' | ';
endforeach;
$output .= '
';
$i++;
endforeach;
$output .= '' . '
';
endforeach;
return $output;
}
}
if ( !function_exists( 'sportspress_player_list' ) ) {
function sportspress_player_list( $id ) {
$data = sportspress_get_player_list_data( $id );
$output = '' . '' . '';
// The first row should be column labels
$labels = $data[0];
// Remove the first row to leave us with the actual data
unset( $data[0] );
$output .= '| ' . __( '#', 'sportspress' ) . ' | ';
foreach( $labels as $key => $label ):
$output .= '' . $label . ' | ';
endforeach;
$output .= '
' . '' . '';
$i = 0;
foreach( $data as $player_id => $row ):
$output .= '';
// Player number
$number = get_post_meta( $player_id, 'sp_number', true );
$output .= '| ' . ( $number ? $number : ' ' ) . ' | ';
// Name as link
$permalink = get_post_permalink( $player_id );
$name = sportspress_array_value( $row, 'name', sportspress_array_value( $row, 'name', ' ' ) );
$output .= '' . '' . $name . ' | ';
foreach( $labels as $key => $value ):
if ( $key == 'name' )
continue;
$output .= '' . sportspress_array_value( $row, $key, '—' ) . ' | ';
endforeach;
$output .= '
';
$i++;
endforeach;
$output .= '' . '
';
return $output;
}
}
if ( !function_exists( 'sportspress_player_metrics' ) ) {
function sportspress_player_metrics( $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 );
$flag_image = '
';
$common = array(
__( 'Number', 'sportspress' ) => $number,
__( 'Nationality', 'sportspress' ) => $flag_image . ' ' . sportspress_array_value( $sportspress_countries, $nationality, '—' ),
);
$data = array_merge( $common, $metrics );
$output = '' . '';
$i = 0;
foreach( $data as $label => $value ):
$output .= '| ' . $label . ' | ' . $value . ' |
';
$i++;
endforeach;
$output .= '' . '
';
return $output;
}
}
if ( !function_exists( 'sportspress_player_statistics' ) ) {
function sportspress_player_statistics( $id ) {
$leagues = get_the_terms( $id, 'sp_league' );
$output = '';
// Loop through statistics for each league
foreach ( $leagues as $league ):
if ( sizeof( $leagues ) > 1 )
$output .= '' . $league->name . '
';
$data = sportspress_get_player_statistics_data( $id, $league->term_id );
// The first row should be column labels
$labels = $data[0];
// Remove the first row to leave us with the actual data
unset( $data[0] );
$output .= '' . '' . '';
foreach( $labels as $key => $label ):
$output .= '| ' . $label . ' | ';
endforeach;
$output .= '
' . '' . '';
$i = 0;
foreach( $data as $season_id => $row ):
$output .= '';
foreach( $labels as $key => $value ):
$output .= '| ' . sportspress_array_value( $row, $key, '—' ) . ' | ';
endforeach;
$output .= '
';
$i++;
endforeach;
$output .= '' . '
';
endforeach;
return $output;
}
}