Add calendar selection to Countdown widget
This commit is contained in:
@@ -10,6 +10,7 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
extract($args);
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? null : $instance['title'], $instance, $this->id_base);
|
||||
$caption = empty($instance['caption']) ? null : $instance['caption'];
|
||||
$calendar = empty($instance['calendar']) ? null : $instance['calendar'];
|
||||
$team = empty($instance['team']) ? null : $instance['team'];
|
||||
$id = empty($instance['id']) ? null : $instance['id'];
|
||||
$show_venue = empty($instance['show_venue']) ? false : $instance['show_venue'];
|
||||
@@ -24,7 +25,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( '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 ) );
|
||||
|
||||
// Action to hook into
|
||||
do_action( 'sportspress_after_widget_template', $args, $instance, 'countdown' );
|
||||
@@ -36,6 +37,7 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
function update( $new_instance, $old_instance ) {
|
||||
$instance = $old_instance;
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['calendar'] = intval($new_instance['calendar']);
|
||||
$instance['team'] = intval($new_instance['team']);
|
||||
$instance['caption'] = strip_tags($new_instance['caption']);
|
||||
$instance['id'] = intval($new_instance['id']);
|
||||
@@ -49,9 +51,10 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
}
|
||||
|
||||
function form( $instance ) {
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'team' => '', 'id' => '', 'caption' => '', 'show_venue' => false, 'show_league' => false ) );
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'calendar' => '', 'team' => '', 'id' => '', 'caption' => '', 'show_venue' => false, 'show_league' => false ) );
|
||||
$title = strip_tags($instance['title']);
|
||||
$caption = strip_tags($instance['caption']);
|
||||
$calendar = intval($instance['calendar']);
|
||||
$team = intval($instance['team']);
|
||||
$id = intval($instance['id']);
|
||||
$show_venue = intval($instance['show_venue']);
|
||||
@@ -65,6 +68,23 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
|
||||
<p><label for="<?php echo $this->get_field_id('caption'); ?>"><?php _e( 'Heading:', 'sportspress' ); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id('caption'); ?>" name="<?php echo $this->get_field_name('caption'); ?>" type="text" value="<?php echo esc_attr($caption); ?>" /></p>
|
||||
|
||||
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id('calendar'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?></label>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_calendar',
|
||||
'name' => $this->get_field_name('calendar'),
|
||||
'id' => $this->get_field_id('calendar'),
|
||||
'selected' => $calendar,
|
||||
'show_option_all' => __( 'All', 'sportspress' ),
|
||||
'values' => 'ID',
|
||||
'class' => 'widefat',
|
||||
);
|
||||
if ( ! sp_dropdown_pages( $args ) ):
|
||||
sp_post_adder( 'sp_calendar', __( 'Add New', 'sportspress' ) );
|
||||
endif;
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p class="sp-dropdown-filter"><label for="<?php echo $this->get_field_id('team'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Team', 'sportspress' ) ); ?></label>
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user