File: /var/www/html/shootinschool/wp-content/themes/shootinschool/sportspress/event-list.php
<?php
/**
* Event List
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 2.6
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/*Default template or sportpress */
$event_list_template = get_theme_mod('event_list_template', 'theme');
$defaults = array(
'id' => null,
'title' => false,
'status' => 'default',
'date' => 'default',
'date_from' => 'default',
'date_to' => 'default',
'date_past' => 'default',
'date_future' => 'default',
'date_relative' => 'default',
'day' => 'default',
'league' => null,
'season' => null,
'venue' => null,
'team' => null,
'player' => null,
'number' => -1,
'show_team_logo' => get_option( 'sportspress_event_list_show_logos', 'no' ) == 'yes' ? true : false,
'link_events' => get_option( 'sportspress_link_events', 'yes' ) == 'yes' ? true : false,
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
'link_venues' => get_option( 'sportspress_link_venues', 'yes' ) == 'yes' ? true : false,
'abbreviate_teams' => get_option( 'sportspress_abbreviate_teams', 'yes' ) === 'yes' ? true : false,
'responsive' => get_option( 'sportspress_enable_responsive_tables', 'no' ) == 'yes' ? true : false,
'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false,
'scrollable' => get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false,
'paginated' => get_option( 'sportspress_event_list_paginated', 'yes' ) == 'yes' ? true : false,
'rows' => get_option( 'sportspress_event_list_rows', 10 ),
'order' => 'default',
'columns' => null,
'show_all_events_link' => false,
'show_title' => get_option( 'sportspress_event_list_show_title', 'yes' ) == 'yes' ? true : false,
'title_format' => get_option( 'sportspress_event_list_title_format', 'title' ),
'time_format' => get_option( 'sportspress_event_list_time_format', 'combined' ),
);
extract( $defaults, EXTR_SKIP );
$calendar = new SP_Calendar( $id );
if ( $status != 'default' )
$calendar->status = $status;
if ( $date != 'default' )
$calendar->date = $date;
if ( $date_from != 'default' )
$calendar->from = $date_from;
if ( $date_to != 'default' )
$calendar->to = $date_to;
if ( $date_past != 'default' )
$calendar->past = $date_past;
if ( $date_future != 'default' )
$calendar->future = $date_future;
if ( $date_relative != 'default' )
$calendar->relative = $date_relative;
if ( $league )
$calendar->league = $league;
if ( $number )
$calendar->number = $number;
if ( $season )
$calendar->season = $season;
if ( $venue )
$calendar->venue = $venue;
if ( $team )
$calendar->team = $team;
if ( $player )
$calendar->player = $player;
if ( $order != 'default' )
$calendar->order = $order;
if ( $day != 'default' )
$calendar->day = $day;
$data = $calendar->data();
$usecolumns = $calendar->columns;
if ( isset( $columns ) ):
if ( is_array( $columns ) )
$usecolumns = $columns;
else
$usecolumns = explode( ',', $columns );
endif;
if ( $show_title && false === $title && $id ):
$caption = $calendar->caption;
if ( $caption )
$title = $caption;
else
$title = get_the_title( $id );
endif;
$bsbNormalClass = (is_layout('baseball')) ? "normal_font" : "";
?>
<?php if($event_list_template == 'theme') { ?>
<div class="stm-upcoming-events_list">
<?php if(is_layout("bb") || is_layout("magazine_one")) : ?>
<ul>
<?php foreach ( $data as $event ){ ?>
<?php
$teams = get_post_meta( $event->ID, 'sp_team' );
$results = get_post_meta( $event->ID, 'sp_results', true );
$result = '';
$i = 0;
if($results){
foreach($results as $val){ $i++;
if ($i == 1) {
if ($val[splash_get_sportpress_points_system()] != '') {
$result .= $val[splash_get_sportpress_points_system()] . ' / ';
}
} else {
if ($val[splash_get_sportpress_points_system()] == '') {
$result .= '';
} else {
$result .= $val[splash_get_sportpress_points_system()];
}
}
}
}
if(empty($result)) {
$result = esc_html__('- vs -','splash');
}
$teams_output = '';
$teams_array = '';
?>
<li class="clearfix">
<div class="event_date heading-font">
<div class="date">
<div class="stm-top">
<span><?php echo get_post_time( 'j', false, $event, true ); ?></span><figure>/</figure><?php echo get_post_time( 'm', false, $event, true ); ?>
</div>
<div class="stm-middle"><?php echo get_post_time( 'l', false, $event, true ); ?></div>
<div class="stm-bottom"><?php echo get_post_time( 'h:i A', false, $event, true ); ?></div>
</div>
</div>
<div class="clearfix">
<div class="commands">
<?php if($teams){ ?>
<h3><a href="<?php echo esc_url(get_the_permalink($teams[0])); ?>"><?php echo get_the_title($teams[0]); ?></a> <span class="stm-red"><?php echo wp_kses_post( $result ); ?></span> <a href="<?php echo esc_url(get_the_permalink($teams[1])); ?>"><?php echo esc_html( get_the_title($teams[1]) ); ?></a></h3>
<?php } ?>
<?php
$venues = get_the_terms( $event->ID, 'sp_venue' );
if ( $venues ){
foreach ( $venues as $venue ) {
echo '<div class="stadium"><i class="stm-icon-pin"></i> ' . $venue->name . '</div>';
}
}
?>
<?php
$leagues = get_the_terms( $event->ID, 'sp_league' );
if ( $leagues ){
foreach ( $leagues as $league ) {
echo '<div class="league"><i class="stm-icon-trophy"></i> ' . $league->name . '</div>';
}
}
?>
</div>
<div class="read_more">
<a class="button btn-secondary" href="<?php echo esc_url( get_post_permalink( $event->ID, false, true ) ); ?>"><span><?php esc_html_e('read more', 'splash'); ?></span></a>
</div>
</div>
</li>
<?php } ?>
</ul>
<?php elseif(is_layout("af") || is_layout('baseball')): /*========================================================== AMERICAN FOOTBALL or BASEBALL ========================================================= */ ?>
<div class="stm-af-template stm-af-template-event-list">
<?php if ( $title ) { ?>
<h4 class="sp-table-caption"><?php echo sanitize_text_field($title); ?></h4>
<?php } ?>
<div class="sp-table-wrapper">
<div class="stm-ipad-block">
<table class="sp-event-list sp-data-table<?php if ( $paginated ) { ?> sp-paginated-table<?php } if ( $sortable ) { ?> sp-sortable-table<?php } if ( $scrollable ) { ?> sp-scrollable-table<?php } ?>" data-sp-rows="<?php echo esc_attr($rows); ?>">
<thead>
<tr>
<?php
echo '<th class="data-date">' . esc_html__( 'Date', 'splash' ) . '</th>';
switch ( $title_format ) {
case 'homeaway':
if ( sp_column_active( $usecolumns, 'event' ) ) {
echo '<th class="data-home">' . esc_html__( 'Home', 'splash' ) . '</th>';
if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) {
echo '<th class="data-time">' . esc_html__( 'Time/Results', 'splash' ) . '</th>';
} elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) {
echo '<th class="data-results">' . esc_html__( 'Results', 'splash' ) . '</th>';
}
echo '<th class="data-away">' . esc_html__( 'Away', 'splash' ) . '</th>';
if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) {
echo '<th class="data-time">' . esc_html__( 'Time', 'splash' ) . '</th>';
}
}
break;
default:
if ( sp_column_active( $usecolumns, 'event' ) ) {
if ( $title_format == 'teams' )
echo '<th class="data-teams">' . esc_html__( 'Teams', 'splash' ) . '</th>';
else
echo '<th class="data-event">' . esc_html__( 'Event', 'splash' ) . '</th>';
}
switch ( $time_format ) {
case 'separate':
if ( sp_column_active( $usecolumns, 'time' ) )
echo '<th class="data-time">' . esc_html__( 'Time', 'splash' ) . '</th>';
if ( sp_column_active( $usecolumns, 'results' ) )
echo '<th class="data-results">' . esc_html__( 'Results', 'splash' ) . '</th>';
break;
case 'time':
if ( sp_column_active( $usecolumns, 'time' ) )
echo '<th class="data-time">' . esc_html__( 'Time', 'splash' ) . '</th>';
break;
case 'results':
if ( sp_column_active( $usecolumns, 'results' ) )
echo '<th class="data-results">' . esc_html__( 'Results', 'splash' ) . '</th>';
break;
default:
if ( sp_column_active( $usecolumns, 'time' ) )
echo '<th class="data-time">' . esc_html__( 'Time/Results', 'splash' ) . '</th>';
}
}
if ( sp_column_active( $usecolumns, 'league' ) )
echo '<th class="data-league">' . esc_html__( 'Competition', 'splash' ) . '</th>';
if ( sp_column_active( $usecolumns, 'season' ) )
echo '<th class="data-season">' . esc_html__( 'Season', 'splash' ) . '</th>';
if ( sp_column_active( $usecolumns, 'venue' ) )
echo '<th class="data-venue">' . esc_html__( 'Venue', 'splash' ) . '</th>';
if ( sp_column_active( $usecolumns, 'article' ) )
echo '<th class="data-article">' . esc_html__( 'Article', 'splash' ) . '</th>';
?>
</tr>
</thead>
<tbody>
<?php
$i = 0;
if ( is_numeric( $number ) && $number > 0 )
$limit = $number;
foreach ( $data as $event ):
if ( isset( $limit ) && $i >= $limit ) continue;
$teams = get_post_meta( $event->ID, 'sp_team' );
$video = get_post_meta( $event->ID, 'sp_video', true );
$main_results = apply_filters( 'sportspress_event_list_main_results', sp_get_main_results( $event ), $event->ID );
$teams_output = '';
$teams_array = array();
$team_logos = array();
if ( $teams ):
foreach ( $teams as $team ):
$name = sp_get_team_name( $team, $abbreviate_teams );
if ( $name ):
if ( $show_team_logo ):
$name = sp_get_logo( $team, 'mini' ) . ' ' . $name;
$team_logos[] = sp_get_logo( $team, 'full' );
endif;
if ( $link_teams ):
$team_output = '<a href="' . get_post_permalink( $team ) . '">' . $name . '</a>';
else:
$team_output = $name;
endif;
$team_result = sp_array_value( $main_results, $team, null );
if ( $team_result != null ):
if ( $usecolumns != null && ! in_array( 'time', $usecolumns ) ):
$team_output .= ' (' . $team_result . ')';
endif;
endif;
$teams_array[] = $team_output;
$teams_output .= $team_output . '<br>';
endif;
endforeach;
else:
$teams_output .= '—';
endif;
echo '<tr class="sp-row sp-post' . ( $i % 2 == 0 ? ' alternate' : '' ) . ' sp-row-no-' . $i . '">';
echo "<td class='data-date'>
<div class='stm-date-event-wrapp'>
<div class='stm-top heading-font'>
<span>" . get_post_time( 'j', false, $event, true ) . "</span>
</div>
<div class='stm-middle normal_font'>" . get_post_time( 'M', false, $event, true ) . "</div>
</div>
</td>";
switch ( $title_format ) {
case 'homeaway':
if ( sp_column_active( $usecolumns, 'event' ) ) {
$team = array_shift( $teams_array );
echo '<td class="data-home">' . $team . '</td>';
if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time">';
if ( $link_events ) echo '<a class="' . $bsbNormalClass . '" href="' . get_post_permalink( $event->ID, false, true ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
endif;
if ( $link_events ) echo '</a>';
echo '</td>';
} elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) {
echo '<td class="data-results">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo '-';
endif;
if ( $link_events ) echo '</a>';
echo '</td>';
}
$team = array_shift( $teams_array );
echo '<td class="data-away">' . $team . '</td>';
if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time">';
if ( $link_events ) echo '<a class="' . $bsbNormalClass . '" href="' . get_post_permalink( $event->ID, false, true ) . '">';
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
if ( $link_events ) echo '</a>';
echo '</td>';
}
}
break;
default:
if ( sp_column_active( $usecolumns, 'event' ) ) {
if ( $title_format == 'teams' ) {
echo '<td class="data-event data-teams">' . $teams_output . '</td>';
} else {
$title_html = implode( ' ', $team_logos ) . ' ' . $event->post_title;
//echo implode( ' - ', $main_results );
if ( $link_events ) $title_html = '<a href="' . get_post_permalink( $event->ID, false, true ) . '">' . str_replace(" vs ", "<span> -vs- </span>", $title_html) . '</a>';
echo '<td class="data-event heading-font">' . $title_html . '</td>';
}
}
switch ( $time_format ) {
case 'separate':
if ( sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time">';
if ( $link_events ) echo '<a class="' . $bsbNormalClass . '" href="' . get_post_permalink( $event->ID, false, true ) . '">';
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
if ( $link_events ) echo '</a>';
echo '</td>';
}
if ( sp_column_active( $usecolumns, 'results' ) ) {
echo '<td class="data-results">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' ', $main_results );
else:
echo '-';
endif;
if ( $link_events ) echo '</a>';
echo '</td>';
}
break;
case 'time':
if ( sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time">';
if ( $link_events ) echo '<a class="' . $bsbNormalClass . '" href="' . get_post_permalink( $event->ID, false, true ) . '">';
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
if ( $link_events ) echo '</a>';
echo '</td>';
}
break;
case 'results':
if ( sp_column_active( $usecolumns, 'results' ) ) {
echo '<td class="data-results">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo '-';
endif;
if ( $link_events ) echo '</a>';
echo '</td>';
}
break;
default:
if ( sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time">';
if ( $link_events ) echo '<a class="' . $bsbNormalClass . '" href="' . get_post_permalink( $event->ID, false, true ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' / ', $main_results );
else:
echo '<date> ' . get_post_time( 'H:i:s T', false, $event ) . '</date>' . sp_get_time( $event );
endif;
if ( $link_events ) echo '</a>';
echo '</td>';
}
}
}
if ( sp_column_active( $usecolumns, 'league' ) ):
echo '<td class="data-league">';
$leagues = get_the_terms( $event->ID, 'sp_league' );
if ( $leagues ): foreach ( $leagues as $league ):
echo esc_attr($league->name);
endforeach; endif;
echo '</td>';
endif;
if ( sp_column_active( $usecolumns, 'season' ) ):
echo '<td class="data-season">';
$seasons = get_the_terms( $event->ID, 'sp_season' );
if ( $seasons ): foreach ( $seasons as $season ):
echo esc_attr($season->name);
endforeach; endif;
echo '</td>';
endif;
if ( sp_column_active( $usecolumns, 'venue' ) ):
echo '<td class="data-venue">';
if ( $link_venues ):
the_terms( $event->ID, 'sp_venue' );
else:
$venues = get_the_terms( $event->ID, 'sp_venue' );
if ( $venues ): foreach ( $venues as $venue ):
echo esc_attr($venue->name);
endforeach; endif;
endif;
echo '</td>';
endif;
if ( sp_column_active( $usecolumns, 'article' ) ):
$classArticle = (is_layout('baseball')) ? 'normal_font' : 'heading-font';
echo '<td class="data-article ' . $classArticle . '">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
if ( $event->post_content !== null ):
if ( $event->post_status == 'publish' ):
esc_html_e( 'Recap', 'splash' );
else:
esc_html_e( 'Preview', 'splash' );
endif;
endif;
echo '<i class="fa fa-arrow-right" aria-hidden="true"></i>';
if ( $link_events ) echo '</a>';
echo '</td>';
endif;
echo '</tr>';
$i++;
endforeach;
?>
</tbody>
</table>
</div>
<div class="stm-ipad-none">
<ul>
<?php foreach ( $data as $event ){ ?>
<?php
$teams = get_post_meta( $event->ID, 'sp_team' );
$results = get_post_meta( $event->ID, 'sp_results', true );
$result = '';
$i = 0;
if($results){
foreach($results as $val){ $i++;
if($i == 1){
if($val[splash_get_sportpress_points_system()] != ''){
$result .= $val[splash_get_sportpress_points_system()].' / ';
}
}else{
if($val[splash_get_sportpress_points_system()] == '') {
$result .= '';
}else{
$result .= $val[splash_get_sportpress_points_system()];
}
}
}
}
if(empty($result)) {
$result = esc_html__('- vs -','splash');
}
$teams_output = '';
$teams_array = '';
?>
<li class="clearfix">
<div class="event_date heading-font">
<div class="date">
<div class="stm-top">
<span><?php echo get_post_time( 'j', false, $event, true ); ?></span><figure>/</figure><?php echo get_post_time( 'm', false, $event, true ); ?>
</div>
<div class="stm-middle"><?php echo get_post_time( 'l', false, $event, true ); ?></div>
<div class="stm-bottom"><?php echo get_post_time( 'h:i A', false, $event, true ); ?></div>
</div>
</div>
<div class="clearfix">
<div class="commands">
<?php if($teams){ ?>
<h3><a href="<?php echo esc_url(get_the_permalink($teams[0])); ?>"><?php echo get_the_title($teams[0]); ?></a> <span class="stm-red"><?php echo wp_kses_post( $result ); ?></span> <a href="<?php echo esc_url(get_the_permalink($teams[1])); ?>"><?php echo esc_html( get_the_title($teams[1]) ); ?></a></h3>
<?php } ?>
<?php
$venues = get_the_terms( $event->ID, 'sp_venue' );
if ( $venues ){
foreach ( $venues as $venue ) {
echo '<div class="stadium"><i class="stm-icon-pin"></i> ' . $venue->name . '</div>';
}
}
?>
<?php
$leagues = get_the_terms( $event->ID, 'sp_league' );
if ( $leagues ){
foreach ( $leagues as $league ) {
echo '<div class="league"><i class="stm-icon-trophy"></i> ' . $league->name . '</div>';
}
}
?>
</div>
<div class="read_more">
<a class="button btn-secondary" href="<?php echo esc_url( get_post_permalink( $event->ID, false, true ) ); ?>"><span><?php esc_html_e('read more', 'splash'); ?></span></a>
</div>
</div>
</li>
<?php } ?>
</ul>
</div>
</div>
<?php
if ( $id && $show_all_events_link )
echo '<div class="sp-calendar-link sp-view-all-link heading-font"><a href="' . get_permalink( $id ) . '">' . esc_html__( 'View all events', 'splash' ) . '</a></div>';
?>
</div>
<?php
elseif(is_layout("sccr")): /*======================= SOCCER ======================== */ ?>
<div class="stm-sccr-template stm-sccr-template-event-list">
<?php if ( $title ) { ?>
<h4 class="sp-table-caption"><?php echo sanitize_text_field($title); ?></h4>
<?php } ?>
<div class="sp-table-wrapper">
<ul>
<?php foreach ( $data as $event ){ ?>
<?php
$teams = get_post_meta( $event->ID, 'sp_team' );
$results = get_post_meta( $event->ID, 'sp_results', true );
$result = '';
$i = 0;
if($results){
foreach($results as $val){ $i++;
if($i == 1){
if($val[splash_get_sportpress_points_system()] != ''){
$result .= $val[splash_get_sportpress_points_system()].' / ';
}
}else{
if($val[splash_get_sportpress_points_system()] == '') {
$result .= '';
}else{
$result .= $val[splash_get_sportpress_points_system()];
}
}
}
}
$teams_output = '';
$teams_array = '';
?>
<li class="clearfix">
<div class="event_date">
<div class="date">
<div class="stm-top">
<span class="date-day-num heading-font"><?php echo get_post_time( 'j', false, $event, true ); ?></span>
<span class="date-month normal_font"><?php echo get_post_time( 'F', false, $event, true ); ?></span>
</div>
</div>
</div>
<div class="clearfix">
<div class="stm-event-data-wrap">
<div class="commands">
<?php if($teams){ ?>
<h3>
<a href="<?php echo esc_url(get_the_permalink($teams[0])); ?>">
<?php echo get_the_title($teams[0]); ?>
</a>
<span class="event-vs">vs</span>
<span class="event-vs-mobile" style="display: none;"><?php echo ($result != "") ? wp_kses_post( $result ) : "vs"; ?></span>
<a href="<?php echo esc_url(get_the_permalink($teams[1])); ?>">
<?php echo esc_html( get_the_title($teams[1]) ); ?>
</a>
</h3>
<?php } ?>
<div class="stm-event-bottom-info">
<div class="date-time">
<i class="fa fa-clock-o" aria-hidden="true"></i>
<span class="mobile-hide"><?php echo get_post_time( 'h:i A', false, $event, true ); ?></span>
<span class="mobile-show" style="display: none;"><?php echo get_post_time( 'j F, h:i A', false, $event, true ); ?></span>
</div>
<?php
$venues = get_the_terms( $event->ID, 'sp_venue' );
if ( $venues ){
foreach ( $venues as $venue ) {
echo '<div class="stadium"><i class="fa fa-location-arrow"></i> ' . $venue->name . '</div>';
}
}
?>
</div>
</div>
<div class="stm-event-result">
<?php echo wp_kses_post( $result ); ?>
</div>
<div class="read_more">
<a class="button button-gray btn-only-border" href="<?php echo esc_url( get_post_permalink( $event->ID, false, true ) ); ?>">
<span><?php echo (empty($result)) ? esc_html__('PREVIEW', 'splash') : esc_html__('RECAP', 'splash'); ?></span>
</a>
</div>
</div>
</div>
</li>
<?php } ?>
</ul>
</div>
<?php
if ( $id && $show_all_events_link )
echo '<div class="sp-calendar-link sp-view-all-link heading-font"><a href="' . get_permalink( $id ) . '">' . esc_html__( 'View all events', 'splash' ) . '</a></div>';
?>
</div>
<?php endif; ?>
</div>
<?php } else { ?>
<div class="sp-template sp-template-event-list">
<?php if ( $title ) { ?>
<h4 class="sp-table-caption"><?php echo sanitize_text_field($title); ?></h4>
<?php } ?>
<div class="sp-table-wrapper">
<table class="sp-event-list sp-event-list-format-<?php echo $title_format; ?> sp-data-table<?php if ( $paginated ) { ?> sp-paginated-table<?php } if ( $sortable ) { ?> sp-sortable-table<?php } if ( $scrollable ) { ?> sp-scrollable-table<?php } ?>" data-sp-rows="<?php echo esc_attr($rows); ?>">
<thead>
<tr>
<?php
echo '<th class="data-date">' . esc_html__( 'Date', 'splash' ) . '</th>';
switch ( $title_format ) {
case 'homeaway':
if ( sp_column_active( $usecolumns, 'event' ) ) {
echo '<th class="data-home">' . esc_html__('Home', 'splash') . '</th>';
}
if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) {
echo '<th class="data-time">' . esc_html__( 'Time/Results', 'splash' ) . '</th>';
} elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) {
echo '<th class="data-results">' . esc_html__( 'Results', 'splash' ) . '</th>';
}
if ( sp_column_active( $usecolumns, 'event' ) ) {
echo '<th class="data-away">' . esc_html__('Away', 'splash') . '</th>';
}
if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) {
echo '<th class="data-time">' . esc_html__( 'Time', 'splash' ) . '</th>';
}
break;
default:
if ( sp_column_active( $usecolumns, 'event' ) ) {
if ( $title_format == 'teams' )
echo '<th class="data-teams">' . esc_html__( 'Teams', 'splash' ) . '</th>';
else
echo '<th class="data-event">' . esc_html__( 'Event', 'splash' ) . '</th>';
}
switch ( $time_format ) {
case 'separate':
if ( sp_column_active( $usecolumns, 'time' ) )
echo '<th class="data-time">' . esc_html__( 'Time', 'splash' ) . '</th>';
if ( sp_column_active( $usecolumns, 'results' ) )
echo '<th class="data-results">' . esc_html__( 'Results', 'splash' ) . '</th>';
break;
case 'time':
if ( sp_column_active( $usecolumns, 'time' ) )
echo '<th class="data-time">' . esc_html__( 'Time', 'splash' ) . '</th>';
break;
case 'results':
if ( sp_column_active( $usecolumns, 'results' ) )
echo '<th class="data-results">' . esc_html__( 'Results', 'splash' ) . '</th>';
break;
default:
if ( sp_column_active( $usecolumns, 'time' ) )
echo '<th class="data-time">' . esc_html__( 'Time/Results', 'splash' ) . '</th>';
}
}
if ( sp_column_active( $usecolumns, 'league' ) )
echo '<th class="data-league">' . esc_html__( 'Competition', 'splash' ) . '</th>';
if ( sp_column_active( $usecolumns, 'season' ) )
echo '<th class="data-season">' . esc_html__( 'Season', 'splash' ) . '</th>';
if ( sp_column_active( $usecolumns, 'venue' ) )
echo '<th class="data-venue">' . esc_html__( 'Venue', 'splash' ) . '</th>';
if ( sp_column_active( $usecolumns, 'article' ) )
echo '<th class="data-article">' . esc_html__( 'Article', 'splash' ) . '</th>';
if ( sp_column_active( $usecolumns, 'day' ) )
echo '<th class="data-day">' . __( 'Match Day', 'splash' ) . '</th>';
?>
</tr>
</thead>
<tbody>
<?php
$i = 0;
if ( is_numeric( $number ) && $number > 0 )
$limit = $number;
foreach ( $data as $event ):
if ( isset( $limit ) && $i >= $limit ) continue;
$teams = get_post_meta( $event->ID, 'sp_team' );
$video = get_post_meta( $event->ID, 'sp_video', true );
$main_results = apply_filters( 'sportspress_event_list_main_results', sp_get_main_results( $event ), $event->ID );
$teams_output = '';
$teams_array = array();
$team_logos = array();
$team_class = "";
if ( $teams ):
foreach ( $teams as $t => $team ):
$name = sp_get_team_name( $team, $abbreviate_teams );
if ( $name ):
if ( $show_team_logo ):
if ( has_post_thumbnail( $team ) ):
$logo = '<span class="team-logo">' . sp_get_logo( $team, 'mini' ) . '</span>';
$team_logos[] = $logo;
$team_class .= ' has-logo';
if ( $t ):
$name = $logo . ' ' . $name;
else:
$name .= ' ' . $logo;
endif;
endif;
endif;
if ( $link_teams ):
$team_output = '<a href="' . get_post_permalink( $team ) . '">' . $name . '</a>';
else:
$team_output = $name;
endif;
$team_result = sp_array_value( $main_results, $team, null );
if ( $team_result != null ):
if ( $usecolumns != null && ! in_array( 'time', $usecolumns ) ):
$team_output .= ' (' . $team_result . ')';
endif;
endif;
$teams_array[] = $team_output;
$teams_output .= $team_output . '<br>';
endif;
endforeach;
else:
$teams_output .= '—';
endif;
echo '<tr class="sp-row sp-post' . ( $i % 2 == 0 ? ' alternate' : '' ) . ' sp-row-no-' . $i . '">';
$date_html = '<date>' . get_post_time( 'Y-m-d H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_date', get_post_time( get_option( 'date_format' ), false, $event, true ), $event->ID );
if ( $link_events ) $date_html = '<a href="' . get_post_permalink( $event->ID, false, true ) . '">' . $date_html . '</a>';
echo '<td class="data-date" itemprop="startDate" content="' . mysql2date( 'Y-m-d\TH:iP', $event->post_date ) . '" data-label="'.__( 'Date', 'sportspress' ).'">' . $date_html . '</td>';
switch ( $title_format ) {
case 'homeaway':
if ( sp_column_active( $usecolumns, 'event' ) ) {
$team = array_shift($teams_array);
echo '<td class="data-home' . $team_class . '" itemprop="competitor" itemscope itemtype="http://schema.org/SportsTeam" data-label="'.__( 'Home', 'sportspress' ).'">' . $team . '</td>';
}
if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time" data-label="'.__( 'Time/Results', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID );
endif;
if ( $link_events ) echo '</a>';
echo '</td>';
} elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) {
echo '<td class="data-results" data-label="'.__( 'Results', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo '-';
endif;
if ( $link_events ) echo '</a>';
echo '</td>';
}
if ( sp_column_active( $usecolumns, 'event' ) ) {
$team = array_shift( $teams_array );
echo '<td class="data-away' . $team_class . '" itemprop="competitor" itemscope itemtype="http://schema.org/SportsTeam" data-label="'.__( 'Away', 'sportspress' ).'">' . $team . '</td>';
}
if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time" data-label="'.__( 'Time', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
if ( $link_events ) echo '</a>';
echo '</td>';
}
break;
default:
if ( sp_column_active( $usecolumns, 'event' ) ) {
if ( $title_format == 'teams' ) {
echo '<td class="data-event data-teams" data-label="'.__( 'Teams', 'sportspress' ).'">' . $teams_output . '</td>';
} else {
$title_html = implode( ' ', $team_logos ) . ' ' . $event->post_title;
if ( $link_events ) $title_html = '<a href="' . get_post_permalink( $event->ID, false, true ) . '">' . $title_html . '</a>';
echo '<td class="data-event heading-font" data-label="'.__( 'Event', 'sportspress' ).'">' . $title_html . '</td>';
}
}
switch ( $time_format ) {
case 'separate':
if ( sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time" data-label="'.__( 'Time', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID );
if ( $link_events ) echo '</a>';
echo '</td>';
}
if ( sp_column_active( $usecolumns, 'results' ) ) {
echo '<td class="data-results" data-label="'.__( 'Results', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' ', $main_results );
else:
echo '-';
endif;
if ( $link_events ) echo '</a>';
echo '</td>';
}
break;
case 'time':
if ( sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time" data-label="'.__( 'Time', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID );
if ( $link_events ) echo '</a>';
echo '</td>';
}
break;
case 'results':
if ( sp_column_active( $usecolumns, 'results' ) ) {
echo '<td class="data-results" data-label="'.__( 'Results', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo '-';
endif;
if ( $link_events ) echo '</a>';
echo '</td>';
}
break;
default:
if ( sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time" data-label="'.__( 'Time/Results', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo '<date> ' . get_post_time( 'H:i:s', false, $event ) . '</date>' . apply_filters( 'sportspress_event_time', sp_get_time( $event ), $event->ID );
endif;
if ( $link_events ) echo '</a>';
echo '</td>';
}
}
}
if ( sp_column_active( $usecolumns, 'league' ) ):
echo '<td class="data-league" data-label="'.__( 'League', 'sportspress' ).'">';
$leagues = get_the_terms( $event->ID, 'sp_league' );
if ( $leagues ): foreach ( $leagues as $league ):
echo esc_attr($league->name);
endforeach; endif;
echo '</td>';
endif;
if ( sp_column_active( $usecolumns, 'season' ) ):
echo '<td class="data-season" data-label="'.__( 'Season', 'sportspress' ).'">';
$seasons = get_the_terms( $event->ID, 'sp_season' );
if ( $seasons ): foreach ( $seasons as $season ):
echo esc_attr($season->name);
endforeach; endif;
echo '</td>';
endif;
if ( sp_column_active( $usecolumns, 'venue' ) ):
echo '<td class="data-venue" data-label="'.__( 'Venue', 'sportspress' ).'">';
if ( $link_venues ):
the_terms( $event->ID, 'sp_venue' );
else:
$venues = get_the_terms( $event->ID, 'sp_venue' );
if ( $venues ): foreach ( $venues as $venue ):
echo esc_attr($venue->name);
endforeach; endif;
endif;
echo '</td>';
endif;
if ( sp_column_active( $usecolumns, 'article' ) ):
$classArticle = (is_layout('baseball')) ? 'normal_font' : 'heading-font';
echo '<td class="data-article ' . $classArticle . '" data-label="'.__( 'Article', 'sportspress' ).'">';
if ( $link_events ) echo '<a href="' . get_post_permalink( $event->ID, false, true ) . '">';
if ( $video ):
echo '<div class="dashicons dashicons-video-alt"></div>';
elseif ( has_post_thumbnail( $event->ID ) ):
echo '<div class="dashicons dashicons-camera"></div>';
endif;
if ( $event->post_content !== null ):
if ( $event->post_status == 'publish' ):
esc_html_e( 'Recap', 'splash' );
else:
esc_html_e( 'Preview', 'splash' );
endif;
endif;
if ( $link_events ) echo '</a>';
echo '</td>';
endif;
if ( sp_column_active( $usecolumns, 'day' ) ):
echo '<td class="data-day" data-label="'.__( 'Match Day', 'sportspress' ).'">';
$day = get_post_meta( $event->ID, 'sp_day', true );
if ( '' == $day ) {
echo '-';
} else {
echo $day;
}
echo '</td>';
endif;
do_action( 'sportspress_event_list_row', $event, $usecolumns );
echo '</tr>';
$i++;
endforeach;
?>
</tbody>
</table>
</div>
<?php
if ( $id && $show_all_events_link )
echo '<div class="sp-calendar-link sp-view-all-link heading-font"><a href="' . get_permalink( $id ) . '">' . esc_html__( 'View all events', 'splash' ) . '</a></div>';
?>
</div>
<?php }