Change league to division and remove sponsors

This commit is contained in:
Takumi
2013-10-24 11:56:53 +11:00
parent b6121a0487
commit 102d6d20e1
15 changed files with 121 additions and 146 deletions

View File

@@ -35,7 +35,7 @@ function sp_player_team_meta( $post ) {
function sp_player_stats_meta( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
$leagues = (array)get_the_terms( $post->ID, 'sp_league' );
$divisions = (array)get_the_terms( $post->ID, 'sp_division' );
$stats = (array)get_post_meta( $post->ID, 'sp_stats', true );
// Get column names from settings
@@ -43,21 +43,21 @@ function sp_player_stats_meta( $post ) {
$columns = sp_get_eos_keys( $stats_settings['player'] );
// Add first column label
array_unshift( $columns, __( 'League', 'sportspress' ) );
array_unshift( $columns, __( 'Division', 'sportspress' ) );
// Generate array of all league ids
$league_ids = array( 0 );
foreach ( $leagues as $key => $value ):
// Generate array of all division ids
$division_ids = array( 0 );
foreach ( $divisions as $key => $value ):
if ( is_object( $value ) && property_exists( $value, 'term_id' ) )
$league_ids[] = $value->term_id;
$division_ids[] = $value->term_id;
endforeach;
// Get all teams populated with overall stats where availabled
$data = sp_array_combine( $league_ids, sp_array_value( $stats, 0, array() ) );
$data = sp_array_combine( $division_ids, sp_array_value( $stats, 0, array() ) );
// Generate array of placeholder values for each league
// Generate array of placeholder values for each division
$placeholders = array();
foreach ( $league_ids as $league_id ):
foreach ( $division_ids as $division_id ):
$args = array(
'post_type' => 'sp_event',
'meta_query' => array(
@@ -67,33 +67,33 @@ function sp_player_stats_meta( $post ) {
)
)
);
if ( $league_id ):
if ( $division_id ):
$args['tax_query'] = array(
array(
'taxonomy' => 'sp_league',
'taxonomy' => 'sp_division',
'field' => 'id',
'terms' => $league_id
'terms' => $division_id
)
);
endif;
$placeholders[ $league_id ] = sp_get_stats_row( 'sp_player', $args );
$placeholders[ $division_id ] = sp_get_stats_row( 'sp_player', $args );
endforeach;
?>
<p><strong><?php _e( 'Overall', 'sportspress' ); ?></strong></p>
<?php
sp_stats_table( $data, $placeholders, 0, $columns, true, 'sp_league' );
sp_stats_table( $data, $placeholders, 0, $columns, true, 'sp_division' );
// Leagues
// Divisions
foreach ( $teams as $team ):
if ( !$team ) continue;
// Get all leagues populated with stats where availabled
$data = sp_array_combine( $league_ids, sp_array_value( $stats, $team, array() ) );
// Get all divisions populated with stats where availabled
$data = sp_array_combine( $division_ids, sp_array_value( $stats, $team, array() ) );
// Generate array of placeholder values for each league
// Generate array of placeholder values for each division
$placeholders = array();
foreach ( $league_ids as $league_id ):
foreach ( $division_ids as $division_id ):
$args = array(
'post_type' => 'sp_event',
'meta_query' => array(
@@ -108,19 +108,19 @@ function sp_player_stats_meta( $post ) {
),
'tax_query' => array(
array(
'taxonomy' => 'sp_league',
'taxonomy' => 'sp_division',
'field' => 'id',
'terms' => $league_id
'terms' => $division_id
)
)
);
$placeholders[ $league_id ] = sp_get_stats_row( 'sp_player', $args );
$placeholders[ $division_id ] = sp_get_stats_row( 'sp_player', $args );
endforeach;
?>
<p><strong><?php echo get_the_title( $team ); ?></strong></p>
<?php
sp_stats_table( $data, $placeholders, $team, $columns, true, 'sp_league' );
sp_stats_table( $data, $placeholders, $team, $columns, true, 'sp_division' );
?>
<?php
@@ -138,8 +138,7 @@ function sp_player_edit_columns() {
'title' => __( 'Name', 'sportspress' ),
'sp_position' => __( 'Positions', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ),
'sp_sponsor' => __( 'Sponsors', 'sportspress' )
'sp_division' => __( 'Divisions', 'sportspress' )
);
return $columns;
}