From 1b2b8c1111ee510d670074bf19d73b7d71d34803 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Sat, 2 Apr 2016 03:57:53 +1100 Subject: [PATCH] Adjust player meta box for auto columns and split statistics --- .../class-sp-meta-box-player-statistics.php | 19 +++++++++++-------- includes/class-sp-player.php | 8 ++++---- templates/player-statistics-league.php | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-statistics.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-statistics.php index a4b4988c..8aba1c14 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-statistics.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-statistics.php @@ -32,8 +32,8 @@ class SP_Meta_Box_Player_Statistics { ?>

name; ?>

data( $league->term_id, true ); - self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $i == 0 ); + list( $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes ) = $player->data( $league->term_id, true ); + self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes && $i == 0 ); $i ++; endforeach; } else { @@ -52,8 +52,8 @@ class SP_Meta_Box_Player_Statistics { ?>

name; ?> —

data( $league->term_id, true, $section_id ); - self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $i == 0 && $s == 0 ); + list( $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes ) = $player->data( $league->term_id, true, $section_id ); + self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes && $i == 0 && $s == 0, $s == 0 ); $i ++; endforeach; $s ++; @@ -73,7 +73,8 @@ class SP_Meta_Box_Player_Statistics { /** * Admin edit table */ - public static function table( $id = null, $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $leagues = array(), $has_checkboxes = false, $readonly = false ) { + public static function table( $id = null, $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $leagues = array(), $has_checkboxes = false, $team_select = false ) { + $readonly = false; $teams = array_filter( get_post_meta( $id, 'sp_team', false ) ); ?>
@@ -81,7 +82,7 @@ class SP_Meta_Box_Player_Statistics { - + - +   diff --git a/includes/class-sp-player.php b/includes/class-sp-player.php index c5004bec..f16bb125 100644 --- a/includes/class-sp-player.php +++ b/includes/class-sp-player.php @@ -128,6 +128,7 @@ class SP_Player extends SP_Custom_Post { if ( 'manual' == get_option( 'sportspress_player_columns', 'auto' ) ) { $usecolumns = get_post_meta( $this->ID, 'sp_columns', true ); + $has_checkboxes = true; } else { $usecolumns = array(); if ( is_array( $posts ) ) { @@ -139,6 +140,7 @@ class SP_Player extends SP_Custom_Post { } } } + $has_checkboxes = false; } // Get labels by section @@ -536,7 +538,7 @@ class SP_Player extends SP_Custom_Post { $labels[ $key ] = $columns[ $key ]; endif; endforeach; endif; - return array( $labels, $data, $placeholders, $merged, $leagues ); + return array( $labels, $data, $placeholders, $merged, $leagues, $has_checkboxes ); else: if ( is_array( $usecolumns ) ): foreach ( $columns as $key => $label ): @@ -552,9 +554,7 @@ class SP_Player extends SP_Custom_Post { $merged = array(); } else { $labels['name'] = __( 'Season', 'sportspress' ); - if ( in_array( 'team', $this->columns ) ) { - $labels['team'] = __( 'Team', 'sportspress' ); - } + $labels['team'] = __( 'Team', 'sportspress' ); } if ( 'yes' === get_option( 'sportspress_player_show_total', 'no' ) ) { diff --git a/templates/player-statistics-league.php b/templates/player-statistics-league.php index 0532ea2a..95c843da 100644 --- a/templates/player-statistics-league.php +++ b/templates/player-statistics-league.php @@ -26,7 +26,7 @@ foreach( $data as $season_id => $row ): $output .= ''; foreach( $labels as $key => $value ): - $output .= '' . sp_array_value( $row, $key, '—' ) . ''; + $output .= '' . sp_array_value( $row, $key, '' ) . ''; endforeach; $output .= '';