Countdown widget options
This commit is contained in:
@@ -2,7 +2,8 @@
|
|||||||
if ( !function_exists( 'sportspress_countdown' ) ) {
|
if ( !function_exists( 'sportspress_countdown' ) ) {
|
||||||
function sportspress_countdown( $args = array() ) {
|
function sportspress_countdown( $args = array() ) {
|
||||||
|
|
||||||
$id = sportspress_array_value( $args, 'id', null );
|
$id = sportspress_array_value( $args, 'event', null );
|
||||||
|
$show_league = sportspress_array_value( $args, 'show_league', null );
|
||||||
|
|
||||||
if ( $id ):
|
if ( $id ):
|
||||||
$post = get_post( $id );
|
$post = get_post( $id );
|
||||||
@@ -27,24 +28,26 @@ if ( !function_exists( 'sportspress_countdown' ) ) {
|
|||||||
$output .= '<div id="sp_countdown_wrap">';
|
$output .= '<div id="sp_countdown_wrap">';
|
||||||
$output .= '<h3 class="event-name"><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h3>';
|
$output .= '<h3 class="event-name"><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h3>';
|
||||||
|
|
||||||
$leagues = get_the_terms( $post->ID, 'sp_league' );
|
if ( $show_league ):
|
||||||
if ( $leagues ):
|
$leagues = get_the_terms( $post->ID, 'sp_league' );
|
||||||
foreach( $leagues as $league ):
|
if ( $leagues ):
|
||||||
$term = get_term( $league->term_id, 'sp_league' );
|
foreach( $leagues as $league ):
|
||||||
$output .= '<h5 class="event-league">' . $term->name . '</h5>';
|
$term = get_term( $league->term_id, 'sp_league' );
|
||||||
endforeach;
|
$output .= '<h5 class="event-league">' . $term->name . '</h5>';
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$now = new DateTime( current_time( 'mysql', 0 ) );
|
$now = new DateTime( current_time( 'mysql', 0 ) );
|
||||||
$date = new DateTime( $post->post_date );
|
$date = new DateTime( $post->post_date );
|
||||||
$interval = date_diff( $now, $date );
|
$interval = date_diff( $now, $date );
|
||||||
|
|
||||||
$output .= '<h3 class="countdown sp-countdown"><time datetime="' . $post->post_date . '" data-countdown="' . str_replace( '-', '/', $post->post_date ) . '">' .
|
$output .= '<p class="countdown sp-countdown"><time datetime="' . $post->post_date . '" data-countdown="' . str_replace( '-', '/', $post->post_date ) . '">' .
|
||||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->d ) ) . ' <small>' . __( 'days', 'sportspress' ) . '</small></span> ' .
|
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->d ) ) . ' <small>' . __( 'days', 'sportspress' ) . '</small></span> ' .
|
||||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->h ) ) . ' <small>' . __( 'hrs', 'sportspress' ) . '</small></span> ' .
|
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->h ) ) . ' <small>' . __( 'hrs', 'sportspress' ) . '</small></span> ' .
|
||||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->i ) ) . ' <small>' . __( 'mins', 'sportspress' ) . '</small></span> ' .
|
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->i ) ) . ' <small>' . __( 'mins', 'sportspress' ) . '</small></span> ' .
|
||||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->s ) ) . ' <small>' . __( 'secs', 'sportspress' ) . '</small></span>' .
|
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->s ) ) . ' <small>' . __( 'secs', 'sportspress' ) . '</small></span>' .
|
||||||
'</time></h3>';
|
'</time></p>';
|
||||||
|
|
||||||
$output .= '</div>';
|
$output .= '</div>';
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -8,9 +8,8 @@ class SP_Widget_Countdown extends WP_Widget {
|
|||||||
|
|
||||||
function widget( $args, $instance ) {
|
function widget( $args, $instance ) {
|
||||||
extract($args);
|
extract($args);
|
||||||
$title = apply_filters('widget_title', empty($instance['title']) ? __( 'Countdown', 'sportspress' ) : $instance['title'], $instance, $this->id_base);
|
$title = apply_filters('widget_title', empty($instance['title']) ? null : $instance['title'], $instance, $this->id_base);
|
||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
$id = empty($instance['id']) ? null : $instance['id'];
|
|
||||||
if ( $title )
|
if ( $title )
|
||||||
echo $before_title . $title . $after_title;
|
echo $before_title . $title . $after_title;
|
||||||
echo sportspress_countdown( $instance );
|
echo sportspress_countdown( $instance );
|
||||||
@@ -20,26 +19,28 @@ class SP_Widget_Countdown extends WP_Widget {
|
|||||||
function update( $new_instance, $old_instance ) {
|
function update( $new_instance, $old_instance ) {
|
||||||
$instance = $old_instance;
|
$instance = $old_instance;
|
||||||
$instance['title'] = strip_tags($new_instance['title']);
|
$instance['title'] = strip_tags($new_instance['title']);
|
||||||
$instance['id'] = intval($new_instance['id']);
|
$instance['event'] = intval($new_instance['event']);
|
||||||
|
$instance['show_league'] = intval($new_instance['show_league']);
|
||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
function form( $instance ) {
|
function form( $instance ) {
|
||||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '' ) );
|
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'event' => '', 'show_league' => 0 ) );
|
||||||
$title = strip_tags($instance['title']);
|
$title = strip_tags($instance['title']);
|
||||||
$id = intval($instance['id']);
|
$event = intval($instance['event']);
|
||||||
|
$show_league = intval($instance['show_league']);
|
||||||
?>
|
?>
|
||||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', 'sportspress' ); ?></label>
|
<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>
|
<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 _e( 'Event:', 'sportspress' ); ?></label>
|
<p><label for="<?php echo $this->get_field_id('event'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Event', 'sportspress' ) ); ?></label>
|
||||||
<?php
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_event',
|
'post_type' => 'sp_event',
|
||||||
'name' => $this->get_field_name('id'),
|
'name' => $this->get_field_name('event'),
|
||||||
'id' => $this->get_field_id('id'),
|
'id' => $this->get_field_id('event'),
|
||||||
'selected' => $id,
|
'selected' => $event,
|
||||||
'show_option_all' => __( '(Auto)', 'sportspress' ),
|
'show_option_all' => __( '(Auto)', 'sportspress' ),
|
||||||
'values' => 'ID',
|
'values' => 'ID',
|
||||||
'class' => 'widefat',
|
'class' => 'widefat',
|
||||||
@@ -51,6 +52,9 @@ class SP_Widget_Countdown extends WP_Widget {
|
|||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_league'); ?>" name="<?php echo $this->get_field_name('show_league'); ?>" value="1" <?php checked( $show_league, 1 ); ?>>
|
||||||
|
<label for="<?php echo $this->get_field_id('show_league'); ?>"><?php printf( __( 'Display %s', 'sportspress' ), __( 'League', 'sportspress' ) ); ?></label></p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class SportsPress_Widget_League_Table extends WP_Widget {
|
|||||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', 'sportspress' ); ?></label>
|
<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>
|
<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 _e( 'League Table:', 'sportspress' ); ?></label>
|
<p><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'League Table', 'sportspress' ) ); ?></label>
|
||||||
<?php
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_table',
|
'post_type' => 'sp_table',
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class SportsPress_Widget_Player_list extends WP_Widget {
|
|||||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', 'sportspress' ); ?></label>
|
<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>
|
<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 _e( 'Player List:', 'sportspress' ); ?></label>
|
<p><label for="<?php echo $this->get_field_id('id'); ?>"><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Player List', 'sportspress' ) ); ?></label>
|
||||||
<?php
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_list',
|
'post_type' => 'sp_list',
|
||||||
|
|||||||
11
readme.txt
11
readme.txt
@@ -4,7 +4,7 @@ Tags: sports, sports journalism, teams, team management, fixtures, results, stan
|
|||||||
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=support@themeboy.com&item_name=Donation+for+SportsPress
|
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=support@themeboy.com&item_name=Donation+for+SportsPress
|
||||||
Requires at least: 3.8
|
Requires at least: 3.8
|
||||||
Tested up to: 3.8.1
|
Tested up to: 3.8.1
|
||||||
Stable tag: 0.2.9
|
Stable tag: 0.2.10
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
@@ -88,9 +88,18 @@ SportsPress is currently in beta and is undergoing testing. We are still activel
|
|||||||
3. Players admin.
|
3. Players admin.
|
||||||
4. SportsPress Settings panel.
|
4. SportsPress Settings panel.
|
||||||
5. League Table widget.
|
5. League Table widget.
|
||||||
|
6. Player List widget.
|
||||||
|
7. Events Calendar widget.
|
||||||
|
8. Countdown widget.
|
||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 0.2.10 =
|
||||||
|
* Fix - Team filtering in events, tables, players, and lists.
|
||||||
|
* Tweak - Display statistics for all league/season events played in player profiles and player lists.
|
||||||
|
* Tweak - Count events as played when in starting lineup or made substitution.
|
||||||
|
* Tweak - Display player metrics only when value is set.
|
||||||
|
|
||||||
= 0.2.9 =
|
= 0.2.9 =
|
||||||
* Feature - Ability to select players from all teams in player list.
|
* Feature - Ability to select players from all teams in player list.
|
||||||
* Fix - Decimal sorting in league tables and player lists.
|
* Fix - Decimal sorting in league tables and player lists.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
Plugin Name: SportsPress
|
Plugin Name: SportsPress
|
||||||
Plugin URI: http://themeboy.com/sportspress
|
Plugin URI: http://themeboy.com/sportspress
|
||||||
Description: Manage your club and its players, staff, events, league tables, and player lists.
|
Description: Manage your club and its players, staff, events, league tables, and player lists.
|
||||||
Version: 0.2.9
|
Version: 0.2.10
|
||||||
Author: ThemeBoy
|
Author: ThemeBoy
|
||||||
Author URI: http://themeboy.com/
|
Author URI: http://themeboy.com/
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
@@ -18,7 +18,7 @@ if ( !function_exists( 'add_action' ) ) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
define( 'SPORTSPRESS_VERSION', '0.2.9' );
|
define( 'SPORTSPRESS_VERSION', '0.2.10' );
|
||||||
define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||||
define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
||||||
define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ );
|
define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ );
|
||||||
|
|||||||
Reference in New Issue
Block a user