From 775ac5cb2fe6dab9ad16b84981dfee241fb26ee3 Mon Sep 17 00:00:00 2001
From: savvasha
Date: Wed, 31 Mar 2021 12:38:56 +0300
Subject: [PATCH] Add "Order" and "Order by" selection fields for countdown
widget
---
.../widgets/class-sp-widget-countdown.php | 25 +++++++++++++++++--
templates/countdown.php | 11 +++++++-
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/includes/widgets/class-sp-widget-countdown.php b/includes/widgets/class-sp-widget-countdown.php
index 873da460..69e7961d 100644
--- a/includes/widgets/class-sp-widget-countdown.php
+++ b/includes/widgets/class-sp-widget-countdown.php
@@ -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' );
@@ -91,6 +97,21 @@ class SP_Widget_Countdown extends WP_Widget {
endif;
?>
+
+
+
+
+
+
+
+
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();
/**