Add array functions and clean shit up

This commit is contained in:
Takumi
2013-07-30 19:22:50 +10:00
parent f76bc15c56
commit e3f2e521cc
5 changed files with 69 additions and 55 deletions

View File

@@ -33,17 +33,23 @@ function sp_player_team_meta( $post ) {
}
function sp_player_stats_meta( $post ) {
$ids = (array)get_post_meta( $post->ID, 'sp_team', false );
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
$leagues = (array)get_the_terms( $post->ID, 'sp_league' );
$stats = (array)get_post_meta( $post->ID, 'sp_stats', true );
$stats = $stats[0];
$data = array();
foreach ( $ids as $id ):
if ( is_array( $stats ) && array_key_exists( $id, $stats ) )
$data[ $id ] = $stats[ $id ];
else
$data[ $id ] = array();
foreach ( $leagues as $league ):
if ( !$league ) continue;
$data = sp_array_combine( $teams, sp_array_value( $stats, $league->term_id, array() ) );
?>
<div>
<p>
<strong><?php echo $league->name; ?></strong>
</p>
<?php
sp_data_table( $data, $league->term_id, array( 'Team', 'Played', 'Goals', 'Assists', 'Yellow Cards', 'Red Cards' ) );
?>
</div>
<?php
endforeach;
sp_data_table( $data, 0, array( 'Team', 'Played', 'Goals', 'Assists', 'Yellow Cards', 'Red Cards' ) );
}
function sp_player_profile_meta( $post ) {