Consistently use event prefix for calendar and list templates
Retain backwards compatibility
This commit is contained in:
@@ -38,10 +38,10 @@ function sportspress_default_calendar_content( $content ) {
|
||||
$format = get_post_meta( $id, 'sp_format', true );
|
||||
switch ( $format ):
|
||||
case 'list':
|
||||
$calendar = sportspress_events_list( $id );
|
||||
$calendar = sportspress_event_list( $id );
|
||||
break;
|
||||
default:
|
||||
$calendar = sportspress_events_calendar( $id, false );
|
||||
$calendar = sportspress_event_calendar( $id, false );
|
||||
break;
|
||||
endswitch;
|
||||
$content = $calendar . $content;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
function sportspress_widget_text( $content ) {
|
||||
if ( ! preg_match( '/\[[\r\n\t ]*(countdown|league-table|events-(calendar|list)|player-(list|gallery))?[\r\n\t ].*?\]/', $content ) )
|
||||
if ( ! preg_match( '/\[[\r\n\t ]*(countdown|league-table|event(s)-(calendar|list)|player-(list|gallery))?[\r\n\t ].*?\]/', $content ) )
|
||||
return $content;
|
||||
|
||||
$content = do_shortcode( $content );
|
||||
|
||||
@@ -62,7 +62,7 @@ function sportspress_calendar_shortcode_meta( $post ) {
|
||||
<p class="howto">
|
||||
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
|
||||
</p>
|
||||
<p><input type="text" value="[events-<?php echo $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
|
||||
<p><input type="text" value="[event-<?php echo $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
class SportsPress_Widget_Events_Calendar extends WP_Widget {
|
||||
class SportsPress_Widget_Event_Calendar extends WP_Widget {
|
||||
|
||||
function __construct() {
|
||||
$widget_ops = array('classname' => 'widget_calendar widget_sp_events_calendar', 'description' => __( 'A calendar of events.', 'sportspress' ) );
|
||||
parent::__construct('sp_events_calendar', __( 'SportsPress Events Calendar', 'sportspress' ), $widget_ops);
|
||||
$widget_ops = array('classname' => 'widget_calendar widget_sp_event_calendar', 'description' => __( 'A calendar of events.', 'sportspress' ) );
|
||||
parent::__construct('sp_event_calendar', __( 'SportsPress Events Calendar', 'sportspress' ), $widget_ops);
|
||||
}
|
||||
|
||||
function widget( $args, $instance ) {
|
||||
@@ -15,7 +15,7 @@ class SportsPress_Widget_Events_Calendar extends WP_Widget {
|
||||
if ( $title )
|
||||
echo $before_title . $title . $after_title;
|
||||
echo '<div id="calendar_wrap">';
|
||||
echo sportspress_events_calendar( $id, true, array( 'caption_tag' => 'caption', 'show_all_events_link' => $show_all_events_link ) );
|
||||
echo sportspress_event_calendar( $id, true, array( 'caption_tag' => 'caption', 'show_all_events_link' => $show_all_events_link ) );
|
||||
echo '</div>';
|
||||
echo $after_widget;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class SportsPress_Widget_Events_Calendar extends WP_Widget {
|
||||
'id' => $this->get_field_id('id'),
|
||||
'selected' => $id,
|
||||
'values' => 'ID',
|
||||
'class' => 'sp-events-calendar-select widefat',
|
||||
'class' => 'sp-event-calendar-select widefat',
|
||||
);
|
||||
if ( ! sportspress_dropdown_pages( $args ) ):
|
||||
sportspress_post_adder( 'sp_calendar', __( 'Add New', 'sportspress' ) );
|
||||
@@ -55,9 +55,9 @@ class SportsPress_Widget_Events_Calendar extends WP_Widget {
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p class="sp-events-calendar-show-all-toggle<?php if ( ! $id ): ?> hidden<?php endif; ?>"><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_all_events_link'); ?>" name="<?php echo $this->get_field_name('show_all_events_link'); ?>" value="1" <?php checked( $show_all_events_link, 1 ); ?>>
|
||||
<p class="sp-event-calendar-show-all-toggle<?php if ( ! $id ): ?> hidden<?php endif; ?>"><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_all_events_link'); ?>" name="<?php echo $this->get_field_name('show_all_events_link'); ?>" value="1" <?php checked( $show_all_events_link, 1 ); ?>>
|
||||
<label for="<?php echo $this->get_field_id('show_all_events_link'); ?>"><?php _e( 'Display link to view all events', 'sportspress' ); ?></label></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
add_action( 'widgets_init', create_function( '', 'return register_widget( "SportsPress_Widget_Events_Calendar" );' ) );
|
||||
add_action( 'widgets_init', create_function( '', 'return register_widget( "SportsPress_Widget_Event_Calendar" );' ) );
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
class SportsPress_Widget_Events_List extends WP_Widget {
|
||||
class SportsPress_Widget_Event_List extends WP_Widget {
|
||||
|
||||
function __construct() {
|
||||
$widget_ops = array('classname' => 'widget_sp_events_list', 'description' => __( 'A list of events.', 'sportspress' ) );
|
||||
parent::__construct('sp_events_list', __( 'SportsPress Events List', 'sportspress' ), $widget_ops);
|
||||
$widget_ops = array('classname' => 'widget_sp_event_list', 'description' => __( 'A list of events.', 'sportspress' ) );
|
||||
parent::__construct('sp_event_list', __( 'SportsPress Events List', 'sportspress' ), $widget_ops);
|
||||
}
|
||||
|
||||
function widget( $args, $instance ) {
|
||||
@@ -15,7 +15,7 @@ class SportsPress_Widget_Events_List extends WP_Widget {
|
||||
echo $before_widget;
|
||||
if ( $title )
|
||||
echo $before_title . $title . $after_title;
|
||||
echo sportspress_events_list( $id, array( 'columns' => $columns, 'show_all_events_link' => $show_all_events_link ) );
|
||||
echo sportspress_event_list( $id, array( 'columns' => $columns, 'show_all_events_link' => $show_all_events_link ) );
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class SportsPress_Widget_Events_List extends WP_Widget {
|
||||
'id' => $this->get_field_id('id'),
|
||||
'selected' => $id,
|
||||
'values' => 'ID',
|
||||
'class' => 'sp-events-calendar-select widefat',
|
||||
'class' => 'sp-event-calendar-select widefat',
|
||||
);
|
||||
if ( ! sportspress_dropdown_pages( $args ) ):
|
||||
sportspress_post_adder( 'sp_calendar', __( 'Add New', 'sportspress' ) );
|
||||
@@ -73,9 +73,9 @@ class SportsPress_Widget_Events_List extends WP_Widget {
|
||||
<?php endforeach; ?>
|
||||
</p>
|
||||
|
||||
<p class="sp-events-calendar-show-all-toggle<?php if ( ! $id ): ?> hidden<?php endif; ?>"><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_all_events_link'); ?>" name="<?php echo $this->get_field_name('show_all_events_link'); ?>" value="1" <?php checked( $show_all_events_link, 1 ); ?>>
|
||||
<p class="sp-event-calendar-show-all-toggle<?php if ( ! $id ): ?> hidden<?php endif; ?>"><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_all_events_link'); ?>" name="<?php echo $this->get_field_name('show_all_events_link'); ?>" value="1" <?php checked( $show_all_events_link, 1 ); ?>>
|
||||
<label for="<?php echo $this->get_field_id('show_all_events_link'); ?>"><?php _e( 'Display link to view all events', 'sportspress' ); ?></label></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
add_action( 'widgets_init', create_function( '', 'return register_widget( "SportsPress_Widget_Events_List" );' ) );
|
||||
add_action( 'widgets_init', create_function( '', 'return register_widget( "SportsPress_Widget_Event_List" );' ) );
|
||||
@@ -33,20 +33,20 @@
|
||||
}
|
||||
|
||||
/* Events Calendar */
|
||||
.sp-events-calendar tbody td, .sp-events-calendar thead th {
|
||||
.sp-event-calendar tbody td, .sp-event-calendar thead th {
|
||||
text-align: center;
|
||||
}
|
||||
.sp-events-calendar #next {
|
||||
.sp-event-calendar #next {
|
||||
text-align: right;
|
||||
}
|
||||
.sp-events-calendar #prev {
|
||||
.sp-event-calendar #prev {
|
||||
text-align: left;
|
||||
}
|
||||
/* Events List */
|
||||
.sp-events-list .column-article {
|
||||
.sp-event-list .column-article {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.sp-events-list .column-article a .dashicons {
|
||||
.sp-event-list .column-article a .dashicons {
|
||||
padding-right: 3px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ jQuery(document).ready(function($){
|
||||
});
|
||||
|
||||
// Calendar affects view all link checkbox in widget options
|
||||
$("body.widgets-php").on("change", ".sp-events-calendar-select", function() {
|
||||
$el = $(this).closest(".widget-content").find(".sp-events-calendar-show-all-toggle");
|
||||
$("body.widgets-php").on("change", ".sp-event-calendar-select", function() {
|
||||
$el = $(this).closest(".widget-content").find(".sp-event-calendar-show-all-toggle");
|
||||
if($(this).val() == 0)
|
||||
$el.hide();
|
||||
else
|
||||
|
||||
@@ -39,9 +39,8 @@ require_once dirname( __FILE__ ) . '/admin/templates/event-statistics.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/templates/event-results.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/templates/event-staff.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/templates/event-venue.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/templates/events.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/templates/events-calendar.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/templates/events-list.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/templates/event-calendar.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/templates/event-list.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/templates/league-table.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/templates/player-league-statistics.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/templates/player-list.php';
|
||||
@@ -84,8 +83,8 @@ require_once dirname( __FILE__ ) . '/admin/terms/position.php';
|
||||
|
||||
// Widgets
|
||||
require_once dirname( __FILE__ ) . '/admin/widgets/countdown.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/widgets/events-calendar.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/widgets/events-list.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/widgets/event-calendar.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/widgets/event-list.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/widgets/league-table.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/widgets/player-list.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/widgets/player-gallery.php';
|
||||
|
||||
Reference in New Issue
Block a user