Add date range selector to calendar events
This commit is contained in:
217
assets/css/datepicker.css
Executable file
217
assets/css/datepicker.css
Executable file
File diff suppressed because one or more lines are too long
@@ -523,6 +523,30 @@ jQuery(document).ready(function($){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Datepicker
|
||||||
|
$(".sp-datepicker-from").datepicker({
|
||||||
|
dateFormat : "yy-mm-dd",
|
||||||
|
onClose: function( selectedDate ) {
|
||||||
|
$(this).closest(".sp-date-selector").find(".sp-datepicker-to").datepicker("option", "minDate", selectedDate);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(".sp-datepicker-to").datepicker({
|
||||||
|
dateFormat : "yy-mm-dd",
|
||||||
|
onClose: function( selectedDate ) {
|
||||||
|
$(this).closest(".sp-date-selector").find(".sp-datepicker-from").datepicker("option", "maxDate", selectedDate);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Show or hide datepicker
|
||||||
|
$(".sp-date-selector select").change(function() {
|
||||||
|
if ( $(this).val() == "range" ) {
|
||||||
|
$(this).closest(".sp-date-selector").find(".sp-date-range").show();
|
||||||
|
} else {
|
||||||
|
$(this).closest(".sp-date-selector").find(".sp-date-range").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(".sp-date-selector select").trigger("change");
|
||||||
|
|
||||||
// Fitvids
|
// Fitvids
|
||||||
$(".sp-fitvids").fitVids();
|
$(".sp-fitvids").fitVids();
|
||||||
});
|
});
|
||||||
@@ -14,4 +14,13 @@ jQuery(document).ready(function($){
|
|||||||
$el.show();
|
$el.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Show or hide datepicker
|
||||||
|
$("body").on("change", ".sp-date-selector select", function() {
|
||||||
|
if ( $(this).val() == "range" ) {
|
||||||
|
$(this).closest(".sp-date-selector").find(".sp-date-range").show();
|
||||||
|
} else {
|
||||||
|
$(this).closest(".sp-date-selector").find(".sp-date-range").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(".sp-date-selector select").trigger("change");
|
||||||
});
|
});
|
||||||
@@ -59,6 +59,11 @@ class SP_Admin_Assets {
|
|||||||
wp_enqueue_style( 'sportspress-admin-equation-styles', SP()->plugin_url() . '/assets/css/equation.css', array(), SP_VERSION );
|
wp_enqueue_style( 'sportspress-admin-equation-styles', SP()->plugin_url() . '/assets/css/equation.css', array(), SP_VERSION );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( in_array( $screen->id, array( 'sp_calendar', 'widgets' ) ) ) {
|
||||||
|
wp_enqueue_style( 'jquery-ui-style' , '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css' );
|
||||||
|
wp_enqueue_style( 'sportspress-admin-datepicker-styles', SP()->plugin_url() . '/assets/css/datepicker.css', array( 'jquery-ui-style' ), SP_VERSION );
|
||||||
|
}
|
||||||
|
|
||||||
do_action( 'sportspress_admin_css' );
|
do_action( 'sportspress_admin_css' );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +108,7 @@ class SP_Admin_Assets {
|
|||||||
wp_enqueue_script( 'jquery-caret' );
|
wp_enqueue_script( 'jquery-caret' );
|
||||||
wp_enqueue_script( 'jquery-countdown' );
|
wp_enqueue_script( 'jquery-countdown' );
|
||||||
wp_enqueue_script( 'jquery-fitvids' );
|
wp_enqueue_script( 'jquery-fitvids' );
|
||||||
wp_enqueue_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array( 'jquery', 'chosen', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown', 'jquery-fitvids' ), SP_VERSION, true );
|
wp_enqueue_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array( 'jquery', 'chosen', 'jquery-ui-core', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown', 'jquery-fitvids' ), SP_VERSION, true );
|
||||||
|
|
||||||
$strings = array(
|
$strings = array(
|
||||||
'none' => __( 'None', 'sportspress' ),
|
'none' => __( 'None', 'sportspress' ),
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
$status = get_post_meta( $post->ID, 'sp_status', true );
|
$status = get_post_meta( $post->ID, 'sp_status', true );
|
||||||
$date = get_post_meta( $post->ID, 'sp_date', true );
|
$date = get_post_meta( $post->ID, 'sp_date', true );
|
||||||
|
$date_from = get_post_meta( $post->ID, 'sp_date_from', true );
|
||||||
|
$date_to = get_post_meta( $post->ID, 'sp_date_to', true );
|
||||||
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
|
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
|
||||||
$season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 );
|
$season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 );
|
||||||
$venue_id = sp_get_the_term_id( $post->ID, 'sp_venue', 0 );
|
$venue_id = sp_get_the_term_id( $post->ID, 'sp_venue', 0 );
|
||||||
@@ -39,17 +41,24 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
sp_dropdown_statuses( $args );
|
sp_dropdown_statuses( $args );
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
<p><strong><?php _e( 'Date', 'sportspress' ); ?></strong></p>
|
<div class="sp-date-selector">
|
||||||
<p>
|
<p><strong><?php _e( 'Date', 'sportspress' ); ?></strong></p>
|
||||||
<?php
|
<p>
|
||||||
$args = array(
|
<?php
|
||||||
'name' => 'sp_date',
|
$args = array(
|
||||||
'id' => 'sp_date',
|
'name' => 'sp_date',
|
||||||
'selected' => $date,
|
'id' => 'sp_date',
|
||||||
);
|
'selected' => $date,
|
||||||
sp_dropdown_dates( $args );
|
);
|
||||||
?>
|
sp_dropdown_dates( $args );
|
||||||
</p>
|
?>
|
||||||
|
</p>
|
||||||
|
<p class="sp-date-range">
|
||||||
|
<input type="text" class="sp-datepicker-from" name="sp_date_from" value="<?php echo $date_from ? $date_from : date_i18n( 'Y-m-d' ); ?>" size="10">
|
||||||
|
:
|
||||||
|
<input type="text" class="sp-datepicker-to" name="sp_date_to" value="<?php echo $date_to ? $date_to : date_i18n( 'Y-m-d' ); ?>" size="10">
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
<p><strong><?php _e( 'Competition', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Competition', 'sportspress' ); ?></strong></p>
|
||||||
<p>
|
<p>
|
||||||
<?php
|
<?php
|
||||||
@@ -130,6 +139,8 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
|
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
|
||||||
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 0 ) );
|
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 0 ) );
|
||||||
update_post_meta( $post_id, 'sp_date', sp_array_value( $_POST, 'sp_date', 0 ) );
|
update_post_meta( $post_id, 'sp_date', sp_array_value( $_POST, 'sp_date', 0 ) );
|
||||||
|
update_post_meta( $post_id, 'sp_date_from', sp_array_value( $_POST, 'sp_date_from', null ) );
|
||||||
|
update_post_meta( $post_id, 'sp_date_to', sp_array_value( $_POST, 'sp_date_to', null ) );
|
||||||
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', 0 ) );
|
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', 0 ) );
|
||||||
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) );
|
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
* @category Class
|
* @category Class
|
||||||
* @author ThemeBoy
|
* @author ThemeBoy
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SP_Calendar extends SP_Custom_Post {
|
class SP_Calendar extends SP_Custom_Post {
|
||||||
|
|
||||||
/** @var string The events status. */
|
/** @var string The events status. */
|
||||||
@@ -21,6 +22,12 @@ class SP_Calendar extends SP_Custom_Post {
|
|||||||
/** @var string The events order. */
|
/** @var string The events order. */
|
||||||
public $order;
|
public $order;
|
||||||
|
|
||||||
|
/** @var string The date to range from. */
|
||||||
|
public $from;
|
||||||
|
|
||||||
|
/** @var string The date to range to. */
|
||||||
|
public $to;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* __construct function.
|
* __construct function.
|
||||||
*
|
*
|
||||||
@@ -48,6 +55,15 @@ class SP_Calendar extends SP_Custom_Post {
|
|||||||
|
|
||||||
if ( ! $this->order )
|
if ( ! $this->order )
|
||||||
$this->order = 'ASC';
|
$this->order = 'ASC';
|
||||||
|
|
||||||
|
if ( ! $this->from )
|
||||||
|
$this->from = get_post_meta( $this->ID, 'sp_date_from', true );
|
||||||
|
|
||||||
|
if ( ! $this->to ):
|
||||||
|
$to = new DateTime( get_post_meta( $this->ID, 'sp_date_to', true ) );
|
||||||
|
$to->modify( '+1 day' );
|
||||||
|
$this->to = $to->format( 'Y-m-d' );
|
||||||
|
endif;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,12 +88,15 @@ class SP_Calendar extends SP_Custom_Post {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ( $this->date !== 0 ):
|
if ( $this->date !== 0 ):
|
||||||
$args['year'] = date('Y');
|
|
||||||
if ( $this->date == 'w' ):
|
if ( $this->date == 'w' ):
|
||||||
|
$args['year'] = date('Y');
|
||||||
$args['w'] = date('W');
|
$args['w'] = date('W');
|
||||||
elseif ( $this->date == 'day' ):
|
elseif ( $this->date == 'day' ):
|
||||||
|
$args['year'] = date('Y');
|
||||||
$args['day'] = date('j');
|
$args['day'] = date('j');
|
||||||
$args['monthnum'] = date('n');
|
$args['monthnum'] = date('n');
|
||||||
|
elseif ( $this->date == 'range' ):
|
||||||
|
add_filter( 'posts_where', array( $this, 'range' ) );
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -141,7 +160,14 @@ class SP_Calendar extends SP_Custom_Post {
|
|||||||
$events = null;
|
$events = null;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
remove_filter( 'posts_where', array( $this, 'range' ) );
|
||||||
|
|
||||||
return $events;
|
return $events;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function range( $where = '' ) {
|
||||||
|
$where .= " AND post_date BETWEEN '" . $this->from . "' AND '" . $this->to . "'";
|
||||||
|
return $where;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -437,7 +437,8 @@ if ( !function_exists( 'sp_dropdown_dates' ) ) {
|
|||||||
$dates = apply_filters( 'sportspress_dates', array(
|
$dates = apply_filters( 'sportspress_dates', array(
|
||||||
0 => __( 'All', 'sportspress' ),
|
0 => __( 'All', 'sportspress' ),
|
||||||
'w' => __( 'This week', 'sportspress' ),
|
'w' => __( 'This week', 'sportspress' ),
|
||||||
'day' => __( 'Today', 'sportspress' )
|
'day' => __( 'Today', 'sportspress' ),
|
||||||
|
'range' => __( 'Date range:', 'sportspress' ),
|
||||||
));
|
));
|
||||||
|
|
||||||
foreach ( $dates as $value => $label ):
|
foreach ( $dates as $value => $label ):
|
||||||
|
|||||||
@@ -12,13 +12,15 @@ class SP_Widget_Event_Blocks extends WP_Widget {
|
|||||||
$id = empty($instance['id']) ? null : $instance['id'];
|
$id = empty($instance['id']) ? null : $instance['id'];
|
||||||
$status = empty($instance['status']) ? 'default' : $instance['status'];
|
$status = empty($instance['status']) ? 'default' : $instance['status'];
|
||||||
$date = empty($instance['date']) ? 'default' : $instance['date'];
|
$date = empty($instance['date']) ? 'default' : $instance['date'];
|
||||||
|
$date_from = empty($instance['date_from']) ? 'default' : $instance['date_from'];
|
||||||
|
$date_to = empty($instance['date_to']) ? 'default' : $instance['date_to'];
|
||||||
$number = empty($instance['number']) ? null : $instance['number'];
|
$number = empty($instance['number']) ? null : $instance['number'];
|
||||||
$order = empty($instance['order']) ? 'default' : $instance['order'];
|
$order = empty($instance['order']) ? 'default' : $instance['order'];
|
||||||
$show_all_events_link = empty($instance['show_all_events_link']) ? false : $instance['show_all_events_link'];
|
$show_all_events_link = empty($instance['show_all_events_link']) ? false : $instance['show_all_events_link'];
|
||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
if ( $title )
|
if ( $title )
|
||||||
echo $before_title . $title . $after_title;
|
echo $before_title . $title . $after_title;
|
||||||
sp_get_template( 'event-blocks.php', array( 'id' => $id, 'status' => $status, 'date' => $date, 'number' => $number, 'order' => $order, 'show_all_events_link' => $show_all_events_link ) );
|
sp_get_template( 'event-blocks.php', array( 'id' => $id, 'status' => $status, 'date' => $date, 'date_from' => $date_from, 'date_to' => $date_to, 'number' => $number, 'order' => $order, 'show_all_events_link' => $show_all_events_link ) );
|
||||||
echo $after_widget;
|
echo $after_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,6 +30,8 @@ class SP_Widget_Event_Blocks extends WP_Widget {
|
|||||||
$instance['id'] = intval($new_instance['id']);
|
$instance['id'] = intval($new_instance['id']);
|
||||||
$instance['status'] = $new_instance['status'];
|
$instance['status'] = $new_instance['status'];
|
||||||
$instance['date'] = $new_instance['date'];
|
$instance['date'] = $new_instance['date'];
|
||||||
|
$instance['date_from'] = $new_instance['date_from'];
|
||||||
|
$instance['date_to'] = $new_instance['date_to'];
|
||||||
$instance['number'] = intval($new_instance['number']);
|
$instance['number'] = intval($new_instance['number']);
|
||||||
$instance['order'] = strip_tags($new_instance['order']);
|
$instance['order'] = strip_tags($new_instance['order']);
|
||||||
$instance['show_all_events_link'] = $new_instance['show_all_events_link'];
|
$instance['show_all_events_link'] = $new_instance['show_all_events_link'];
|
||||||
@@ -36,11 +40,13 @@ class SP_Widget_Event_Blocks extends WP_Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function form( $instance ) {
|
function form( $instance ) {
|
||||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'status' => 'default', 'date' => 'default', 'number' => 5, 'order' => 'default', 'show_all_events_link' => true ) );
|
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'status' => 'default', 'date' => 'default', 'date_from' => date_i18n( 'Y-m-d' ), 'date_to' => date_i18n( 'Y-m-d' ), 'number' => 5, 'order' => 'default', 'show_all_events_link' => true ) );
|
||||||
$title = strip_tags($instance['title']);
|
$title = strip_tags($instance['title']);
|
||||||
$id = intval($instance['id']);
|
$id = intval($instance['id']);
|
||||||
$status = $instance['status'];
|
$status = $instance['status'];
|
||||||
$date = $instance['date'];
|
$date = $instance['date'];
|
||||||
|
$date_from = $instance['date_from'];
|
||||||
|
$date_to = $instance['date_to'];
|
||||||
$number = intval($instance['number']);
|
$number = intval($instance['number']);
|
||||||
$order = strip_tags($instance['order']);
|
$order = strip_tags($instance['order']);
|
||||||
$show_all_events_link = $instance['show_all_events_link'];
|
$show_all_events_link = $instance['show_all_events_link'];
|
||||||
@@ -78,18 +84,25 @@ class SP_Widget_Event_Blocks extends WP_Widget {
|
|||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p><label for="<?php echo $this->get_field_id('date'); ?>"><?php _e( 'Date:', 'sportspress' ); ?></label>
|
<div class="sp-date-selector">
|
||||||
<?php
|
<p><label for="<?php echo $this->get_field_id('date'); ?>"><?php _e( 'Date:', 'sportspress' ); ?></label>
|
||||||
$args = array(
|
<?php
|
||||||
'show_option_default' => __( 'Default', 'sportspress' ),
|
$args = array(
|
||||||
'name' => $this->get_field_name('date'),
|
'show_option_default' => __( 'Default', 'sportspress' ),
|
||||||
'id' => $this->get_field_id('date'),
|
'name' => $this->get_field_name('date'),
|
||||||
'selected' => $date,
|
'id' => $this->get_field_id('date'),
|
||||||
'class' => 'sp-event-date-select widefat',
|
'selected' => $date,
|
||||||
);
|
'class' => 'sp-event-date-select widefat',
|
||||||
sp_dropdown_dates( $args );
|
);
|
||||||
?>
|
sp_dropdown_dates( $args );
|
||||||
</p>
|
?>
|
||||||
|
</p>
|
||||||
|
<p class="sp-date-range<?php if ( 'range' !== $date ): ?> hidden<?php endif; ?>">
|
||||||
|
<input type="text" name="<?php echo $this->get_field_name( 'date_from' ); ?>" value="<?php echo $date_from; ?>" placeholder="yyyy-mm-dd" size="10">
|
||||||
|
:
|
||||||
|
<input type="text" name="<?php echo $this->get_field_name( 'date_to' ); ?>" value="<?php echo $date_to; ?>" placeholder="yyyy-mm-dd" size="10">
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of events to show:', 'sportspress' ); ?></label>
|
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of events to show:', 'sportspress' ); ?></label>
|
||||||
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
|
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
|
||||||
|
|||||||
@@ -11,12 +11,15 @@ class SP_Widget_Event_Calendar extends WP_Widget {
|
|||||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||||
$id = empty($instance['id']) ? null : $instance['id'];
|
$id = empty($instance['id']) ? null : $instance['id'];
|
||||||
$status = empty($instance['status']) ? 'default' : $instance['status'];
|
$status = empty($instance['status']) ? 'default' : $instance['status'];
|
||||||
|
$date = empty($instance['date']) ? 'default' : $instance['date'];
|
||||||
|
$date_from = empty($instance['date_from']) ? 'default' : $instance['date_from'];
|
||||||
|
$date_to = empty($instance['date_to']) ? 'default' : $instance['date_to'];
|
||||||
$show_all_events_link = empty($instance['show_all_events_link']) ? false : $instance['show_all_events_link'];
|
$show_all_events_link = empty($instance['show_all_events_link']) ? false : $instance['show_all_events_link'];
|
||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
if ( $title )
|
if ( $title )
|
||||||
echo $before_title . $title . $after_title;
|
echo $before_title . $title . $after_title;
|
||||||
echo '<div id="calendar_wrap">';
|
echo '<div id="calendar_wrap">';
|
||||||
sp_get_template( 'event-calendar.php', array( 'id' => $id, 'status' => $status, 'caption_tag' => 'caption', 'show_all_events_link' => $show_all_events_link ) );
|
sp_get_template( 'event-calendar.php', array( 'id' => $id, 'status' => $status, 'date' => $date, 'date_from' => $date_from, 'date_to' => $date_to, 'caption_tag' => 'caption', 'show_all_events_link' => $show_all_events_link ) );
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
echo $after_widget;
|
echo $after_widget;
|
||||||
}
|
}
|
||||||
@@ -26,16 +29,22 @@ class SP_Widget_Event_Calendar extends WP_Widget {
|
|||||||
$instance['title'] = strip_tags($new_instance['title']);
|
$instance['title'] = strip_tags($new_instance['title']);
|
||||||
$instance['id'] = intval($new_instance['id']);
|
$instance['id'] = intval($new_instance['id']);
|
||||||
$instance['status'] = $new_instance['status'];
|
$instance['status'] = $new_instance['status'];
|
||||||
|
$instance['date'] = $new_instance['date'];
|
||||||
|
$instance['date_from'] = $new_instance['date_from'];
|
||||||
|
$instance['date_to'] = $new_instance['date_to'];
|
||||||
$instance['show_all_events_link'] = $new_instance['show_all_events_link'];
|
$instance['show_all_events_link'] = $new_instance['show_all_events_link'];
|
||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
function form( $instance ) {
|
function form( $instance ) {
|
||||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'status' => 'default', 'show_all_events_link' => false ) );
|
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'status' => 'default', 'date' => 'default', 'date_from' => date_i18n( 'Y-m-d' ), 'date_to' => date_i18n( 'Y-m-d' ), 'show_all_events_link' => false ) );
|
||||||
$title = strip_tags($instance['title']);
|
$title = strip_tags($instance['title']);
|
||||||
$id = intval($instance['id']);
|
$id = intval($instance['id']);
|
||||||
$status = $instance['status'];
|
$status = $instance['status'];
|
||||||
|
$date = $instance['date'];
|
||||||
|
$date_from = $instance['date_from'];
|
||||||
|
$date_to = $instance['date_to'];
|
||||||
$show_all_events_link = $instance['show_all_events_link'];
|
$show_all_events_link = $instance['show_all_events_link'];
|
||||||
?>
|
?>
|
||||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', 'sportspress' ); ?></label>
|
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', 'sportspress' ); ?></label>
|
||||||
@@ -71,6 +80,26 @@ class SP_Widget_Event_Calendar extends WP_Widget {
|
|||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<div class="sp-date-selector sp-event-calendar-show-all-toggle<?php if ( ! $id ): ?> hidden<?php endif; ?>">
|
||||||
|
<p><label for="<?php echo $this->get_field_id('date'); ?>"><?php _e( 'Date:', 'sportspress' ); ?></label>
|
||||||
|
<?php
|
||||||
|
$args = array(
|
||||||
|
'show_option_default' => __( 'Default', 'sportspress' ),
|
||||||
|
'name' => $this->get_field_name('date'),
|
||||||
|
'id' => $this->get_field_id('date'),
|
||||||
|
'selected' => $date,
|
||||||
|
'class' => 'sp-event-date-select widefat',
|
||||||
|
);
|
||||||
|
sp_dropdown_dates( $args );
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
<p class="sp-date-range<?php if ( 'range' !== $date ): ?> hidden<?php endif; ?>">
|
||||||
|
<input type="text" name="<?php echo $this->get_field_name( 'date_from' ); ?>" value="<?php echo $date_from; ?>" placeholder="yyyy-mm-dd" size="10">
|
||||||
|
:
|
||||||
|
<input type="text" name="<?php echo $this->get_field_name( 'date_to' ); ?>" value="<?php echo $date_to; ?>" placeholder="yyyy-mm-dd" size="10">
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<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 ); ?>>
|
<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>
|
<label for="<?php echo $this->get_field_id('show_all_events_link'); ?>"><?php _e( 'Display link to view all events', 'sportspress' ); ?></label></p>
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ class SP_Widget_Event_List extends WP_Widget {
|
|||||||
$id = empty($instance['id']) ? null : $instance['id'];
|
$id = empty($instance['id']) ? null : $instance['id'];
|
||||||
$status = empty($instance['status']) ? 'default' : $instance['status'];
|
$status = empty($instance['status']) ? 'default' : $instance['status'];
|
||||||
$date = empty($instance['date']) ? 'default' : $instance['date'];
|
$date = empty($instance['date']) ? 'default' : $instance['date'];
|
||||||
|
$date_from = empty($instance['date_from']) ? 'default' : $instance['date_from'];
|
||||||
|
$date_to = empty($instance['date_to']) ? 'default' : $instance['date_to'];
|
||||||
$number = empty($instance['number']) ? null : $instance['number'];
|
$number = empty($instance['number']) ? null : $instance['number'];
|
||||||
$columns = empty($instance['columns']) ? null : $instance['columns'];
|
$columns = empty($instance['columns']) ? null : $instance['columns'];
|
||||||
$order = empty($instance['order']) ? 'default' : $instance['order'];
|
$order = empty($instance['order']) ? 'default' : $instance['order'];
|
||||||
@@ -19,7 +21,7 @@ class SP_Widget_Event_List extends WP_Widget {
|
|||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
if ( $title )
|
if ( $title )
|
||||||
echo $before_title . $title . $after_title;
|
echo $before_title . $title . $after_title;
|
||||||
sp_get_template( 'event-list.php', array( 'id' => $id, 'status' => $status, 'date' => $date, 'number' => $number, 'columns' => $columns, 'order' => $order, 'show_all_events_link' => $show_all_events_link ) );
|
sp_get_template( 'event-list.php', array( 'id' => $id, 'status' => $status, 'date' => $date, 'date_from' => $date_from, 'date_to' => $date_to, 'number' => $number, 'columns' => $columns, 'order' => $order, 'show_all_events_link' => $show_all_events_link ) );
|
||||||
echo $after_widget;
|
echo $after_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,6 +31,8 @@ class SP_Widget_Event_List extends WP_Widget {
|
|||||||
$instance['id'] = intval($new_instance['id']);
|
$instance['id'] = intval($new_instance['id']);
|
||||||
$instance['status'] = $new_instance['status'];
|
$instance['status'] = $new_instance['status'];
|
||||||
$instance['date'] = $new_instance['date'];
|
$instance['date'] = $new_instance['date'];
|
||||||
|
$instance['date_from'] = $new_instance['date_from'];
|
||||||
|
$instance['date_to'] = $new_instance['date_to'];
|
||||||
$instance['number'] = intval($new_instance['number']);
|
$instance['number'] = intval($new_instance['number']);
|
||||||
$instance['columns'] = (array)$new_instance['columns'];
|
$instance['columns'] = (array)$new_instance['columns'];
|
||||||
$instance['order'] = strip_tags($new_instance['order']);
|
$instance['order'] = strip_tags($new_instance['order']);
|
||||||
@@ -38,11 +42,13 @@ class SP_Widget_Event_List extends WP_Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function form( $instance ) {
|
function form( $instance ) {
|
||||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'status' => 'default', 'date' => 'default', 'number' => 5, 'columns' => null, 'order' => 'default', 'show_all_events_link' => true ) );
|
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'status' => 'default', 'date' => 'default', 'date_from' => date_i18n( 'Y-m-d' ), 'date_to' => date_i18n( 'Y-m-d' ), 'number' => 5, 'columns' => null, 'order' => 'default', 'show_all_events_link' => true ) );
|
||||||
$title = strip_tags($instance['title']);
|
$title = strip_tags($instance['title']);
|
||||||
$id = intval($instance['id']);
|
$id = intval($instance['id']);
|
||||||
$status = $instance['status'];
|
$status = $instance['status'];
|
||||||
$date = $instance['date'];
|
$date = $instance['date'];
|
||||||
|
$date_from = $instance['date_from'];
|
||||||
|
$date_to = $instance['date_to'];
|
||||||
$number = intval($instance['number']);
|
$number = intval($instance['number']);
|
||||||
$columns = $instance['columns'];
|
$columns = $instance['columns'];
|
||||||
$order = strip_tags($instance['order']);
|
$order = strip_tags($instance['order']);
|
||||||
@@ -81,18 +87,25 @@ class SP_Widget_Event_List extends WP_Widget {
|
|||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p><label for="<?php echo $this->get_field_id('date'); ?>"><?php _e( 'Date:', 'sportspress' ); ?></label>
|
<div class="sp-date-selector">
|
||||||
<?php
|
<p><label for="<?php echo $this->get_field_id('date'); ?>"><?php _e( 'Date:', 'sportspress' ); ?></label>
|
||||||
$args = array(
|
<?php
|
||||||
'show_option_default' => __( 'Default', 'sportspress' ),
|
$args = array(
|
||||||
'name' => $this->get_field_name('date'),
|
'show_option_default' => __( 'Default', 'sportspress' ),
|
||||||
'id' => $this->get_field_id('date'),
|
'name' => $this->get_field_name('date'),
|
||||||
'selected' => $date,
|
'id' => $this->get_field_id('date'),
|
||||||
'class' => 'sp-event-date-select widefat',
|
'selected' => $date,
|
||||||
);
|
'class' => 'sp-event-date-select widefat',
|
||||||
sp_dropdown_dates( $args );
|
);
|
||||||
?>
|
sp_dropdown_dates( $args );
|
||||||
</p>
|
?>
|
||||||
|
</p>
|
||||||
|
<p class="sp-date-range<?php if ( 'range' !== $date ): ?> hidden<?php endif; ?>">
|
||||||
|
<input type="text" name="<?php echo $this->get_field_name( 'date_from' ); ?>" value="<?php echo $date_from; ?>" placeholder="yyyy-mm-dd" size="10">
|
||||||
|
:
|
||||||
|
<input type="text" name="<?php echo $this->get_field_name( 'date_to' ); ?>" value="<?php echo $date_to; ?>" placeholder="yyyy-mm-dd" size="10">
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of events to show:', 'sportspress' ); ?></label>
|
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of events to show:', 'sportspress' ); ?></label>
|
||||||
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
|
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ $primary_result = get_option( 'sportspress_primary_result', null );
|
|||||||
$defaults = array(
|
$defaults = array(
|
||||||
'status' => 'default',
|
'status' => 'default',
|
||||||
'date' => 'default',
|
'date' => 'default',
|
||||||
|
'date_to' => 'default',
|
||||||
|
'date_from' => 'default',
|
||||||
'number' => -1,
|
'number' => -1,
|
||||||
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
|
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
|
||||||
'paginated' => get_option( 'sportspress_event_blocks_paginated', 'yes' ) == 'yes' ? true : false,
|
'paginated' => get_option( 'sportspress_event_blocks_paginated', 'yes' ) == 'yes' ? true : false,
|
||||||
@@ -31,6 +33,10 @@ if ( $status != 'default' )
|
|||||||
$calendar->status = $status;
|
$calendar->status = $status;
|
||||||
if ( $date != 'default' )
|
if ( $date != 'default' )
|
||||||
$calendar->date = $date;
|
$calendar->date = $date;
|
||||||
|
if ( $date_from != 'default' )
|
||||||
|
$calendar->from = $date_from;
|
||||||
|
if ( $date_to != 'default' )
|
||||||
|
$calendar->to = $date_to;
|
||||||
if ( $order != 'default' )
|
if ( $order != 'default' )
|
||||||
$calendar->order = $order;
|
$calendar->order = $order;
|
||||||
$data = $calendar->data();
|
$data = $calendar->data();
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ global $wpdb, $m, $monthnum, $year, $wp_locale;
|
|||||||
$defaults = array(
|
$defaults = array(
|
||||||
'id' => null,
|
'id' => null,
|
||||||
'status' => 'default',
|
'status' => 'default',
|
||||||
|
'date' => 'default',
|
||||||
|
'date_to' => 'default',
|
||||||
|
'date_from' => 'default',
|
||||||
'initial' => true,
|
'initial' => true,
|
||||||
'caption_tag' => 'h4',
|
'caption_tag' => 'h4',
|
||||||
'show_all_events_link' => false,
|
'show_all_events_link' => false,
|
||||||
@@ -25,6 +28,12 @@ if ( isset( $id ) ):
|
|||||||
$calendar = new SP_Calendar( $id );
|
$calendar = new SP_Calendar( $id );
|
||||||
if ( $status != 'default' )
|
if ( $status != 'default' )
|
||||||
$calendar->status = $status;
|
$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;
|
||||||
$events = $calendar->data();
|
$events = $calendar->data();
|
||||||
$event_ids = array();
|
$event_ids = array();
|
||||||
foreach ( $events as $event ):
|
foreach ( $events as $event ):
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ $defaults = array(
|
|||||||
'id' => null,
|
'id' => null,
|
||||||
'status' => 'default',
|
'status' => 'default',
|
||||||
'date' => 'default',
|
'date' => 'default',
|
||||||
|
'date_to' => 'default',
|
||||||
|
'date_from' => 'default',
|
||||||
'number' => -1,
|
'number' => -1,
|
||||||
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == '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,
|
'link_venues' => get_option( 'sportspress_link_venues', 'yes' ) == 'yes' ? true : false,
|
||||||
@@ -35,6 +37,10 @@ if ( $status != 'default' )
|
|||||||
$calendar->status = $status;
|
$calendar->status = $status;
|
||||||
if ( $date != 'default' )
|
if ( $date != 'default' )
|
||||||
$calendar->date = $date;
|
$calendar->date = $date;
|
||||||
|
if ( $date_from != 'default' )
|
||||||
|
$calendar->from = $date_from;
|
||||||
|
if ( $date_to != 'default' )
|
||||||
|
$calendar->to = $date_to;
|
||||||
if ( $order != 'default' )
|
if ( $order != 'default' )
|
||||||
$calendar->order = $order;
|
$calendar->order = $order;
|
||||||
$data = $calendar->data();
|
$data = $calendar->data();
|
||||||
|
|||||||
Reference in New Issue
Block a user