null,
'orderby' => 'default',
'order' => 'ASC',
);
$r = wp_parse_args( $args, $defaults );
$output = '
' .
'
' . '' . '';
$data = sportspress_get_player_list_data( $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] );
$statistics = sportspress_array_value( $r, 'statistics', null );
if ( $r['orderby'] == 'default' ):
$r['orderby'] = get_post_meta( $id, 'sp_orderby', true );
$r['order'] = get_post_meta( $id, 'sp_order', true );
else:
global $sportspress_statistic_priorities;
$sportspress_statistic_priorities = array(
array(
'statistic' => $r['orderby'],
'order' => $r['order'],
),
);
uasort( $data, 'sportspress_sort_list_players' );
endif;
if ( in_array( $r['orderby'], array( 'number', 'name' ) ) ):
$output .= '| # | ';
else:
$output .= '' . __( 'Rank', 'sportspress' ) . ' | ';
endif;
foreach( $labels as $key => $label ):
if ( ! is_array( $statistics ) || $key == 'name' || in_array( $key, $statistics ) )
$output .= ''. $label . ' | ';
endforeach;
$output .= '
' . '' . '';
$i = 0;
foreach( $data as $player_id => $row ):
$output .= '';
// Rank or number
if ( isset( $r['orderby'] ) && $r['orderby'] != 'number' ):
$output .= '| ' . ( $i + 1 ) . ' | ';
else:
$number = get_post_meta( $player_id, 'sp_number', true );
$output .= '' . ( $number ? $number : ' ' ) . ' | ';
endif;
// 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;
if ( ! is_array( $statistics ) || in_array( $key, $statistics ) )
$output .= '' . sportspress_array_value( $row, $key, '—' ) . ' | ';
endforeach;
$output .= '
';
$i++;
endforeach;
$output .= '' . '
' . '
';
return apply_filters( 'sportspress_player_list', $output );
}
}