Add events list template
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_events_calendar' ) ) {
|
||||
function sportspress_events_calendar( $initial = true ) {
|
||||
function sportspress_events_calendar( $id = null, $single = false, $initial = true ) {
|
||||
|
||||
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
|
||||
|
||||
@@ -8,6 +8,8 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) {
|
||||
if ( !$posts )
|
||||
return;
|
||||
|
||||
$caption_tag = ( $single ? 'h4' : 'caption' );
|
||||
|
||||
// week_begins = 0 stands for Sunday
|
||||
$week_begins = intval(get_option('start_of_week'));
|
||||
|
||||
@@ -56,7 +58,7 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) {
|
||||
$calendar_caption = _x('%1$s %2$s', 'calendar caption', 'sportspress');
|
||||
$calendar_output = '
|
||||
<table id="wp-calendar">
|
||||
<caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
|
||||
<' . $caption_tag . ' class="sp-table-caption">' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</' . $caption_tag . '>
|
||||
<thead>
|
||||
<tr>';
|
||||
|
||||
|
||||
121
admin/templates/events-list.php
Normal file
121
admin/templates/events-list.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_events_list' ) ) {
|
||||
function sportspress_events_list( $id = null, $args = '' ) {
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
$options = get_option( 'sportspress' );
|
||||
$main_result = sportspress_array_value( $options, 'main_result', null );
|
||||
|
||||
$defaults = array(
|
||||
);
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
|
||||
$output = '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-events-list sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
|
||||
list( $data, $usecolumns ) = sportspress_get_calendar_data( $id, true );
|
||||
|
||||
$output .= '<th class="column-date">' . __( 'Date', 'sportspress' ). '</th>';
|
||||
|
||||
if ( in_array( 'event', $usecolumns ) )
|
||||
$output .= '<th class="column-event">' . __( 'Event', 'sportspress' ). '</th>';
|
||||
|
||||
if ( in_array( 'teams', $usecolumns ) )
|
||||
$output .= '<th class="column-teams">' . __( 'Teams', 'sportspress' ). '</th>';
|
||||
|
||||
if ( in_array( 'time', $usecolumns ) )
|
||||
$output .= '<th class="column-time">' . __( 'Time', 'sportspress' ). '</th>';
|
||||
|
||||
if ( 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 ( in_array( 'event', $usecolumns ) )
|
||||
$output .= '<td class="column-event">' . $event->post_title . '</td>';
|
||||
|
||||
if ( 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 ( in_array( 'time', $usecolumns ) )
|
||||
$output .= '<td class="column-time">' . get_post_time( get_option( 'time_format' ), false, $event ) . '</td>';
|
||||
|
||||
if ( 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>' . '</div>';
|
||||
|
||||
return apply_filters( 'sportspress_events_list', $output );
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user