From 4a225ef034fa57f6aac9b231cba0f60d0e9d64ef Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Sun, 16 Mar 2014 11:38:50 +1100 Subject: [PATCH] Display team names only when available --- admin/hooks/manage-posts-columns.php | 46 +++++++++++++++------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/admin/hooks/manage-posts-columns.php b/admin/hooks/manage-posts-columns.php index 917bb00b..f3dcde88 100644 --- a/admin/hooks/manage-posts-columns.php +++ b/admin/hooks/manage-posts-columns.php @@ -49,43 +49,47 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) { if ( ! $team_id ) continue; $team = get_post( $team_id ); - $team_results = sportspress_array_value( $results, $team_id, null ); + if ( $team ): + $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 ); + if ( $main_result ): + $team_result = sportspress_array_value( $team_results, $main_result, null ); else: - $team_result = null; + if ( is_array( $team_results ) ): + end( $team_results ); + $team_result = prev( $team_results ); + else: + $team_result = null; + endif; endif; + + if ( $team_result != null ): + echo '' . $team_result . ' '; + endif; + + echo $team->post_title; + + echo '
'; endif; - - if ( $team_result != null ): - echo '' . $team_result . ' '; - endif; - - echo $team->post_title; - - echo '
'; endforeach; elseif ( $post_type == 'sp_player' ): $current_team = get_post_meta( $post_id, 'sp_current_team', true ); foreach( $teams as $team_id ): if ( ! $team_id ) continue; $team = get_post( $team_id ); - echo $team->post_title; - if ( $team_id == $current_team ): - echo ''; + if ( $team ): + echo $team->post_title; + if ( $team_id == $current_team ): + echo ''; + endif; + echo '
'; endif; - echo '
'; endforeach; else: foreach( $teams as $team_id ): if ( ! $team_id ) continue; $team = get_post( $team_id ); - echo $team->post_title . '
'; + if ( $team ) echo $team->post_title . '
'; endforeach; endif; break;