Add date and time option for showing on the countdown widget
This commit is contained in:
@@ -15,6 +15,7 @@ class SP_Widget_Countdown extends WP_Widget {
|
|||||||
$id = empty($instance['id']) ? null : $instance['id'];
|
$id = empty($instance['id']) ? null : $instance['id'];
|
||||||
$show_venue = empty($instance['show_venue']) ? false : $instance['show_venue'];
|
$show_venue = empty($instance['show_venue']) ? false : $instance['show_venue'];
|
||||||
$show_league = empty($instance['show_league']) ? false : $instance['show_league'];
|
$show_league = empty($instance['show_league']) ? false : $instance['show_league'];
|
||||||
|
$show_date = empty($instance['show_date']) ? false : $instance['show_date'];
|
||||||
|
|
||||||
do_action( 'sportspress_before_widget', $args, $instance, 'countdown' );
|
do_action( 'sportspress_before_widget', $args, $instance, 'countdown' );
|
||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
@@ -25,7 +26,7 @@ class SP_Widget_Countdown extends WP_Widget {
|
|||||||
// Action to hook into
|
// Action to hook into
|
||||||
do_action( 'sportspress_before_widget_template', $args, $instance, 'countdown' );
|
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 ) );
|
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 ) );
|
||||||
|
|
||||||
// Action to hook into
|
// Action to hook into
|
||||||
do_action( 'sportspress_after_widget_template', $args, $instance, 'countdown' );
|
do_action( 'sportspress_after_widget_template', $args, $instance, 'countdown' );
|
||||||
@@ -43,6 +44,7 @@ class SP_Widget_Countdown extends WP_Widget {
|
|||||||
$instance['id'] = intval($new_instance['id']);
|
$instance['id'] = intval($new_instance['id']);
|
||||||
$instance['show_venue'] = intval($new_instance['show_venue']);
|
$instance['show_venue'] = intval($new_instance['show_venue']);
|
||||||
$instance['show_league'] = intval($new_instance['show_league']);
|
$instance['show_league'] = intval($new_instance['show_league']);
|
||||||
|
$instance['show_date'] = intval($new_instance['show_date']);
|
||||||
|
|
||||||
// Filter to hook into
|
// Filter to hook into
|
||||||
$instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'countdown' );
|
$instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'countdown' );
|
||||||
@@ -59,6 +61,7 @@ class SP_Widget_Countdown extends WP_Widget {
|
|||||||
$id = intval($instance['id']);
|
$id = intval($instance['id']);
|
||||||
$show_venue = intval($instance['show_venue']);
|
$show_venue = intval($instance['show_venue']);
|
||||||
$show_league = intval($instance['show_league']);
|
$show_league = intval($instance['show_league']);
|
||||||
|
$show_date = intval($instance['show_date']);
|
||||||
|
|
||||||
// Action to hook into
|
// Action to hook into
|
||||||
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'countdown' );
|
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'countdown' );
|
||||||
@@ -129,6 +132,9 @@ class SP_Widget_Countdown extends WP_Widget {
|
|||||||
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_league'); ?>" name="<?php echo $this->get_field_name('show_league'); ?>" value="1" <?php checked( $show_league, 1 ); ?>>
|
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_league'); ?>" name="<?php echo $this->get_field_name('show_league'); ?>" value="1" <?php checked( $show_league, 1 ); ?>>
|
||||||
<label for="<?php echo $this->get_field_id('show_league'); ?>"><?php _e( 'Display league', 'sportspress' ); ?></label></p>
|
<label for="<?php echo $this->get_field_id('show_league'); ?>"><?php _e( 'Display league', 'sportspress' ); ?></label></p>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Action to hook into
|
// Action to hook into
|
||||||
do_action( 'sportspress_after_widget_template_form', $this, $instance, 'countdown' );
|
do_action( 'sportspress_after_widget_template_form', $this, $instance, 'countdown' );
|
||||||
|
|||||||
@@ -106,6 +106,18 @@ if ( $link_events ) $title = '<a href="' . get_post_permalink( $post->ID, false,
|
|||||||
<?php echo $title; ?>
|
<?php echo $title; ?>
|
||||||
</h3>
|
</h3>
|
||||||
<?php
|
<?php
|
||||||
|
if ( isset( $show_date ) && $show_date ):
|
||||||
|
if ( $event_date ):
|
||||||
|
?>
|
||||||
|
<h5 class="event-date sp-event-date">
|
||||||
|
<?php
|
||||||
|
echo get_the_time( get_option( 'date_format', $post ) ).' '.get_the_time( get_option( 'time_format', $post ) ).' (local time)';
|
||||||
|
?>
|
||||||
|
</h5>
|
||||||
|
<?php
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
|
||||||
if ( isset( $show_venue ) && $show_venue ):
|
if ( isset( $show_venue ) && $show_venue ):
|
||||||
$venues = get_the_terms( $post->ID, 'sp_venue' );
|
$venues = get_the_terms( $post->ID, 'sp_venue' );
|
||||||
if ( $venues ):
|
if ( $venues ):
|
||||||
|
|||||||
Reference in New Issue
Block a user