Add "Order" and "Order by" selection fields for countdown widget
This commit is contained in:
@@ -17,6 +17,8 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
$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'];
|
||||
$order = empty($instance['order']) ? false : $instance['order'];
|
||||
$orderby = empty($instance['orderby']) ? false : $instance['orderby'];
|
||||
|
||||
do_action( 'sportspress_before_widget', $args, $instance, 'countdown' );
|
||||
echo $before_widget;
|
||||
@@ -27,7 +29,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, 'show_excluded' => $show_excluded ) );
|
||||
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, 'order' => $order, 'orderby' => $orderby ) );
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template', $args, $instance, 'countdown' );
|
||||
@@ -47,6 +49,8 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
$instance['show_league'] = intval($new_instance['show_league']);
|
||||
$instance['show_date'] = intval($new_instance['show_date']);
|
||||
$instance['show_excluded'] = intval($new_instance['show_excluded']);
|
||||
$instance['order'] = strip_tags($new_instance['order']);
|
||||
$instance['orderby'] = strip_tags($new_instance['orderby']);
|
||||
|
||||
// Filter to hook into
|
||||
$instance = apply_filters( 'sportspress_widget_update', $instance, $new_instance, $old_instance, 'countdown' );
|
||||
@@ -55,7 +59,7 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
}
|
||||
|
||||
function form( $instance ) {
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'calendar' => '', 'team' => '', 'id' => '', 'caption' => '', 'show_venue' => false, 'show_league' => false, 'show_date' => false, 'show_excluded' => false ) );
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'calendar' => '', 'team' => '', 'id' => '', 'caption' => '', 'show_venue' => false, 'show_league' => false, 'show_date' => false, 'show_excluded' => false, 'order' => '', 'orderby' => '' ) );
|
||||
$title = strip_tags($instance['title']);
|
||||
$caption = strip_tags($instance['caption']);
|
||||
$calendar = intval($instance['calendar']);
|
||||
@@ -65,6 +69,8 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
$show_league = intval($instance['show_league']);
|
||||
$show_date = intval($instance['show_date']);
|
||||
$show_excluded = intval($instance['show_excluded']);
|
||||
$order = strip_tags($instance['order']);
|
||||
$orderby = strip_tags($instance['orderby']);
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_before_widget_template_form', $this, $instance, 'countdown' );
|
||||
@@ -92,6 +98,21 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id('orderby'); ?>"><?php printf( __( 'Sort by:', 'sportspress' ) ); ?></label>
|
||||
<select name="<?php echo $this->get_field_name('orderby'); ?>" class="postform widefat">
|
||||
<option value="" <?php selected( 'default', $orderby ); ?>><?php _e( 'Default', 'sportspress' ); ?></option>
|
||||
<option value="date" <?php selected( 'date', $orderby ); ?>><?php _e( 'Date', 'sportspress' ); ?></option>
|
||||
<option value="day" <?php selected( 'day', $orderby ); ?>><?php _e( 'Match Day', 'sportspress' ); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id('order'); ?>"><?php printf( __( 'Sort Order:', 'sportspress' ) ); ?></label>
|
||||
<select name="<?php echo $this->get_field_name('order'); ?>" class="postform widefat">
|
||||
<option value="ASC" <?php selected( 'ASC', $order ); ?>><?php _e( 'Ascending', 'sportspress' ); ?></option>
|
||||
<option value="DESC" <?php selected( 'DESC', $order ); ?>><?php _e( 'Descending', 'sportspress' ); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id('team'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Team', 'sportspress' ) ); ?></label>
|
||||
<?php
|
||||
$args = array(
|
||||
|
||||
@@ -12,6 +12,8 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
$defaults = array(
|
||||
'team' => null,
|
||||
'calendar' => null,
|
||||
'order' => null,
|
||||
'orderby' => null,
|
||||
'league' => null,
|
||||
'season' => null,
|
||||
'id' => null,
|
||||
@@ -40,7 +42,14 @@ elseif ( $calendar ):
|
||||
if ( $team )
|
||||
$calendar->team = $team;
|
||||
$calendar->status = 'future';
|
||||
$calendar->order = 'ASC';
|
||||
if ( $order ) {
|
||||
$calendar->order = $order;
|
||||
}else{
|
||||
$calendar->order = 'ASC';
|
||||
}
|
||||
if ( $orderby ) {
|
||||
$calendar->orderby = $orderby;
|
||||
}
|
||||
$data = $calendar->data();
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user