diff --git a/admin/templates/event-details.php b/admin/templates/event-details.php
index a49736b3..1acb3f6d 100644
--- a/admin/templates/event-details.php
+++ b/admin/templates/event-details.php
@@ -2,10 +2,8 @@
if ( !function_exists( 'sportspress_event_details' ) ) {
function sportspress_event_details( $id = null ) {
- if ( ! $id ):
- global $post;
- $id = $post->ID;
- endif;
+ if ( ! $id )
+ $id = get_the_ID();
$date = get_the_time( get_option('date_format'), $id );
$time = get_the_time( get_option('time_format'), $id );
diff --git a/admin/templates/event-players.php b/admin/templates/event-players.php
index b6f86220..999dd732 100644
--- a/admin/templates/event-players.php
+++ b/admin/templates/event-players.php
@@ -2,10 +2,8 @@
if ( !function_exists( 'sportspress_event_players' ) ) {
function sportspress_event_players( $id = null ) {
- if ( ! $id ):
- global $post;
- $id = $post->ID;
- endif;
+ if ( ! $id )
+ $id = get_the_ID();
$teams = (array)get_post_meta( $id, 'sp_team', false );
$staff = (array)get_post_meta( $id, 'sp_staff', false );
diff --git a/admin/templates/event-results.php b/admin/templates/event-results.php
index a81dafd1..ab430259 100644
--- a/admin/templates/event-results.php
+++ b/admin/templates/event-results.php
@@ -2,10 +2,8 @@
if ( !function_exists( 'sportspress_event_results' ) ) {
function sportspress_event_results( $id = null ) {
- if ( ! $id ):
- global $post;
- $id = $post->ID;
- endif;
+ if ( ! $id )
+ $id = get_the_ID();
$teams = (array)get_post_meta( $id, 'sp_team', false );
$results = sportspress_array_combine( $teams, (array)get_post_meta( $id, 'sp_results', true ) );
diff --git a/admin/templates/event-staff.php b/admin/templates/event-staff.php
index 252557fc..be2a0fdb 100644
--- a/admin/templates/event-staff.php
+++ b/admin/templates/event-staff.php
@@ -2,11 +2,8 @@
if ( !function_exists( 'sportspress_event_staff' ) ) {
function sportspress_event_staff( $id = null ) {
- if ( ! $id ):
- global $post;
- $id = $post->ID;
- endif;
-
+ if ( ! $id )
+ $id = get_the_ID();
$staff = (array)get_post_meta( $id, 'sp_staff', false );
$output = '';
diff --git a/admin/templates/event-venue.php b/admin/templates/event-venue.php
index 98cf1715..9a132673 100644
--- a/admin/templates/event-venue.php
+++ b/admin/templates/event-venue.php
@@ -2,6 +2,9 @@
if ( !function_exists( 'sportspress_event_venue' ) ) {
function sportspress_event_venue( $id ) {
+ if ( ! $id )
+ $id = get_the_ID();
+
$venues = get_the_terms( $id, 'sp_venue' );
$output = '';
diff --git a/admin/templates/events-calendar.php b/admin/templates/events-calendar.php
index d79f7c53..4a652b81 100644
--- a/admin/templates/events-calendar.php
+++ b/admin/templates/events-calendar.php
@@ -2,10 +2,8 @@
if ( !function_exists( 'sportspress_events_calendar' ) ) {
function sportspress_events_calendar( $id = null ) {
- if ( ! $id ):
- global $post;
- $id = $post->ID;
- endif;
+ if ( ! $id )
+ $id = get_the_ID();
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
$initial = false;
diff --git a/admin/templates/league-table.php b/admin/templates/league-table.php
index 32b27595..ca06a60e 100644
--- a/admin/templates/league-table.php
+++ b/admin/templates/league-table.php
@@ -2,10 +2,8 @@
if ( !function_exists( 'sportspress_league_table' ) ) {
function sportspress_league_table( $id = null, $args = '' ) {
- if ( ! $id ):
- global $post;
- $id = $post->ID;
- endif;
+ if ( ! $id )
+ $id = get_the_ID();
$defaults = array(
'number_label' => __( 'Pos', 'sportspress' ),
@@ -26,8 +24,8 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
$title = sizeof( $terms ) ? implode( ' — ', $terms ) : get_the_title( $id );
- $output = '
' .
- '' . $title . '' . '' . '';
+ $output = '' . $title . '
' .
+ '' . '' . '';
$data = sportspress_get_league_table_data( $id );
diff --git a/admin/templates/player-league-statistics.php b/admin/templates/player-league-statistics.php
index 2fc4b8b4..6b2b52f4 100644
--- a/admin/templates/player-league-statistics.php
+++ b/admin/templates/player-league-statistics.php
@@ -2,10 +2,11 @@
if ( !function_exists( 'sportspress_player_league_statistics' ) ) {
function sportspress_player_league_statistics( $league, $id = null ) {
- if ( ! $id ):
- global $post;
- $id = $post->ID;
- endif;
+ if ( ! $league )
+ return false;
+
+ if ( ! $id )
+ $id = get_the_ID();
$data = sportspress_get_player_statistics_data( $id, $league->term_id );
@@ -15,8 +16,12 @@ if ( !function_exists( 'sportspress_player_league_statistics' ) ) {
// Remove the first row to leave us with the actual data
unset( $data[0] );
- $output = '' .
- '' . $league->name . '' . '' . '';
+ // Skip if there are no rows in the table
+ if ( empty( $data ) )
+ return false;
+
+ $output = '' . $league->name . '
' .
+ '' . '' . '';
foreach( $labels as $key => $label ):
$output .= '| ' . $label . ' | ';
diff --git a/admin/templates/player-list.php b/admin/templates/player-list.php
index 4429b8ce..af945f98 100644
--- a/admin/templates/player-list.php
+++ b/admin/templates/player-list.php
@@ -2,10 +2,8 @@
if ( !function_exists( 'sportspress_player_list' ) ) {
function sportspress_player_list( $id = null ) {
- if ( ! $id ):
- global $post;
- $id = $post->ID;
- endif;
+ if ( ! $id )
+ $id = get_the_ID();
$data = sportspress_get_player_list_data( $id );
diff --git a/admin/templates/player-metrics.php b/admin/templates/player-metrics.php
index 3af5a821..e978596e 100644
--- a/admin/templates/player-metrics.php
+++ b/admin/templates/player-metrics.php
@@ -2,10 +2,8 @@
if ( !function_exists( 'sportspress_player_metrics' ) ) {
function sportspress_player_metrics( $id = null ) {
- if ( ! $id ):
- global $post;
- $id = $post->ID;
- endif;
+ if ( ! $id )
+ $id = get_the_ID();
global $sportspress_countries;
diff --git a/admin/templates/player-statistics.php b/admin/templates/player-statistics.php
index 2717c910..7f10e76d 100644
--- a/admin/templates/player-statistics.php
+++ b/admin/templates/player-statistics.php
@@ -2,10 +2,8 @@
if ( !function_exists( 'sportspress_player_statistics' ) ) {
function sportspress_player_statistics( $id = null ) {
- if ( ! $id ):
- global $post;
- $id = $post->ID;
- endif;
+ if ( ! $id )
+ $id = get_the_ID();
$leagues = get_the_terms( $id, 'sp_league' );
diff --git a/admin/templates/team-columns.php b/admin/templates/team-columns.php
index 961037eb..f94097ee 100644
--- a/admin/templates/team-columns.php
+++ b/admin/templates/team-columns.php
@@ -2,13 +2,14 @@
if ( !function_exists( 'sportspress_team_columns' ) ) {
function sportspress_team_columns( $id = null ) {
- if ( ! $id ):
- global $post;
- $id = $post->ID;
- endif;
+ if ( ! $id )
+ $id = get_the_ID();
$leagues = get_the_terms( $id, 'sp_league' );
+ if ( ! $leagues )
+ return false;
+
$output = '';
// Loop through data for each league
@@ -19,16 +20,14 @@ if ( !function_exists( 'sportspress_team_columns' ) ) {
if ( sizeof( $data ) <= 1 )
continue;
- if ( sizeof( $leagues ) > 1 )
- $output .= '' . $league->name . '
';
-
// The first row should be column labels
$labels = $data[0];
// Remove the first row to leave us with the actual data
unset( $data[0] );
- $output .= '' . '' . '';
+ $output .= '' . $league->name . '
' .
+ '' . '' . '';
foreach( $labels as $key => $label ):
$output .= '| ' . $label . ' | ';