From 151ad04fcacdb0849c4456c5495023d0cf3a476a Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Sun, 15 Jan 2017 10:01:59 +1100 Subject: [PATCH] Fix error in event results if team was deleted --- includes/sp-api-functions.php | 4 ++++ templates/event-results.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/sp-api-functions.php b/includes/sp-api-functions.php index 88c0ec1a..fb58df1e 100644 --- a/includes/sp-api-functions.php +++ b/includes/sp-api-functions.php @@ -16,6 +16,10 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly * General functions */ +function sp_post_exists( $post = 0 ) { + return is_string( get_post_status( $post ) ); +} + function sp_get_time( $post = 0, $format = null ) { if ( null == $format ) $format = get_option( 'time_format' ); return get_post_time( $format, false, $post, true ); diff --git a/templates/event-results.php b/templates/event-results.php index 6fb39333..7b7bd8c9 100644 --- a/templates/event-results.php +++ b/templates/event-results.php @@ -66,7 +66,7 @@ foreach( $data as $team_id => $result ): $team_name = sp_get_team_name( $team_id, $abbreviate_teams ); - if ( $link_teams ): + if ( $link_teams && sp_post_exists( $team_id ) ): $team_name = '' . $team_name . ''; endif;