From 06221321b57517b8c4ab1dc918a6533d6fe5681f Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Mon, 21 Jul 2014 14:37:48 +1000 Subject: [PATCH] Display event results in admin teams column --- .../post-types/class-sp-admin-cpt-event.php | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/includes/admin/post-types/class-sp-admin-cpt-event.php b/includes/admin/post-types/class-sp-admin-cpt-event.php index 7a302068..84da7b21 100644 --- a/includes/admin/post-types/class-sp-admin-cpt-event.php +++ b/includes/admin/post-types/class-sp-admin-cpt-event.php @@ -124,15 +124,32 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT { if ( empty( $teams ) ): echo '—'; else: - $current_team = get_post_meta( $post_id, 'sp_current_team', true ); + $results = get_post_meta( $post_id, 'sp_results', true ); + $main_result = get_option( 'sportspress_primary_result', null ); foreach( $teams as $team_id ): if ( ! $team_id ) continue; $team = get_post( $team_id ); + if ( $team ): - echo $team->post_title; - if ( $team_id == $current_team ): - echo ''; + $team_results = sportspress_array_value( $results, $team_id, null ); + + if ( $main_result ): + $team_result = sportspress_array_value( $team_results, $main_result, null ); + else: + if ( is_array( $team_results ) ): + end( $team_results ); + $team_result = prev( $team_results ); + else: + $team_result = null; + endif; endif; + + if ( $team_result != null ): + unset( $team_results['outcome'] ); + $team_results = implode( ' | ', $team_results ); + echo '' . $team_result . ' '; + endif; + echo $team->post_title; echo '
'; endif; endforeach;