Show venue option in countdown widget
This commit is contained in:
@@ -10,11 +10,12 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
extract($args);
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? null : $instance['title'], $instance, $this->id_base);
|
||||
$id = empty($instance['id']) ? null : $instance['id'];
|
||||
$show_venue = empty($instance['show_venue']) ? false : $instance['show_venue'];
|
||||
$show_league = empty($instance['show_league']) ? false : $instance['show_league'];
|
||||
echo $before_widget;
|
||||
if ( $title )
|
||||
echo $before_title . $title . $after_title;
|
||||
sp_get_template( 'countdown.php', array( 'id' => $id, 'show_league' => $show_league ) );
|
||||
sp_get_template( 'countdown.php', array( 'id' => $id, 'show_venue' => $show_venue, 'show_league' => $show_league ) );
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
@@ -22,15 +23,17 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
$instance = $old_instance;
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['id'] = intval($new_instance['id']);
|
||||
$instance['show_venue'] = intval($new_instance['show_venue']);
|
||||
$instance['show_league'] = intval($new_instance['show_league']);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
function form( $instance ) {
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'show_league' => false ) );
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'show_venue' => false, 'show_league' => false ) );
|
||||
$title = strip_tags($instance['title']);
|
||||
$id = intval($instance['id']);
|
||||
$show_venue = intval($instance['show_venue']);
|
||||
$show_league = intval($instance['show_league']);
|
||||
?>
|
||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', 'sportspress' ); ?></label>
|
||||
@@ -55,6 +58,9 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_venue'); ?>" name="<?php echo $this->get_field_name('show_venue'); ?>" value="1" <?php checked( $show_venue, 1 ); ?>>
|
||||
<label for="<?php echo $this->get_field_id('show_venue'); ?>"><?php _e( 'Display venue', 'sportspress' ); ?></label></p>
|
||||
|
||||
<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>
|
||||
<?php
|
||||
|
||||
@@ -30,8 +30,13 @@ if ( ! isset( $post ) ) return;
|
||||
<div id="sp-countdown-wrapper">
|
||||
<h3 class="event-name"><a href="<?php echo get_permalink( $post->ID ); ?>"><?php echo $post->post_title; ?></a></h3>
|
||||
<?php
|
||||
if ( true || isset( $show_venue ) && $show_venue ):
|
||||
the_terms( $post->ID, 'sp_venue' );
|
||||
if ( isset( $show_venue ) && $show_venue ):
|
||||
$venues = get_the_terms( $post->ID, 'sp_venue' );
|
||||
if ( $venues ):
|
||||
?>
|
||||
<h5 class="event-venue"><?php the_terms( $post->ID, 'sp_venue' ); ?></h5>
|
||||
<?php
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( isset( $show_league ) && $show_league ):
|
||||
@@ -49,11 +54,16 @@ if ( ! isset( $post ) ) return;
|
||||
$now = new DateTime( current_time( 'mysql', 0 ) );
|
||||
$date = new DateTime( $post->post_date );
|
||||
$interval = date_diff( $now, $date );
|
||||
|
||||
$days = $interval->invert ? 0 : $interval->days;
|
||||
$h = $interval->invert ? 0 : $interval->h;
|
||||
$i = $interval->invert ? 0 : $interval->i;
|
||||
$s = $interval->invert ? 0 : $interval->s;
|
||||
?>
|
||||
<p class="countdown sp-countdown"><time datetime="<?php echo $post->post_date; ?>"<?php if ( $live ): ?> data-countdown="<?php echo str_replace( '-', '/', $post->post_date ); ?>"<?php endif; ?>>
|
||||
<span><?php echo sprintf( '%02s', ( $interval->invert ? 0 : $interval->days ) ); ?> <small><?php echo __( 'days', 'sportspress' ); ?></small></span>
|
||||
<span><?php echo sprintf( '%02s', ( $interval->invert ? 0 : $interval->h ) ); ?> <small><?php echo __( 'hrs', 'sportspress' ); ?></small></span>
|
||||
<span><?php echo sprintf( '%02s', ( $interval->invert ? 0 : $interval->i ) ); ?> <small><?php echo __( 'mins', 'sportspress' ); ?></small></span>
|
||||
<span><?php echo sprintf( '%02s', ( $interval->invert ? 0 : $interval->s ) ); ?> <small><?php echo __( 'secs', 'sportspress' ); ?></small></span>
|
||||
<p class="countdown sp-countdown<?php if ( $days >= 10 ): ?> long-countdown<?php endif; ?>"><time datetime="<?php echo $post->post_date; ?>"<?php if ( $live ): ?> data-countdown="<?php echo str_replace( '-', '/', $post->post_date ); ?>"<?php endif; ?>>
|
||||
<span><?php echo sprintf( '%02s', $days ); ?> <small><?php echo __( 'days', 'sportspress' ); ?></small></span>
|
||||
<span><?php echo sprintf( '%02s', $h ); ?> <small><?php echo __( 'hrs', 'sportspress' ); ?></small></span>
|
||||
<span><?php echo sprintf( '%02s', $i ); ?> <small><?php echo __( 'mins', 'sportspress' ); ?></small></span>
|
||||
<span><?php echo sprintf( '%02s', $s ); ?> <small><?php echo __( 'secs', 'sportspress' ); ?></small></span>
|
||||
</time></p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user