Use template function and load as needed
This commit is contained in:
43
templates/countdown.php
Normal file
43
templates/countdown.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
if ( isset( $id ) ):
|
||||
$post = get_post( $id );
|
||||
else:
|
||||
$args = array();
|
||||
if ( isset( $team ) )
|
||||
$args = array( 'key' => 'sp_team', 'value' => $team );
|
||||
$post = sportspress_get_next_event( $args );
|
||||
endif;
|
||||
|
||||
$output = '';
|
||||
|
||||
if ( isset( $post ) ):
|
||||
$output .= '<div id="sp-countdown-wrapper">';
|
||||
$output .= '<h3 class="event-name"><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h3>';
|
||||
|
||||
if ( isset( $show_league ) && $show_league ):
|
||||
$leagues = get_the_terms( $post->ID, 'sp_league' );
|
||||
if ( $leagues ):
|
||||
foreach( $leagues as $league ):
|
||||
$term = get_term( $league->term_id, 'sp_league' );
|
||||
$output .= '<h5 class="event-league">' . $term->name . '</h5>';
|
||||
endforeach;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$now = new DateTime( current_time( 'mysql', 0 ) );
|
||||
$date = new DateTime( $post->post_date );
|
||||
$interval = date_diff( $now, $date );
|
||||
|
||||
$output .= '<p class="countdown sp-countdown"><time datetime="' . $post->post_date . '" data-countdown="' . str_replace( '-', '/', $post->post_date ) . '">' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->days ) ) . ' <small>' . __( 'days', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->h ) ) . ' <small>' . __( 'hrs', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->i ) ) . ' <small>' . __( 'mins', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->s ) ) . ' <small>' . __( 'secs', 'sportspress' ) . '</small></span>' .
|
||||
'</time></p>';
|
||||
|
||||
$output .= '</div>';
|
||||
else:
|
||||
return false;
|
||||
endif;
|
||||
|
||||
echo apply_filters( 'sportspress_countdown', $output );
|
||||
200
templates/event-calendar.php
Normal file
200
templates/event-calendar.php
Normal file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
|
||||
|
||||
// Quick check. If we have no posts at all, abort!
|
||||
if ( ! $posts )
|
||||
return;
|
||||
|
||||
$defaults = array(
|
||||
'id' => null,
|
||||
'initial' => true,
|
||||
'caption_tag' => 'h4',
|
||||
'show_all_events_link' => false,
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
|
||||
if ( isset( $id ) ):
|
||||
$events = sportspress_get_calendar_data( $id );
|
||||
$event_ids = array();
|
||||
foreach ( $events as $event ):
|
||||
$event_ids[] = $event->ID;
|
||||
endforeach;
|
||||
$in = 'AND ID IN (' . implode( ', ', $event_ids ) . ')';
|
||||
else:
|
||||
$in = '';
|
||||
endif;
|
||||
|
||||
// week_begins = 0 stands for Sunday
|
||||
$week_begins = intval(get_option('start_of_week'));
|
||||
|
||||
// Get year and month from query vars
|
||||
$year = isset( $_GET['sp_year'] ) ? $_GET['sp_year'] : $year;
|
||||
$monthnum = isset( $_GET['sp_month'] ) ? $_GET['sp_month'] : $monthnum;
|
||||
|
||||
// Let's figure out when we are
|
||||
if ( !empty($monthnum) && !empty($year) ) {
|
||||
$thismonth = ''.zeroise(intval($monthnum), 2);
|
||||
$thisyear = ''.intval($year);
|
||||
} elseif ( !empty($w) ) {
|
||||
// We need to get the month from MySQL
|
||||
$thisyear = ''.intval(substr($m, 0, 4));
|
||||
$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
|
||||
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
||||
} elseif ( !empty($m) ) {
|
||||
$thisyear = ''.intval(substr($m, 0, 4));
|
||||
if ( strlen($m) < 6 )
|
||||
$thismonth = '01';
|
||||
else
|
||||
$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
|
||||
} else {
|
||||
$thisyear = gmdate('Y', current_time('timestamp'));
|
||||
$thismonth = gmdate('m', current_time('timestamp'));
|
||||
}
|
||||
|
||||
$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
|
||||
$last_day = date('t', $unixmonth);
|
||||
|
||||
// Get the next and previous month and year with at least one post
|
||||
$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||
FROM $wpdb->posts
|
||||
WHERE post_date < '$thisyear-$thismonth-01'
|
||||
AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' )
|
||||
$in
|
||||
ORDER BY post_date DESC
|
||||
LIMIT 1");
|
||||
$next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||
FROM $wpdb->posts
|
||||
WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
|
||||
AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' )
|
||||
$in
|
||||
ORDER BY post_date ASC
|
||||
LIMIT 1");
|
||||
|
||||
/* translators: Calendar caption: 1: month name, 2: 4-digit year */
|
||||
$calendar_caption = _x('%1$s %2$s', 'calendar caption', 'sportspress');
|
||||
$calendar_output = '
|
||||
<div class="sp-calendar-wrapper">
|
||||
<table id="wp-calendar" class="sp-calendar sp-event-calendar">
|
||||
<' . $caption_tag . ' class="sp-table-caption">' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</' . $caption_tag . '>
|
||||
<thead>
|
||||
<tr>';
|
||||
|
||||
$myweek = array();
|
||||
|
||||
for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
|
||||
$myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
|
||||
}
|
||||
|
||||
foreach ( $myweek as $wd ) {
|
||||
$day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
|
||||
$wd = esc_attr($wd);
|
||||
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
|
||||
}
|
||||
|
||||
$calendar_output .= '
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>';
|
||||
|
||||
if ( $previous ) {
|
||||
$calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a data-tooltip data-options="disable_for_touch:true" class="has-tooltip tip-right" href="' . add_query_arg( array( 'sp_year' => $previous->year, 'sp_month' => $previous->month ) ) . '" title="' . esc_attr( sprintf(_x('%1$s %2$s', 'calendar caption', 'sportspress'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
|
||||
} else {
|
||||
$calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
|
||||
}
|
||||
|
||||
$calendar_output .= "\n\t\t".'<td class="pad"> </td>';
|
||||
|
||||
if ( $next ) {
|
||||
$calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a data-tooltip data-options="disable_for_touch:true" class="has-tooltip tip-left" href="' . add_query_arg( array( 'sp_year' => $next->year, 'sp_month' => $next->month ) ) . '" title="' . esc_attr( sprintf(_x('%1$s %2$s', 'calendar caption', 'sportspress'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>';
|
||||
} else {
|
||||
$calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
|
||||
}
|
||||
|
||||
$calendar_output .= '
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody>
|
||||
<tr>';
|
||||
|
||||
// Get days with posts
|
||||
$dayswithposts = $wpdb->get_results("SELECT DAYOFMONTH(post_date), ID
|
||||
FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
|
||||
AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' )
|
||||
$in
|
||||
AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
|
||||
if ( $dayswithposts ) {
|
||||
foreach ( (array) $dayswithposts as $daywith ) {
|
||||
$daywithpost[ $daywith[0] ][] = $daywith[1];
|
||||
}
|
||||
} else {
|
||||
$daywithpost = array();
|
||||
}
|
||||
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
|
||||
$ak_title_separator = "\n";
|
||||
else
|
||||
$ak_title_separator = ', ';
|
||||
|
||||
$ak_titles_for_day = array();
|
||||
$ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
|
||||
."FROM $wpdb->posts "
|
||||
."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
|
||||
."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
|
||||
."AND post_type = 'sp_event' AND ( post_status = 'publish' OR post_status = 'future' ) "
|
||||
."$in"
|
||||
);
|
||||
if ( $ak_post_titles ) {
|
||||
foreach ( (array) $ak_post_titles as $ak_post_title ) {
|
||||
|
||||
/** This filter is documented in wp-includes/post-template.php */
|
||||
$post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
|
||||
|
||||
if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
|
||||
$ak_titles_for_day['day_'.$ak_post_title->dom] = '';
|
||||
if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
|
||||
$ak_titles_for_day["$ak_post_title->dom"] = $post_title;
|
||||
else
|
||||
$ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
|
||||
}
|
||||
}
|
||||
|
||||
// See how much we should pad in the beginning
|
||||
$pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
|
||||
if ( 0 != $pad )
|
||||
$calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>';
|
||||
|
||||
$daysinmonth = intval(date('t', $unixmonth));
|
||||
for ( $day = 1; $day <= $daysinmonth; ++$day ) {
|
||||
if ( isset($newrow) && $newrow )
|
||||
$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
|
||||
$newrow = false;
|
||||
|
||||
if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
|
||||
$calendar_output .= '<td id="today">';
|
||||
else
|
||||
$calendar_output .= '<td>';
|
||||
|
||||
if ( array_key_exists($day, $daywithpost) ) // any posts today?
|
||||
$calendar_output .= '<a data-tooltip data-options="disable_for_touch:true" class="has-tip" href="' . ( sizeof( $daywithpost[ $day ] ) > 1 ? add_query_arg( array( 'post_type' => 'sp_event' ), get_day_link( $thisyear, $thismonth, $day ) ) . '" title="' . sprintf( '%s events', ( sizeof( $daywithpost[ $day ] ) ) ) : get_permalink( $daywithpost[ $day ][0] ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) ) . "\">$day</a>";
|
||||
else
|
||||
$calendar_output .= $day;
|
||||
$calendar_output .= '</td>';
|
||||
|
||||
if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
|
||||
$newrow = true;
|
||||
}
|
||||
|
||||
$pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
|
||||
if ( $pad != 0 && $pad != 7 )
|
||||
$calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>';
|
||||
|
||||
$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>\n\t</div>";
|
||||
|
||||
if ( $id && $show_all_events_link )
|
||||
$calendar_output .= '<a class="sp-calendar-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
|
||||
|
||||
echo apply_filters( 'sportspress_event_calendar', $calendar_output );
|
||||
42
templates/event-details.php
Normal file
42
templates/event-details.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$date = get_the_time( get_option('date_format'), $id );
|
||||
$time = get_the_time( get_option('time_format'), $id );
|
||||
$leagues = get_the_terms( $id, 'sp_league' );
|
||||
$seasons = get_the_terms( $id, 'sp_season' );
|
||||
|
||||
$data = array( __( 'Date', 'sportspress' ) => $date, __( 'Time', 'sportspress' ) => $time );
|
||||
|
||||
if ( $leagues ):
|
||||
$league = array_pop( $leagues );
|
||||
$data[ __( 'League', 'sportspress' ) ] = $league->name;
|
||||
endif;
|
||||
|
||||
if ( $seasons ):
|
||||
$season = array_pop( $seasons );
|
||||
$data[ __( 'Season', 'sportspress' ) ] = $season->name;
|
||||
endif;
|
||||
|
||||
$output = '<h3>' . __( 'Details', 'sportspress' ) . '</h3>';
|
||||
|
||||
$output .= '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-event-details sp-data-table"><tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $label => $value ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
$output .= '<th>' . $label . '</th>';
|
||||
$output .= '<td>' . $value . '</td>';
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody></table></div>';
|
||||
|
||||
echo apply_filters( 'sportspress_event_details', $output );
|
||||
121
templates/event-list.php
Normal file
121
templates/event-list.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
global $sportspress_options;
|
||||
$main_result = sportspress_array_value( $sportspress_options, 'main_result', null );
|
||||
|
||||
$defaults = array(
|
||||
'show_all_events_link' => false,
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
|
||||
$output = '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-event-list sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
|
||||
list( $data, $usecolumns ) = sportspress_get_calendar_data( $id, true );
|
||||
|
||||
if ( isset( $columns ) )
|
||||
$usecolumns = $columns;
|
||||
|
||||
$output .= '<th class="column-date">' . __( 'Date', 'sportspress' ). '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
||||
$output .= '<th class="column-event">' . __( 'Event', 'sportspress' ). '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) )
|
||||
$output .= '<th class="column-teams">' . __( 'Teams', 'sportspress' ). '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
||||
$output .= '<th class="column-time">' . __( 'Time', 'sportspress' ). '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'article', $usecolumns ) )
|
||||
$output .= '<th class="column-article">' . __( 'Article', 'sportspress' ). '</th>';
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
foreach ( $data as $event ):
|
||||
$teams = get_post_meta( $event->ID, 'sp_team' );
|
||||
$results = get_post_meta( $event->ID, 'sp_results', true );
|
||||
$video = get_post_meta( $event->ID, 'sp_video', true );
|
||||
|
||||
$output .= '<tr class="sp-row sp-post' . ( $i % 2 == 0 ? ' alternate' : '' ) . '">';
|
||||
|
||||
$output .= '<td class="column-date">' . get_post_time( get_option( 'date_format' ), false, $event ) . '</td>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
||||
$output .= '<td class="column-event">' . $event->post_title . '</td>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ):
|
||||
$output .= '<td class="column-teams">';
|
||||
|
||||
$teams = get_post_meta( $event->ID, 'sp_team', false );
|
||||
if ( $teams ):
|
||||
foreach ( $teams as $team ):
|
||||
$name = get_the_title( $team );
|
||||
if ( $name ):
|
||||
$team_results = sportspress_array_value( $results, $team, 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;
|
||||
|
||||
$output .= $name;
|
||||
|
||||
if ( $team_result != null ):
|
||||
$output .= ' (' . $team_result . ')';
|
||||
endif;
|
||||
|
||||
$output .= '<br>';
|
||||
endif;
|
||||
endforeach;
|
||||
else:
|
||||
$output .= '—';
|
||||
endif;
|
||||
|
||||
$output .= '</td>';
|
||||
endif;
|
||||
|
||||
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
||||
$output .= '<td class="column-time">' . get_post_time( get_option( 'time_format' ), false, $event ) . '</td>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'article', $usecolumns ) ):
|
||||
$output .= '<td class="column-article">
|
||||
<a href="' . get_permalink( $event->ID ) . '#sp_articlediv">';
|
||||
|
||||
if ( $video ):
|
||||
$output .= '<div class="dashicons dashicons-video-alt"></div>';
|
||||
elseif ( has_post_thumbnail( $event->ID ) ):
|
||||
$output .= '<div class="dashicons dashicons-camera"></div>';
|
||||
endif;
|
||||
if ( $event->post_content !== null ):
|
||||
if ( $event->post_status == 'publish' ):
|
||||
$output .= __( 'Recap', 'sportspress' );
|
||||
else:
|
||||
$output .= __( 'Preview', 'sportspress' );
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$output .= '</a>
|
||||
</td>';
|
||||
endif;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>';
|
||||
|
||||
if ( $id && $show_all_events_link )
|
||||
$output .= '<a class="sp-calendar-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
echo apply_filters( 'sportspress_event_list', $output );
|
||||
121
templates/event-performance.php
Normal file
121
templates/event-performance.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
global $sportspress_options;
|
||||
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$teams = (array)get_post_meta( $id, 'sp_team', false );
|
||||
$staff = (array)get_post_meta( $id, 'sp_staff', false );
|
||||
$stats = (array)get_post_meta( $id, 'sp_players', true );
|
||||
$performance_labels = sportspress_get_var_labels( 'sp_performance' );
|
||||
$link_posts = sportspress_array_value( $sportspress_options, 'event_performance_link_posts', true );
|
||||
$sortable = sportspress_array_value( $sportspress_options, 'event_performance_sortable', true );
|
||||
$responsive = sportspress_array_value( $sportspress_options, 'event_performance_responsive', true );
|
||||
|
||||
$output = '';
|
||||
|
||||
foreach( $teams as $key => $team_id ):
|
||||
if ( ! $team_id ) continue;
|
||||
|
||||
$totals = array();
|
||||
|
||||
// Get results for players in the team
|
||||
$players = sportspress_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $key );
|
||||
$data = sportspress_array_combine( $players, sportspress_array_value( $stats, $team_id, array() ) );
|
||||
|
||||
$output .= '<h3>' . get_the_title( $team_id ) . '</h3>';
|
||||
|
||||
$output .= '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-event-performance sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . ( $sortable ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
|
||||
|
||||
$output .= '<th class="data-number">#</th>';
|
||||
$output .= '<th class="data-number">' . __( 'Player', 'sportspress' ) . '</th>';
|
||||
|
||||
foreach( $performance_labels as $key => $label ):
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $player_id => $row ):
|
||||
|
||||
if ( ! $player_id )
|
||||
continue;
|
||||
|
||||
$name = get_the_title( $player_id );
|
||||
|
||||
if ( ! $name )
|
||||
continue;
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
|
||||
// Player number
|
||||
$output .= '<td class="data-number">' . $number . '</td>';
|
||||
|
||||
if ( $link_posts ):
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
endif;
|
||||
|
||||
$output .= '<td class="data-name">' . $name . '</td>';
|
||||
|
||||
foreach( $performance_labels as $key => $label ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
|
||||
$value = $row[ $key ];
|
||||
else:
|
||||
$value = 0;
|
||||
endif;
|
||||
if ( ! array_key_exists( $key, $totals ) ):
|
||||
$totals[ $key ] = 0;
|
||||
endif;
|
||||
$totals[ $key ] += $value;
|
||||
$output .= '<td class="data-' . $key . '">' . $value . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>';
|
||||
|
||||
if ( array_key_exists( 0, $data ) ):
|
||||
|
||||
$output .= '<tfoot><tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
|
||||
// Player number
|
||||
$output .= '<td class="data-number"> </td>';
|
||||
$output .= '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>';
|
||||
|
||||
$row = $data[0];
|
||||
|
||||
foreach( $performance_labels as $key => $label ):
|
||||
if ( $key == 'name' ):
|
||||
continue;
|
||||
endif;
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
|
||||
$value = $row[ $key ];
|
||||
else:
|
||||
$value = sportspress_array_value( $totals, $key, 0 );
|
||||
endif;
|
||||
$output .= '<td class="data-' . $key . '">' . $value . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr></tfoot>';
|
||||
|
||||
endif;
|
||||
|
||||
$output .= '</table>' . '</div>';
|
||||
|
||||
endforeach;
|
||||
|
||||
echo apply_filters( 'sportspress_event_performance', $output );
|
||||
66
templates/event-results.php
Normal file
66
templates/event-results.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$teams = (array)get_post_meta( $id, 'sp_team', false );
|
||||
$results = array_filter( sportspress_array_combine( $teams, (array)get_post_meta( $id, 'sp_results', true ) ), 'array_filter' );
|
||||
$result_labels = sportspress_get_var_labels( 'sp_result' );
|
||||
|
||||
$output = '';
|
||||
|
||||
// Initialize and check
|
||||
$table_rows = '';
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ( empty( $results ) )
|
||||
return false;
|
||||
|
||||
foreach( $results as $team_id => $result ):
|
||||
if ( sportspress_array_value( $result, 'outcome', '-1' ) != '-1' ):
|
||||
|
||||
unset( $result['outcome'] );
|
||||
|
||||
$table_rows .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
$table_rows .= '<td class="data-name">' . get_the_title( $team_id ) . '</td>';
|
||||
|
||||
foreach( $result_labels as $key => $label ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( array_key_exists( $key, $result ) && $result[ $key ] != '' ):
|
||||
$value = $result[ $key ];
|
||||
else:
|
||||
$value = '—';
|
||||
endif;
|
||||
$table_rows .= '<td class="data-' . $key . '">' . $value . '</td>';
|
||||
endforeach;
|
||||
|
||||
$table_rows .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
if ( empty( $table_rows ) ):
|
||||
|
||||
return false;
|
||||
|
||||
else:
|
||||
|
||||
$output .= '<h3>' . __( 'Results', 'sportspress' ) . '</h3>';
|
||||
|
||||
$output .= '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-event-results sp-data-table sp-responsive-table"><thead>' .
|
||||
'<th class="data-name">' . __( 'Team', 'sportspress' ) . '</th>';
|
||||
foreach( $result_labels as $key => $label ):
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
$output .= $table_rows;
|
||||
$output .= '</tbody>' . '</table>' . '</div>';
|
||||
|
||||
endif;
|
||||
|
||||
echo $output;
|
||||
8
templates/event-staff.php
Normal file
8
templates/event-staff.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
$staff = (array)get_post_meta( $id, 'sp_staff', false );
|
||||
|
||||
$output = '';
|
||||
|
||||
echo apply_filters( 'sportspress_event_staff', $output );
|
||||
28
templates/event-venue.php
Normal file
28
templates/event-venue.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$venues = get_the_terms( $id, 'sp_venue' );
|
||||
|
||||
$output = '';
|
||||
|
||||
if ( ! $venues )
|
||||
return $output;
|
||||
|
||||
foreach( $venues as $venue ):
|
||||
|
||||
$t_id = $venue->term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
|
||||
$address = sportspress_array_value( $term_meta, 'sp_address', '' );
|
||||
$latitude = sportspress_array_value( $term_meta, 'sp_latitude', 0 );
|
||||
$longitude = sportspress_array_value( $term_meta, 'sp_longitude', 0 );
|
||||
|
||||
$output .= '<h3>' . __( 'Venue', 'sportspress' ) . '</h3>';
|
||||
$output .= '<p><a href="' . get_term_link( $t_id, 'sp_venue' ) . '">' . $venue->name . '</a><br><small>' . $address . '</small></p>';
|
||||
if ( $latitude != null && $longitude != null )
|
||||
$output .= '<div class="sp-google-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
|
||||
|
||||
endforeach;
|
||||
|
||||
echo apply_filters( 'sportspress_event_venue', $output );
|
||||
90
templates/league-table.php
Normal file
90
templates/league-table.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
global $sportspress_options;
|
||||
|
||||
$defaults = array(
|
||||
'id' => get_the_ID(),
|
||||
'number' => -1,
|
||||
'columns' => null,
|
||||
'show_full_table_link' => false,
|
||||
'show_team_logo' => sportspress_array_value( $sportspress_options, 'league_table_show_team_logo', false ),
|
||||
'link_posts' => sportspress_array_value( $sportspress_options, 'league_table_link_posts', false ),
|
||||
'sortable' => sportspress_array_value( $sportspress_options, 'league_table_sortable', true ),
|
||||
'responsive' => sportspress_array_value( $sportspress_options, 'league_table_responsive', true ),
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
|
||||
$output = '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-league-table sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . ( $sortable ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
|
||||
|
||||
$data = sportspress_get_league_table_data( $id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
if ( ! $columns )
|
||||
$columns = get_post_meta( $id, 'sp_columns', true );
|
||||
|
||||
if ( ! is_array( $columns ) )
|
||||
$columns = explode( ',', $columns );
|
||||
|
||||
$output .= '<th class="data-rank">' . __( 'Pos', 'sportspress' ) . '</th>';
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
if ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) )
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ( is_int( $number ) && $number > 0 )
|
||||
$limit = $number;
|
||||
|
||||
foreach( $data as $team_id => $row ):
|
||||
|
||||
if ( isset( $limit ) && $i >= $limit ) continue;
|
||||
|
||||
$name = sportspress_array_value( $row, 'name', null );
|
||||
if ( ! $name ) continue;
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
// Rank
|
||||
$output .= '<td class="data-rank">' . ( $i + 1 ) . '</td>';
|
||||
|
||||
if ( $show_team_logo )
|
||||
$name = get_the_post_thumbnail( $team_id, 'sportspress-fit-icon', array( 'class' => 'team-logo' ) ) . ' ' . $name;
|
||||
|
||||
if ( $link_posts ):
|
||||
$permalink = get_post_permalink( $team_id );
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
endif;
|
||||
|
||||
$output .= '<td class="data-name">' . $name . '</td>';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( ! is_array( $columns ) || in_array( $key, $columns ) )
|
||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>';
|
||||
|
||||
if ( $show_full_table_link )
|
||||
$output .= '<a class="sp-league-table-link" href="' . get_permalink( $id ) . '">' . __( 'View full table', 'sportspress' ) . '</a>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
echo $output;
|
||||
133
templates/player-gallery.php
Normal file
133
templates/player-gallery.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
global $sportspress_options;
|
||||
|
||||
$defaults = array(
|
||||
'id' => get_the_ID(),
|
||||
'number' => -1,
|
||||
'orderby' => 'default',
|
||||
'order' => 'ASC',
|
||||
'itemtag' => 'dl',
|
||||
'icontag' => 'dt',
|
||||
'captiontag' => 'dd',
|
||||
'columns' => 3,
|
||||
'size' => 'thumbnail',
|
||||
'show_all_players_link' => false,
|
||||
'show_names_on_hover' => sportspress_array_value( $sportspress_options, 'player_gallery_show_names_on_hover', true ),
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
|
||||
$itemtag = tag_escape( $itemtag );
|
||||
$captiontag = tag_escape( $captiontag );
|
||||
$icontag = tag_escape( $icontag );
|
||||
$valid_tags = wp_kses_allowed_html( 'post' );
|
||||
if ( ! isset( $valid_tags[ $itemtag ] ) )
|
||||
$itemtag = 'dl';
|
||||
if ( ! isset( $valid_tags[ $captiontag ] ) )
|
||||
$captiontag = 'dd';
|
||||
if ( ! isset( $valid_tags[ $icontag ] ) )
|
||||
$icontag = 'dt';
|
||||
|
||||
$columns = intval( $columns );
|
||||
$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
|
||||
$size = $size;
|
||||
$float = is_rtl() ? 'right' : 'left';
|
||||
|
||||
$selector = 'sp-player-gallery-' . $id;
|
||||
|
||||
$data = sportspress_get_player_list_data( $id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
if ( $orderby == 'default' ):
|
||||
$orderby = get_post_meta( $id, 'sp_orderby', true );
|
||||
$order = get_post_meta( $id, 'sp_order', true );
|
||||
else:
|
||||
global $sportspress_performance_priorities;
|
||||
$sportspress_performance_priorities = array(
|
||||
array(
|
||||
'key' => $orderby,
|
||||
'order' => $order,
|
||||
),
|
||||
);
|
||||
uasort( $data, 'sportspress_sort_list_players' );
|
||||
endif;
|
||||
|
||||
$gallery_style = $gallery_div = '';
|
||||
if ( apply_filters( 'use_default_gallery_style', true ) )
|
||||
$gallery_style = "
|
||||
<style type='text/css'>
|
||||
#{$selector} {
|
||||
margin: auto;
|
||||
}
|
||||
#{$selector} .gallery-item {
|
||||
float: {$float};
|
||||
margin-top: 10px;
|
||||
text-align: center;
|
||||
width: {$itemwidth}%;
|
||||
}
|
||||
#{$selector} img {
|
||||
border: 2px solid #cfcfcf;
|
||||
}
|
||||
#{$selector} .gallery-caption {
|
||||
margin-left: 0;
|
||||
}
|
||||
/* see gallery_shortcode() in wp-includes/media.php */
|
||||
</style>";
|
||||
$size_class = sanitize_html_class( $size );
|
||||
$gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
|
||||
$output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ( is_int( $number ) && $number > 0 )
|
||||
$limit = $number;
|
||||
|
||||
foreach( $data as $player_id => $performance ):
|
||||
|
||||
if ( $show_names_on_hover ):
|
||||
$caption = get_the_title( $player_id );
|
||||
$player_number = get_post_meta( $player_id, 'sp_number', true );
|
||||
if ( $player_number ):
|
||||
$caption = '<strong>' . $player_number . '</strong> ' . $caption;
|
||||
endif;
|
||||
else:
|
||||
$caption = null;
|
||||
endif;
|
||||
|
||||
if ( isset( $limit ) && $i >= $limit )
|
||||
continue;
|
||||
|
||||
if ( has_post_thumbnail( $player_id ) ):
|
||||
$thumbnail = get_the_post_thumbnail( $player_id, $size );
|
||||
|
||||
$output .= "<{$itemtag} class='gallery-item'>";
|
||||
$output .= "
|
||||
<{$icontag} class='gallery-icon portrait'>"
|
||||
. '<a href="' . get_permalink( $player_id ) . '">' . $thumbnail . '</a>'
|
||||
. "</{$icontag}>";
|
||||
if ( $captiontag && trim( $caption ) ) {
|
||||
$output .= '<a href="' . get_permalink( $player_id ) . '">' . "
|
||||
<{$captiontag} class='wp-caption-text gallery-caption'>
|
||||
" . wptexturize($caption) . "
|
||||
</{$captiontag}>" . '</a>';
|
||||
}
|
||||
$output .= "</{$itemtag}>";
|
||||
if ( $columns > 0 && ++$i % $columns == 0 )
|
||||
$output .= '<br style="clear: both" />';
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= "
|
||||
<br style='clear: both;' />
|
||||
</div>\n";
|
||||
|
||||
if ( $show_all_players_link )
|
||||
$output .= '<a class="sp-player-list-link" href="' . get_permalink( $id ) . '">' . __( 'View all players', 'sportspress' ) . '</a>';
|
||||
|
||||
echo apply_filters( 'sportspress_player_gallery', $output );
|
||||
48
templates/player-league-performance.php
Normal file
48
templates/player-league-performance.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
if ( ! isset( $league ) )
|
||||
return false;
|
||||
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$data = sportspress_get_player_performance_data( $id, $league->term_id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
// Skip if there are no rows in the table
|
||||
if ( empty( $data ) )
|
||||
return false;
|
||||
|
||||
$output = '<h4 class="sp-table-caption">' . $league->name . '</h4>' .
|
||||
'<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-player-performance sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $season_id => $row ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>' . '</div>';
|
||||
|
||||
echo apply_filters( 'sportspress_player_league_performance', $output );
|
||||
102
templates/player-list.php
Normal file
102
templates/player-list.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
global $sportspress_options;
|
||||
|
||||
$defaults = array(
|
||||
'id' => get_the_ID(),
|
||||
'number' => -1,
|
||||
'performance' => null,
|
||||
'orderby' => 'default',
|
||||
'order' => 'ASC',
|
||||
'show_all_players_link' => false,
|
||||
'link_posts' => sportspress_array_value( $sportspress_options, 'player_list_link_posts', true ),
|
||||
'sortable' => sportspress_array_value( $sportspress_options, 'player_list_sortable', true ),
|
||||
'responsive' => sportspress_array_value( $sportspress_options, 'player_list_responsive', true ),
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
|
||||
$output = '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-player-list sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . ( $sortable ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
|
||||
|
||||
$data = sportspress_get_player_list_data( $id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
if ( $orderby == 'default' ):
|
||||
$orderby = get_post_meta( $id, 'sp_orderby', true );
|
||||
$order = get_post_meta( $id, 'sp_order', true );
|
||||
else:
|
||||
global $sportspress_performance_priorities;
|
||||
$sportspress_performance_priorities = array(
|
||||
array(
|
||||
'key' => $orderby,
|
||||
'order' => $order,
|
||||
),
|
||||
);
|
||||
uasort( $data, 'sportspress_sort_list_players' );
|
||||
endif;
|
||||
|
||||
if ( in_array( $orderby, array( 'number', 'name' ) ) ):
|
||||
$output .= '<th class="data-number">#</th>';
|
||||
else:
|
||||
$output .= '<th class="data-rank">' . __( 'Rank', 'sportspress' ) . '</th>';
|
||||
endif;
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) )
|
||||
$output .= '<th class="data-' . $key . '">'. $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ( is_int( $number ) && $number > 0 )
|
||||
$limit = $number;
|
||||
|
||||
foreach( $data as $player_id => $row ):
|
||||
if ( isset( $limit ) && $i >= $limit ) continue;
|
||||
|
||||
$name = sportspress_array_value( $row, 'name', null );
|
||||
if ( ! $name ) continue;
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
// Rank or number
|
||||
if ( isset( $orderby ) && $orderby != 'number' ):
|
||||
$output .= '<td class="data-rank">' . ( $i + 1 ) . '</td>';
|
||||
else:
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
$output .= '<td class="data-number">' . ( $number ? $number : ' ' ) . '</td>';
|
||||
endif;
|
||||
|
||||
if ( $link_posts ):
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
endif;
|
||||
|
||||
$output .= '<td class="data-name">' . $name . '</td>';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( ! is_array( $performance ) || in_array( $key, $performance ) )
|
||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>' . '</div>';
|
||||
|
||||
if ( $show_all_players_link )
|
||||
$output .= '<a class="sp-player-list-link" href="' . get_permalink( $id ) . '">' . __( 'View all players', 'sportspress' ) . '</a>';
|
||||
|
||||
echo apply_filters( 'sportspress_player_list', $output );
|
||||
50
templates/player-metrics.php
Normal file
50
templates/player-metrics.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
global $sportspress_countries;
|
||||
|
||||
global $sportspress_options;
|
||||
|
||||
$defaults = array(
|
||||
'show_nationality_flag' => sportspress_array_value( $sportspress_options, 'player_show_nationality_flag', true ),
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
|
||||
$nationality = get_post_meta( $id, 'sp_nationality', true );
|
||||
$current_team = get_post_meta( $id, 'sp_current_team', true );
|
||||
$past_teams = get_post_meta( $id, 'sp_past_team', false );
|
||||
$metrics = sportspress_get_player_metrics_data( $id );
|
||||
|
||||
$common = array();
|
||||
if ( $nationality ):
|
||||
$country_name = sportspress_array_value( $sportspress_countries, $nationality, null );
|
||||
$common[ __( 'Nationality', 'sportspress' ) ] = $country_name ? ( $show_nationality_flag ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . '/assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '—';
|
||||
endif;
|
||||
|
||||
$data = array_merge( $common, $metrics );
|
||||
|
||||
if ( $current_team )
|
||||
$data[ __( 'Current Team', 'sportspress' ) ] = '<a href="' . get_post_permalink( $current_team ) . '">' . get_the_title( $current_team ) . '</a>';
|
||||
|
||||
if ( $past_teams ):
|
||||
$teams = array();
|
||||
foreach ( $past_teams as $team ):
|
||||
$teams[] = '<a href="' . get_post_permalink( $team ) . '">' . get_the_title( $team ) . '</a>';
|
||||
endforeach;
|
||||
$data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
|
||||
endif;
|
||||
|
||||
$output = '<div class="sp-list-wrapper">' .
|
||||
'<dl class="sp-player-metrics">';
|
||||
|
||||
foreach( $data as $label => $value ):
|
||||
|
||||
$output .= '<dt>' . $label . '<dd>' . $value . '</dd>';
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</dl></div>';
|
||||
|
||||
echo apply_filters( 'sportspress_player_metrics', $output );
|
||||
14
templates/player-performance.php
Normal file
14
templates/player-performance.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$leagues = get_the_terms( $id, 'sp_league' );
|
||||
|
||||
// Loop through performance for each league
|
||||
if ( is_array( $leagues ) ):
|
||||
foreach ( $leagues as $league ):
|
||||
sp_get_template( 'player-league-performance.php', array(
|
||||
'league' => $league
|
||||
) );
|
||||
endforeach;
|
||||
endif;
|
||||
97
templates/player-roster.php
Normal file
97
templates/player-roster.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
$defaults = array(
|
||||
'performance' => null,
|
||||
'orderby' => 'default',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
|
||||
$output = '';
|
||||
|
||||
$data = sportspress_get_player_roster_data( $id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
$performance = sportspress_array_value( $r, 'performance', null );
|
||||
|
||||
if ( $r['orderby'] == 'default' ):
|
||||
$r['orderby'] = get_post_meta( $id, 'sp_orderby', true );
|
||||
$r['order'] = get_post_meta( $id, 'sp_order', true );
|
||||
else:
|
||||
global $sportspress_performance_priorities;
|
||||
$sportspress_performance_priorities = array(
|
||||
array(
|
||||
'key' => $r['orderby'],
|
||||
'order' => $r['order'],
|
||||
),
|
||||
);
|
||||
uasort( $data, 'sportspress_sort_list_players' );
|
||||
endif;
|
||||
|
||||
$positions = get_terms ( 'sp_position' );
|
||||
|
||||
foreach ( $positions as $position ):
|
||||
$rows = '';
|
||||
$i = 0;
|
||||
|
||||
foreach ( $data as $player_id => $row ):
|
||||
|
||||
if ( ! in_array( $position->term_id, $row['positions']) )
|
||||
continue;
|
||||
|
||||
$rows .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
// Rank or number
|
||||
if ( isset( $r['orderby'] ) && $r['orderby'] != 'number' ):
|
||||
$rows .= '<td class="data-rank">' . ( $i + 1 ) . '</td>';
|
||||
else:
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
$rows .= '<td class="data-number">' . ( $number ? $number : ' ' ) . '</td>';
|
||||
endif;
|
||||
|
||||
// Name as link
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = sportspress_array_value( $row, 'name', sportspress_array_value( $row, 'name', ' ' ) );
|
||||
$rows .= '<td class="data-name">' . '<a href="' . $permalink . '">' . $name . '</a></td>';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( ! is_array( $performance ) || in_array( $key, $performance ) )
|
||||
$rows .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$rows .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
if ( ! empty( $rows ) ):
|
||||
$output .= '<h4 class="sp-table-caption">' . $position->name . '</h4>';
|
||||
$output .= '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-player-list sp-player-roster sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
if ( in_array( $r['orderby'], array( 'number', 'name' ) ) ):
|
||||
$output .= '<th class="data-number">#</th>';
|
||||
else:
|
||||
$output .= '<th class="data-rank">' . __( 'Rank', 'sportspress' ) . '</th>';
|
||||
endif;
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) )
|
||||
$output .= '<th class="data-' . $key . '">'. $label . '</th>';
|
||||
endforeach;
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>' . $rows . '</tbody>' . '</table>' . '</div>';
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
|
||||
echo apply_filters( 'sportspress_player_roster', $output );
|
||||
57
templates/team-columns.php
Normal file
57
templates/team-columns.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$leagues = get_the_terms( $id, 'sp_league' );
|
||||
|
||||
if ( ! $leagues )
|
||||
return false;
|
||||
|
||||
$output = '';
|
||||
|
||||
// Loop through data for each league
|
||||
foreach ( $leagues as $league ):
|
||||
|
||||
$data = sportspress_get_team_columns_data( $id, $league->term_id );
|
||||
|
||||
if ( sizeof( $data ) <= 1 )
|
||||
continue;
|
||||
|
||||
// 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 .= '<h4 class="sp-table-caption">' . $league->name . '</h4>' .
|
||||
'<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-team-columns sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $season_id => $row ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>' . '</div>';
|
||||
|
||||
|
||||
endforeach;
|
||||
|
||||
echo apply_filters( 'sportspress_team_columns', $output );
|
||||
Reference in New Issue
Block a user