diff --git a/admin/post-types/event.php b/admin/post-types/event.php index 1fb89371..867e1896 100644 --- a/admin/post-types/event.php +++ b/admin/post-types/event.php @@ -72,8 +72,30 @@ function sp_event_team_meta( $post ) { sp_nonce(); } -function sp_event_article_meta( $post ) { - wp_editor( $post->post_content, 'content' ); +function sp_event_stats_meta( $post ) { + $limit = get_option( 'sp_event_team_count' ); + $teams = array_pad( array_slice( (array)get_post_meta( $post->ID, 'sp_team', false ), 0, $limit ), $limit, 0 ); + $stats = (array)get_post_meta( $post->ID, 'sp_stats', true ); + + // Get columns from result variables + $columns = sp_get_var_columns( 'sp_metric', true ); + + // Teams + foreach ( $teams as $key => $team_id ): + + // Get results for players in the team + $players = sp_array_between( (array)get_post_meta( $post->ID, 'sp_player', false ), 0, $key ); + $data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) ); + + ?> +
+

+ +
+ ID, 'sp_team', false ), 0, $limit ), $limit, 0 ); $results = (array)get_post_meta( $post->ID, 'sp_results', true ); + // Get columns from result variables + $columns = sp_get_var_columns( 'sp_result' ); + // Get results for all teams $data = sp_array_combine( $teams, $results ); - // Get column names from settings - $stats_settings = get_option( 'sportspress_stats' ); - - $columns = sp_get_var_columns( 'sp_result', $post->ID ); ?>
- +
ID, 'sp_team', false ), 0, $limit ), $limit, 0 ); - $stats = (array)get_post_meta( $post->ID, 'sp_stats', true ); - - // Get column names from settings - $stats_settings = get_option( 'sportspress_stats' ); - $columns = sp_get_eos_keys( $stats_settings['player'] ); - - // Add first column label - array_unshift( $columns, __( 'Player', 'sportspress' ) ); - - // Teams - foreach ( $teams as $key => $value ): - - // Get results for players in the team - $players = sp_array_between( (array)get_post_meta( $post->ID, 'sp_player', false ), 0, $key ); - $data = sp_array_combine( $players, sp_array_value( $stats, $value, array() ) ); - - ?> -
-

- -
- post_content, 'content' ); } function sp_event_edit_columns() { diff --git a/sportspress-helpers.php b/sportspress-helpers.php index 0ca49ca9..f08853b2 100644 --- a/sportspress-helpers.php +++ b/sportspress-helpers.php @@ -385,15 +385,23 @@ if ( !function_exists( 'sp_get_eos_keys' ) ) { if ( !function_exists( 'sp_get_var_columns' ) ) { - function sp_get_var_columns( $post_type, $exclude ) { + function sp_get_var_columns( $post_type, $indies = false ) { $args = array( 'post_type' => $post_type, 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', - 'order' => 'ASC', - 'exclude' => $exclude + 'order' => 'ASC' ); + if ( $indies ): + $args['meta_query'] = array( + array( + 'key' => 'sp_equation', + 'value'=>'' + ) + ); + endif; + $vars = get_posts( $args ); $output = array(); @@ -660,8 +668,8 @@ if ( !function_exists( 'sp_stats_table' ) ) { } } -if ( !function_exists( 'sp_results_table' ) ) { - function sp_results_table( $columns = array(), $data = array(), $placeholders = array() ) { +if ( !function_exists( 'sp_event_results_table' ) ) { + function sp_event_results_table( $columns = array(), $data = array() ) { ?> @@ -684,9 +692,8 @@ if ( !function_exists( 'sp_results_table' ) ) { $label ): $value = sp_array_value( $team_results, $column, '' ); - $placeholder = (int)sp_array_value( sp_array_value( $placeholders, $team_id, 0), $column, 0 ); ?> - +
- + @@ -714,18 +721,66 @@ if ( !function_exists( 'sp_players_table' ) ) { $team_results ): - if ( !$team_id ) continue; + foreach ( $data as $player_id => $player_metrics ): + if ( !$player_id ) continue; ?> $label ): - $value = sp_array_value( $team_results, $column, '' ); - $placeholder = (int)sp_array_value( sp_array_value( $placeholders, $team_id, 0), $column, 0 ); + $value = sp_array_value( $player_metrics, $column, '' ); ?> - + + + + + + + $label ): + $player_id = 0; + $player_metrics = $data[0]; + $value = sp_array_value( $player_metrics, $column, '' ); + ?> + + + + +
- +
+ + + + + + + + + + + + $player_metrics ): + if ( !$player_id ) continue; + ?> + + + $label ): + $value = sp_array_value( $player_metrics, $column, '' ); + $placeholder = (int)sp_array_value( sp_array_value( $placeholders, $player_id, 0), $column, 0 ); + ?> + "> $label ): - $team_id = 0; - $value = sp_array_value( $team_results, $column, '' ); - $placeholder = (int)sp_array_value( sp_array_value( $placeholders, $team_id, 0), $column, 0 ); + $player_id = 0; + $value = sp_array_value( $player_metrics, $column, '' ); + $placeholder = (int)sp_array_value( sp_array_value( $placeholders, $player_id, 0), $column, 0 ); ?> - +
+ +