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 0777c789..132efcef 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 @@ -20,9 +20,10 @@ class SP_Meta_Box_Player_Statistics { */ public static function output( $post ) { $leagues = get_the_terms( $post->ID, 'sp_league' ); - $league_num = sizeof( $leagues ); + $usecolumns = get_post_meta( $post->ID, 'sp_columns', true ); + // Loop through statistics for each league if ( $leagues ): foreach ( $leagues as $league ): @@ -34,8 +35,7 @@ class SP_Meta_Box_Player_Statistics { $player = new SP_Player( $post ); list( $columns, $data, $placeholders, $merged, $seasons_teams ) = $player->data( $league->term_id, true ); - - self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_player_statistics' ) ); + self::table( $post->ID, $league->term_id, $columns, $usecolumns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_player_statistics' ) ); endforeach; else: @@ -48,6 +48,7 @@ class SP_Meta_Box_Player_Statistics { * Save meta box data */ public static function save( $post_id, $post ) { + update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) ); update_post_meta( $post_id, 'sp_leagues', sp_array_value( $_POST, 'sp_leagues', array() ) ); if ( current_user_can( 'edit_sp_player_statistics' ) ) update_post_meta( $post_id, 'sp_statistics', sp_array_value( $_POST, 'sp_statistics', array() ) ); @@ -56,8 +57,10 @@ 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(), $readonly = true ) { + public static function table( $id = null, $league_id, $columns = array(), $usecolumns = null, $data = array(), $placeholders = array(), $merged = array(), $leagues = array(), $readonly = true ) { $teams = array_filter( get_post_meta( $id, 'sp_team', false ) ); + if ( is_array( $usecolumns ) ) + $usecolumns = array_filter( $usecolumns ); ?>
| - - | + $label ): ?> + |
|---|