Add team option to countdown widget close #43
This commit is contained in:
@@ -9,19 +9,21 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
function widget( $args, $instance ) {
|
||||
extract($args);
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? null : $instance['title'], $instance, $this->id_base);
|
||||
$team = empty($instance['team']) ? null : $instance['team'];
|
||||
$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_venue' => $show_venue, 'show_league' => $show_league ) );
|
||||
sp_get_template( 'countdown.php', array( 'team' => $team, 'id' => $id, 'show_venue' => $show_venue, 'show_league' => $show_league ) );
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
function update( $new_instance, $old_instance ) {
|
||||
$instance = $old_instance;
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['team'] = intval($new_instance['team']);
|
||||
$instance['id'] = intval($new_instance['id']);
|
||||
$instance['show_venue'] = intval($new_instance['show_venue']);
|
||||
$instance['show_league'] = intval($new_instance['show_league']);
|
||||
@@ -30,8 +32,9 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
}
|
||||
|
||||
function form( $instance ) {
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'show_venue' => false, 'show_league' => false ) );
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'team' => '', 'id' => '', 'show_venue' => false, 'show_league' => false ) );
|
||||
$title = strip_tags($instance['title']);
|
||||
$team = intval($instance['team']);
|
||||
$id = intval($instance['id']);
|
||||
$show_venue = intval($instance['show_venue']);
|
||||
$show_league = intval($instance['show_league']);
|
||||
@@ -39,7 +42,24 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', 'sportspress' ); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Event', 'sportspress' ) ); ?></label>
|
||||
<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(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => $this->get_field_name('team'),
|
||||
'id' => $this->get_field_id('team'),
|
||||
'selected' => $team,
|
||||
'show_option_all' => __( 'All', 'sportspress' ),
|
||||
'values' => 'ID',
|
||||
'class' => 'widefat',
|
||||
);
|
||||
if ( ! sp_dropdown_pages( $args ) ):
|
||||
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||
endif;
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p class="sp-dropdown-target"><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Event', 'sportspress' ) ); ?></label>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_event',
|
||||
@@ -51,6 +71,7 @@ class SP_Widget_Countdown extends WP_Widget {
|
||||
'class' => 'widefat',
|
||||
'show_dates' => true,
|
||||
'post_status' => 'future',
|
||||
'filter' => 'sp_team',
|
||||
);
|
||||
if ( ! sp_dropdown_pages( $args ) ):
|
||||
sp_post_adder( 'sp_event', __( 'Add New', 'sportspress' ) );
|
||||
|
||||
Reference in New Issue
Block a user