Add match day field to events and calendars

This commit is contained in:
Brian Miyaji
2016-08-22 01:14:32 +10:00
parent b33df471d8
commit 84e80d642a
10 changed files with 107 additions and 9 deletions

View File

@@ -20,6 +20,7 @@ class SP_Widget_Event_Calendar extends WP_Widget {
$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'];
$day = empty($instance['day']) ? 'default' : $instance['day'];
$show_all_events_link = empty($instance['show_all_events_link']) ? false : $instance['show_all_events_link'];
do_action( 'sportspress_before_widget', $args, $instance, 'event-calendar' );
@@ -31,7 +32,7 @@ class SP_Widget_Event_Calendar extends WP_Widget {
// Action to hook into
do_action( 'sportspress_before_widget_template', $args, $instance, 'event-calendar' );
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 ) );
sp_get_template( 'event-calendar.php', array( 'id' => $id, 'status' => $status, 'date' => $date, 'date_from' => $date_from, 'date_to' => $date_to, 'caption_tag' => 'caption', 'day' => $day, 'show_all_events_link' => $show_all_events_link ) );
// Action to hook into
do_action( 'sportspress_after_widget_template', $args, $instance, 'event-calendar' );
@@ -48,6 +49,7 @@ class SP_Widget_Event_Calendar extends WP_Widget {
$instance['date'] = $new_instance['date'];
$instance['date_from'] = $new_instance['date_from'];
$instance['date_to'] = $new_instance['date_to'];
$instance['day'] = $new_instance['day'];
$instance['show_all_events_link'] = $new_instance['show_all_events_link'];
// Filter to hook into
@@ -57,13 +59,14 @@ class SP_Widget_Event_Calendar extends WP_Widget {
}
function form( $instance ) {
$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 ) );
$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' ), 'day' => '', 'show_all_events_link' => false ) );
$title = strip_tags($instance['title']);
$id = intval($instance['id']);
$status = $instance['status'];
$date = $instance['date'];
$date_from = $instance['date_from'];
$date_to = $instance['date_to'];
$day = $instance['day'];
$show_all_events_link = $instance['show_all_events_link'];
// Action to hook into
@@ -122,6 +125,9 @@ class SP_Widget_Event_Calendar extends WP_Widget {
</p>
</div>
<p><label for="<?php echo $this->get_field_id('day'); ?>"><?php _e( 'Match Day:', 'sportspress' ); ?></label>
<input id="<?php echo $this->get_field_id('day'); ?>" name="<?php echo $this->get_field_name('day'); ?>" type="text" placeholder="<?php _e( 'All', 'sportspress' ); ?>" value="<?php echo esc_attr($day); ?>" size="10"></p>
<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>