Enable selecting date from widgets
This commit is contained in:
@@ -11,13 +11,14 @@ class SP_Widget_Event_Blocks extends WP_Widget {
|
|||||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||||
$id = empty($instance['id']) ? null : $instance['id'];
|
$id = empty($instance['id']) ? null : $instance['id'];
|
||||||
$status = empty($instance['status']) ? 'default' : $instance['status'];
|
$status = empty($instance['status']) ? 'default' : $instance['status'];
|
||||||
|
$date = empty($instance['date']) ? 'default' : $instance['date'];
|
||||||
$number = empty($instance['number']) ? null : $instance['number'];
|
$number = empty($instance['number']) ? null : $instance['number'];
|
||||||
$order = empty($instance['order']) ? 'default' : $instance['order'];
|
$order = empty($instance['order']) ? 'default' : $instance['order'];
|
||||||
$show_all_events_link = empty($instance['show_all_events_link']) ? false : $instance['show_all_events_link'];
|
$show_all_events_link = empty($instance['show_all_events_link']) ? false : $instance['show_all_events_link'];
|
||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
if ( $title )
|
if ( $title )
|
||||||
echo $before_title . $title . $after_title;
|
echo $before_title . $title . $after_title;
|
||||||
sp_get_template( 'event-blocks.php', array( 'id' => $id, 'status' => $status, 'number' => $number, 'order' => $order, 'show_all_events_link' => $show_all_events_link ) );
|
sp_get_template( 'event-blocks.php', array( 'id' => $id, 'status' => $status, 'date' => $date, 'number' => $number, 'order' => $order, 'show_all_events_link' => $show_all_events_link ) );
|
||||||
echo $after_widget;
|
echo $after_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ class SP_Widget_Event_Blocks extends WP_Widget {
|
|||||||
$instance['title'] = strip_tags($new_instance['title']);
|
$instance['title'] = strip_tags($new_instance['title']);
|
||||||
$instance['id'] = intval($new_instance['id']);
|
$instance['id'] = intval($new_instance['id']);
|
||||||
$instance['status'] = $new_instance['status'];
|
$instance['status'] = $new_instance['status'];
|
||||||
|
$instance['date'] = $new_instance['date'];
|
||||||
$instance['number'] = intval($new_instance['number']);
|
$instance['number'] = intval($new_instance['number']);
|
||||||
$instance['order'] = strip_tags($new_instance['order']);
|
$instance['order'] = strip_tags($new_instance['order']);
|
||||||
$instance['show_all_events_link'] = $new_instance['show_all_events_link'];
|
$instance['show_all_events_link'] = $new_instance['show_all_events_link'];
|
||||||
@@ -34,10 +36,11 @@ class SP_Widget_Event_Blocks extends WP_Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function form( $instance ) {
|
function form( $instance ) {
|
||||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'status' => 'default', 'number' => 5, 'order' => 'default', 'show_all_events_link' => true ) );
|
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'status' => 'default', 'date' => 'default', 'number' => 5, 'order' => 'default', 'show_all_events_link' => true ) );
|
||||||
$title = strip_tags($instance['title']);
|
$title = strip_tags($instance['title']);
|
||||||
$id = intval($instance['id']);
|
$id = intval($instance['id']);
|
||||||
$status = $instance['status'];
|
$status = $instance['status'];
|
||||||
|
$date = $instance['date'];
|
||||||
$number = intval($instance['number']);
|
$number = intval($instance['number']);
|
||||||
$order = strip_tags($instance['order']);
|
$order = strip_tags($instance['order']);
|
||||||
$show_all_events_link = $instance['show_all_events_link'];
|
$show_all_events_link = $instance['show_all_events_link'];
|
||||||
@@ -75,6 +78,19 @@ class SP_Widget_Event_Blocks extends WP_Widget {
|
|||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p><label for="<?php echo $this->get_field_id('date'); ?>"><?php _e( 'Date:', 'sportspress' ); ?></label>
|
||||||
|
<?php
|
||||||
|
$args = array(
|
||||||
|
'show_option_default' => __( 'Default', 'sportspress' ),
|
||||||
|
'name' => $this->get_field_name('date'),
|
||||||
|
'id' => $this->get_field_id('date'),
|
||||||
|
'selected' => $date,
|
||||||
|
'class' => 'sp-event-date-select widefat',
|
||||||
|
);
|
||||||
|
sp_dropdown_dates( $args );
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of events to show:', 'sportspress' ); ?></label>
|
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of events to show:', 'sportspress' ); ?></label>
|
||||||
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
|
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class SP_Widget_Event_List extends WP_Widget {
|
|||||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||||
$id = empty($instance['id']) ? null : $instance['id'];
|
$id = empty($instance['id']) ? null : $instance['id'];
|
||||||
$status = empty($instance['status']) ? 'default' : $instance['status'];
|
$status = empty($instance['status']) ? 'default' : $instance['status'];
|
||||||
|
$date = empty($instance['date']) ? 'default' : $instance['date'];
|
||||||
$number = empty($instance['number']) ? null : $instance['number'];
|
$number = empty($instance['number']) ? null : $instance['number'];
|
||||||
$columns = empty($instance['columns']) ? null : $instance['columns'];
|
$columns = empty($instance['columns']) ? null : $instance['columns'];
|
||||||
$order = empty($instance['order']) ? 'default' : $instance['order'];
|
$order = empty($instance['order']) ? 'default' : $instance['order'];
|
||||||
@@ -18,7 +19,7 @@ class SP_Widget_Event_List extends WP_Widget {
|
|||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
if ( $title )
|
if ( $title )
|
||||||
echo $before_title . $title . $after_title;
|
echo $before_title . $title . $after_title;
|
||||||
sp_get_template( 'event-list.php', array( 'id' => $id, 'status' => $status, 'number' => $number, 'columns' => $columns, 'order' => $order, 'show_all_events_link' => $show_all_events_link ) );
|
sp_get_template( 'event-list.php', array( 'id' => $id, 'status' => $status, 'date' => $date, 'number' => $number, 'columns' => $columns, 'order' => $order, 'show_all_events_link' => $show_all_events_link ) );
|
||||||
echo $after_widget;
|
echo $after_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ class SP_Widget_Event_List extends WP_Widget {
|
|||||||
$instance['title'] = strip_tags($new_instance['title']);
|
$instance['title'] = strip_tags($new_instance['title']);
|
||||||
$instance['id'] = intval($new_instance['id']);
|
$instance['id'] = intval($new_instance['id']);
|
||||||
$instance['status'] = $new_instance['status'];
|
$instance['status'] = $new_instance['status'];
|
||||||
|
$instance['date'] = $new_instance['date'];
|
||||||
$instance['number'] = intval($new_instance['number']);
|
$instance['number'] = intval($new_instance['number']);
|
||||||
$instance['columns'] = (array)$new_instance['columns'];
|
$instance['columns'] = (array)$new_instance['columns'];
|
||||||
$instance['order'] = strip_tags($new_instance['order']);
|
$instance['order'] = strip_tags($new_instance['order']);
|
||||||
@@ -36,10 +38,11 @@ class SP_Widget_Event_List extends WP_Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function form( $instance ) {
|
function form( $instance ) {
|
||||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'status' => 'default', 'number' => 5, 'columns' => null, 'order' => 'default', 'show_all_events_link' => true ) );
|
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'status' => 'default', 'date' => 'default', 'number' => 5, 'columns' => null, 'order' => 'default', 'show_all_events_link' => true ) );
|
||||||
$title = strip_tags($instance['title']);
|
$title = strip_tags($instance['title']);
|
||||||
$id = intval($instance['id']);
|
$id = intval($instance['id']);
|
||||||
$status = $instance['status'];
|
$status = $instance['status'];
|
||||||
|
$date = $instance['date'];
|
||||||
$number = intval($instance['number']);
|
$number = intval($instance['number']);
|
||||||
$columns = $instance['columns'];
|
$columns = $instance['columns'];
|
||||||
$order = strip_tags($instance['order']);
|
$order = strip_tags($instance['order']);
|
||||||
@@ -78,6 +81,19 @@ class SP_Widget_Event_List extends WP_Widget {
|
|||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p><label for="<?php echo $this->get_field_id('date'); ?>"><?php _e( 'Date:', 'sportspress' ); ?></label>
|
||||||
|
<?php
|
||||||
|
$args = array(
|
||||||
|
'show_option_default' => __( 'Default', 'sportspress' ),
|
||||||
|
'name' => $this->get_field_name('date'),
|
||||||
|
'id' => $this->get_field_id('date'),
|
||||||
|
'selected' => $date,
|
||||||
|
'class' => 'sp-event-date-select widefat',
|
||||||
|
);
|
||||||
|
sp_dropdown_dates( $args );
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of events to show:', 'sportspress' ); ?></label>
|
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of events to show:', 'sportspress' ); ?></label>
|
||||||
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
|
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @author ThemeBoy
|
* @author ThemeBoy
|
||||||
* @package SportsPress/Templates
|
* @package SportsPress/Templates
|
||||||
* @version 0.8
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
@@ -13,6 +13,7 @@ $primary_result = get_option( 'sportspress_primary_result', null );
|
|||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'status' => 'default',
|
'status' => 'default',
|
||||||
|
'date' => 'default',
|
||||||
'number' => -1,
|
'number' => -1,
|
||||||
'link_teams' => get_option( 'sportspress_calendar_link_teams', 'no' ) == 'yes' ? true : false,
|
'link_teams' => get_option( 'sportspress_calendar_link_teams', 'no' ) == 'yes' ? true : false,
|
||||||
'paginated' => get_option( 'sportspress_calendar_paginated', 'yes' ) == 'yes' ? true : false,
|
'paginated' => get_option( 'sportspress_calendar_paginated', 'yes' ) == 'yes' ? true : false,
|
||||||
@@ -26,6 +27,8 @@ extract( $defaults, EXTR_SKIP );
|
|||||||
$calendar = new SP_Calendar( $id );
|
$calendar = new SP_Calendar( $id );
|
||||||
if ( $status != 'default' )
|
if ( $status != 'default' )
|
||||||
$calendar->status = $status;
|
$calendar->status = $status;
|
||||||
|
if ( $date != 'default' )
|
||||||
|
$calendar->date = $date;
|
||||||
if ( $order != 'default' )
|
if ( $order != 'default' )
|
||||||
$calendar->order = $order;
|
$calendar->order = $order;
|
||||||
$data = $calendar->data();
|
$data = $calendar->data();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @author ThemeBoy
|
* @author ThemeBoy
|
||||||
* @package SportsPress/Templates
|
* @package SportsPress/Templates
|
||||||
* @version 0.8
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
@@ -91,7 +91,7 @@ $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS yea
|
|||||||
/* translators: Calendar caption: 1: month name, 2: 4-digit year */
|
/* translators: Calendar caption: 1: month name, 2: 4-digit year */
|
||||||
$calendar_caption = _x('%1$s %2$s', 'calendar caption', 'sportspress');
|
$calendar_caption = _x('%1$s %2$s', 'calendar caption', 'sportspress');
|
||||||
$calendar_output = '
|
$calendar_output = '
|
||||||
<div class="widget_calendar sp-calendar-wrapper">
|
<div class="sp-calendar-wrapper">
|
||||||
<table id="wp-calendar" class="sp-calendar sp-event-calendar">
|
<table id="wp-calendar" class="sp-calendar sp-event-calendar">
|
||||||
<caption class="sp-table-caption">' . ( $caption_tag == 'caption' ? '' : '<' . $caption_tag . '>' ) . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . ( $caption_tag == 'caption' ? '' : '</' . $caption_tag . '>' ) . '</caption>
|
<caption class="sp-table-caption">' . ( $caption_tag == 'caption' ? '' : '<' . $caption_tag . '>' ) . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . ( $caption_tag == 'caption' ? '' : '</' . $caption_tag . '>' ) . '</caption>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @author ThemeBoy
|
* @author ThemeBoy
|
||||||
* @package SportsPress/Templates
|
* @package SportsPress/Templates
|
||||||
* @version 0.8
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
@@ -13,6 +13,7 @@ $primary_result = get_option( 'sportspress_primary_result', null );
|
|||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'status' => 'default',
|
'status' => 'default',
|
||||||
|
'date' => 'default',
|
||||||
'number' => -1,
|
'number' => -1,
|
||||||
'link_teams' => get_option( 'sportspress_calendar_link_teams', 'no' ) == 'yes' ? true : false,
|
'link_teams' => get_option( 'sportspress_calendar_link_teams', 'no' ) == 'yes' ? true : false,
|
||||||
'link_venues' => get_option( 'sportspress_calendar_link_venues', 'yes' ) == 'yes' ? true : false,
|
'link_venues' => get_option( 'sportspress_calendar_link_venues', 'yes' ) == 'yes' ? true : false,
|
||||||
@@ -29,6 +30,8 @@ extract( $defaults, EXTR_SKIP );
|
|||||||
$calendar = new SP_Calendar( $id );
|
$calendar = new SP_Calendar( $id );
|
||||||
if ( $status != 'default' )
|
if ( $status != 'default' )
|
||||||
$calendar->status = $status;
|
$calendar->status = $status;
|
||||||
|
if ( $date != 'default' )
|
||||||
|
$calendar->date = $date;
|
||||||
if ( $order != 'default' )
|
if ( $order != 'default' )
|
||||||
$calendar->order = $order;
|
$calendar->order = $order;
|
||||||
$data = $calendar->data();
|
$data = $calendar->data();
|
||||||
|
|||||||
Reference in New Issue
Block a user