Add an option to Countdown widget to show Excluded (i.e. cancelled, postponed) events.

This commit is contained in:
savvasha
2020-04-12 13:32:11 +03:00
parent ec00d7d74b
commit 9f2888fd45
2 changed files with 26 additions and 10 deletions

View File

@@ -16,6 +16,7 @@ class SP_Widget_Countdown extends WP_Widget {
$show_venue = empty($instance['show_venue']) ? false : $instance['show_venue'];
$show_league = empty($instance['show_league']) ? false : $instance['show_league'];
$show_date = empty($instance['show_date']) ? false : $instance['show_date'];
$show_excluded = empty($instance['show_excluded']) ? false : $instance['show_excluded'];
do_action( 'sportspress_before_widget', $args, $instance, 'countdown' );
echo $before_widget;
@@ -26,7 +27,7 @@ class SP_Widget_Countdown extends WP_Widget {
// Action to hook into
do_action( 'sportspress_before_widget_template', $args, $instance, 'countdown' );
sp_get_template( 'countdown.php', array( 'calendar' => $calendar, 'team' => $team, 'id' => $id, 'title' => $caption, 'show_venue' => $show_venue, 'show_league' => $show_league, 'show_date' => $show_date ) );
sp_get_template( 'countdown.php', array( 'calendar' => $calendar, 'team' => $team, 'id' => $id, 'title' => $caption, 'show_venue' => $show_venue, 'show_league' => $show_league, 'show_date' => $show_date, 'show_excluded' => $show_excluded ) );
// Action to hook into
do_action( 'sportspress_after_widget_template', $args, $instance, 'countdown' );
@@ -45,6 +46,7 @@ class SP_Widget_Countdown extends WP_Widget {
$instance['show_venue'] = intval($new_instance['show_venue']);
$instance['show_league'] = intval($new_instance['show_league']);
$instance['show_date'] = intval($new_instance['show_date']);
$instance['show_excluded'] = intval($new_instance['show_excluded']);
// Filter to hook into
$instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'countdown' );
@@ -62,6 +64,7 @@ class SP_Widget_Countdown extends WP_Widget {
$show_venue = intval($instance['show_venue']);
$show_league = intval($instance['show_league']);
$show_date = intval($instance['show_date']);
$show_excluded = intval($instance['show_excluded']);
// Action to hook into
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'countdown' );
@@ -135,6 +138,9 @@ class SP_Widget_Countdown extends WP_Widget {
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_date'); ?>" name="<?php echo $this->get_field_name('show_date'); ?>" value="1" <?php checked( $show_date, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_date'); ?>"><?php _e( 'Display date', 'sportspress' ); ?></label></p>
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_excluded'); ?>" name="<?php echo $this->get_field_name('show_excluded'); ?>" value="1" <?php checked( $show_excluded, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_excluded'); ?>"><?php _e( 'Display excluded events', 'sportspress' ); ?></label></p>
<?php
// Action to hook into
do_action( 'sportspress_after_widget_template_form', $this, $instance, 'countdown' );