Consistently use event prefix for calendar and list templates
Retain backwards compatibility
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_events_calendar' ) ) {
|
||||
function sportspress_events_calendar( $id = null, $initial = true, $args = array() ) {
|
||||
if ( !function_exists( 'sportspress_event_calendar' ) ) {
|
||||
function sportspress_event_calendar( $id = null, $initial = true, $args = array() ) {
|
||||
|
||||
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
|
||||
|
||||
@@ -78,7 +78,7 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) {
|
||||
$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-events-calendar">
|
||||
<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>';
|
||||
@@ -200,12 +200,12 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) {
|
||||
if ( $id && $r['show_all_events_link'] )
|
||||
$calendar_output .= '<a class="sp-calendar-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
|
||||
|
||||
return apply_filters( 'sportspress_events_calendar', $calendar_output );
|
||||
return apply_filters( 'sportspress_event_calendar', $calendar_output );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function sportspress_events_calendar_shortcode( $atts ) {
|
||||
function sportspress_event_calendar_shortcode( $atts ) {
|
||||
if ( isset( $atts['id'] ) ):
|
||||
$id = $atts['id'];
|
||||
unset( $atts['id'] );
|
||||
@@ -216,6 +216,7 @@ function sportspress_events_calendar_shortcode( $atts ) {
|
||||
$id = null;
|
||||
endif;
|
||||
$initial = isset( $atts['initial'] ) ? $atts['initial'] : true;
|
||||
return sportspress_events_calendar( $id, $initial, $atts );
|
||||
return sportspress_event_calendar( $id, $initial, $atts );
|
||||
}
|
||||
add_shortcode('events-calendar', 'sportspress_events_calendar_shortcode');
|
||||
add_shortcode('event-calendar', 'sportspress_event_calendar_shortcode');
|
||||
add_shortcode('events-calendar', 'sportspress_event_calendar_shortcode');
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_events_list' ) ) {
|
||||
function sportspress_events_list( $id = null, $args = '' ) {
|
||||
if ( !function_exists( 'sportspress_event_list' ) ) {
|
||||
function sportspress_event_list( $id = null, $args = '' ) {
|
||||
|
||||
global $sportspress_options;
|
||||
$main_result = sportspress_array_value( $sportspress_options, 'main_result', null );
|
||||
@@ -12,7 +12,7 @@ if ( !function_exists( 'sportspress_events_list' ) ) {
|
||||
$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>';
|
||||
'<table class="sp-event-list sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
|
||||
list( $data, $usecolumns ) = sportspress_get_calendar_data( $id, true );
|
||||
|
||||
@@ -121,12 +121,12 @@ if ( !function_exists( 'sportspress_events_list' ) ) {
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
return apply_filters( 'sportspress_events_list', $output );
|
||||
return apply_filters( 'sportspress_event_list', $output );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function sportspress_events_list_shortcode( $atts ) {
|
||||
function sportspress_event_list_shortcode( $atts ) {
|
||||
if ( isset( $atts['id'] ) ):
|
||||
$id = $atts['id'];
|
||||
unset( $atts['id'] );
|
||||
@@ -136,6 +136,7 @@ function sportspress_events_list_shortcode( $atts ) {
|
||||
else:
|
||||
$id = null;
|
||||
endif;
|
||||
return sportspress_events_list( $id, $atts );
|
||||
return sportspress_event_list( $id, $atts );
|
||||
}
|
||||
add_shortcode('events-list', 'sportspress_events_list_shortcode');
|
||||
add_shortcode('event-list', 'sportspress_event_list_shortcode');
|
||||
add_shortcode('events-list', 'sportspress_event_list_shortcode');
|
||||
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_events' ) ) {
|
||||
function sportspress_events( $args = array() ) {
|
||||
|
||||
$options = array(
|
||||
'post_type' => 'sp_event',
|
||||
'posts_per_page' => 1,
|
||||
'post_status' => 'publish',
|
||||
'tax_query' => array(),
|
||||
);
|
||||
|
||||
if ( isset( $args['number'] ) ):
|
||||
$options['posts_per_page'] = $args['number'];
|
||||
endif;
|
||||
|
||||
if ( isset( $args['status'] ) && $args['status'] == 'future' ):
|
||||
$options['post_status'] = array( 'future' );
|
||||
$options['order'] = 'ASC';
|
||||
endif;
|
||||
|
||||
if ( isset( $args['league'] ) ):
|
||||
$options['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'id',
|
||||
'terms' => $league
|
||||
);
|
||||
endif;
|
||||
|
||||
if ( isset( $args['season'] ) ):
|
||||
$options['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'field' => 'id',
|
||||
'terms' => $season
|
||||
);
|
||||
endif;
|
||||
|
||||
if ( isset( $args['venue'] ) ):
|
||||
$options['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_venue',
|
||||
'field' => 'id',
|
||||
'terms' => $venue
|
||||
);
|
||||
endif;
|
||||
|
||||
$query = new WP_Query( $options );
|
||||
|
||||
if ( $query->have_posts() ):
|
||||
$output = '<ul class="sp-events-list">';
|
||||
while ( $query->have_posts() ):
|
||||
$query->the_post();
|
||||
|
||||
$output .=
|
||||
'<li>' .
|
||||
'<span class="post-date">' . get_the_date() . '</span>' .
|
||||
'<a href="' . get_permalink() . '">' . get_the_title() . '</a>' .
|
||||
'</li>';
|
||||
|
||||
endwhile;
|
||||
$output .= '</ul>';
|
||||
wp_reset_postdata();
|
||||
endif;
|
||||
|
||||
return apply_filters( 'sportspress_events', $output );
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user