Better way of getting ID

This commit is contained in:
Brian Miyaji
2014-01-22 21:01:58 +11:00
parent 7555d78739
commit d7509b8614
12 changed files with 41 additions and 53 deletions

View File

@@ -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 );

View File

@@ -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 );

View File

@@ -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 ) );

View File

@@ -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 = '';

View File

@@ -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 = '';

View File

@@ -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;

View File

@@ -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 = '<table class="sp-league-table sp-data-table">' .
'<caption>' . $title . '</caption>' . '<thead>' . '<tr>';
$output = '<h4 class="sp-table-caption">' . $title . '</h4>' .
'<table class="sp-league-table sp-data-table">' . '<thead>' . '<tr>';
$data = sportspress_get_league_table_data( $id );

View File

@@ -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 = '<table class="sp-player-statistics sp-data-table">' .
'<caption>' . $league->name . '</caption>' . '<thead>' . '<tr>';
// Skip if there are no rows in the table
if ( empty( $data ) )
return false;
$output = '<h4 class="sp-table-caption">' . $league->name . '</h4>' .
'<table class="sp-player-statistics sp-data-table">' . '<thead>' . '<tr>';
foreach( $labels as $key => $label ):
$output .= '<th class="data-' . $key . '">' . $label . '</th>';

View File

@@ -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 );

View File

@@ -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;

View File

@@ -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' );

View File

@@ -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 .= '<h4 class="sp-team-league-name">' . $league->name . '</h4>';
// 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 .= '<table class="sp-team-columns sp-data-table">' . '<thead>' . '<tr>';
$output .= '<h4 class="sp-table-caption">' . $league->name . '</h4>' .
'<table class="sp-team-columns sp-data-table">' . '<thead>' . '<tr>';
foreach( $labels as $key => $label ):
$output .= '<th class="data-' . $key . '">' . $label . '</th>';