diff --git a/admin/hooks/save-post.php b/admin/hooks/save-post.php index 046798fb..74011077 100644 --- a/admin/hooks/save-post.php +++ b/admin/hooks/save-post.php @@ -128,6 +128,9 @@ function sportspress_save_post( $post_id ) { case ( 'sp_table' ): + // Update columns array + update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) ); + // Update teams array update_post_meta( $post_id, 'sp_teams', sportspress_array_value( $_POST, 'sp_teams', array() ) ); diff --git a/admin/post-types/table.php b/admin/post-types/table.php index 8e3b0308..32f41419 100644 --- a/admin/post-types/table.php +++ b/admin/post-types/table.php @@ -100,9 +100,9 @@ function sportspress_table_team_meta( $post, $test ) { function sportspress_table_columns_meta( $post ) { - list( $columns, $data, $placeholders, $merged ) = sportspress_get_league_table_data( $post->ID, true ); + list( $columns, $usecolumns, $data, $placeholders, $merged ) = sportspress_get_league_table_data( $post->ID, true ); - sportspress_edit_league_table( $columns, $data, $placeholders ); + sportspress_edit_league_table( $columns, $usecolumns, $data, $placeholders ); sportspress_nonce(); } diff --git a/functions.php b/functions.php index acee158d..6564ca99 100644 --- a/functions.php +++ b/functions.php @@ -190,7 +190,7 @@ if ( !function_exists( 'sportspress_get_post_datetime' ) ) { if ( $post->post_status == 'future' ): $status = __( 'Scheduled', 'sportspress' ); elseif( $post->post_status == 'publish' ): - $status = __( 'Played', 'sportspress' ); + $status = __( 'Published', 'sportspress' ); elseif( $post->post_status == 'draft' ): $status = __( 'Draft', 'sportspress' ); else: @@ -772,15 +772,18 @@ if ( !function_exists( 'sportspress_get_var_calculates' ) ) { } if ( !function_exists( 'sportspress_edit_league_table' ) ) { - function sportspress_edit_league_table( $columns = array(), $data = array(), $placeholders = array() ) { + function sportspress_edit_league_table( $columns = array(), $usecolumns = array(), $data = array(), $placeholders = array() ) { ?>
- - + $label ): ?> + @@ -1638,6 +1641,7 @@ if ( !function_exists( 'sportspress_get_league_table_data' ) ) { $div_id = sportspress_get_the_term_id( $post_id, 'sp_season', 0 ); $team_ids = (array)get_post_meta( $post_id, 'sp_team', false ); $table_stats = (array)get_post_meta( $post_id, 'sp_teams', true ); + $usecolumns = get_post_meta( $post_id, 'sp_columns', true ); // Get labels from result variables $result_labels = (array)sportspress_get_var_labels( 'sp_result' ); @@ -1890,8 +1894,13 @@ if ( !function_exists( 'sportspress_get_league_table_data' ) ) { endforeach; if ( $breakdown ): - return array( $columns, $data, $placeholders, $merged ); + return array( $columns, $usecolumns, $data, $placeholders, $merged ); else: + foreach( $columns as $key => $label ): + if ( ! in_array( $key, $usecolumns ) ): + unset( $columns[ $key ] ); + endif; + endforeach; $labels = array_merge( array( 'name' => __( 'Team', 'sportspress' ) ), $columns ); $merged[0] = $labels; return $merged;