diff --git a/admin/templates/events.php b/admin/templates/events.php index aeee8542..3b3e59bb 100644 --- a/admin/templates/events.php +++ b/admin/templates/events.php @@ -13,8 +13,9 @@ if ( !function_exists( 'sportspress_events' ) ) { $options['posts_per_page'] = $args['number']; endif; - if ( isset( $args['status'] ) && $args['status'] == 'any' || $args['status'] == 'scheduled' ): - $options['post_status'] = array( 'publish', 'future' ); + if ( isset( $args['status'] ) && $args['status'] == 'future' ): + $options['post_status'] = array( 'future' ); + $options['order'] = 'ASC'; endif; if ( isset( $args['league'] ) ): diff --git a/admin/widgets/countdown-timer.php b/admin/widgets/countdown-timer.php new file mode 100644 index 00000000..7e5c38f1 --- /dev/null +++ b/admin/widgets/countdown-timer.php @@ -0,0 +1,91 @@ + 'widget_countdown_timer widget_sp_countdown_timer', 'description' => __( 'SportsPress widget.', 'sportspress' ) ); + parent::__construct('sp_countdown_timer', __( 'Countdown Timer', 'sportspress' ), $widget_ops); + } + + function widget( $args, $instance ) { + extract($args); + $title = apply_filters('widget_title', empty($instance['title']) ? __( 'Countdown Timer', 'sportspress' ) : $instance['title'], $instance, $this->id_base); + echo $before_widget; + $id = empty($instance['id']) ? null : $instance['id']; + if ( $title ) + echo $before_title . $title . $after_title; + if ( $id ) + $post = get_post( $id ); + if ( isset( $post ) ): + echo '
+
+ ++ 'sp_event', + 'name' => $this->get_field_name('id'), + 'id' => $this->get_field_id('id'), + 'selected' => $id, + 'show_option_none' => '(' . __( 'Next Event', 'premier' ) . ')', + 'values' => 'ID', + 'class' => 'widefat', + 'show_dates' => true, + 'post_status' => 'future', + ); + if ( ! sportspress_dropdown_pages( $args ) ): + sportspress_post_adder( 'sp_event' ); + endif; + ?> +
+ 'widget_calendar widget_sp_calendar', 'description' => __( 'SportsPress widget.', 'sportspress' ) ); - parent::__construct('sp_calendar', __( 'Events Calendar', 'sportspress' ), $widget_ops); + $widget_ops = array('classname' => 'widget_calendar widget_sp_events_calendar', 'description' => __( 'SportsPress widget.', 'sportspress' ) ); + parent::__construct('sp_events_calendar', __( 'Events Calendar', 'sportspress' ), $widget_ops); } function widget( $args, $instance ) { @@ -34,4 +34,4 @@ class SportsPress_Widget_Calendar extends WP_Widget { 'widget_recent_entries widget_sp_events', 'description' => __( 'SportsPress widget.', 'sportspress' ) ); - parent::__construct('sp_events', __( 'Events', 'sportspress' ), $widget_ops); + $widget_ops = array('classname' => 'widget_recent_entries widget_sp_future_events', 'description' => __( 'SportsPress widget.', 'sportspress' ) ); + parent::__construct('sp_future_events', __( 'Future Events', 'sportspress' ), $widget_ops); } function widget( $args, $instance ) { extract($args); - $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); - $status = empty($instance['status']) ? null : $instance['status']; + $title = apply_filters('widget_title', empty($instance['title']) ? __( 'Future Events' ) : $instance['title'], $instance, $this->id_base); $league = empty($instance['league']) ? null : $instance['league']; $season = empty($instance['season']) ? null : $instance['season']; $venue = empty($instance['venue']) ? null : $instance['venue']; $team = empty($instance['team']) ? null : $instance['team']; $number = empty($instance['number']) ? get_option( 'posts_per_page' ) : $instance['number']; $args = array( - 'status' => $status, + 'status' => 'future', 'league' => $league, 'season' => $season, 'venue' => $venue, @@ -26,7 +25,7 @@ class SportsPress_Widget_Events extends WP_Widget { echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; - echo '-
- __( 'Any', 'sportspress' ), - 'played' => __( 'Played', 'sportspress' ), - 'scheduled' => __( 'Scheduled', 'sportspress' ), - ); - ?> - -
'widget_league_table widget_sp_league_table', 'description' => __( 'SportsPress widget.', 'sportspress' ) ); - parent::__construct('sp_table', __( 'League Table', 'sportspress' ), $widget_ops); + parent::__construct('sp_league_table', __( 'League Table', 'sportspress' ), $widget_ops); } function widget( $args, $instance ) { diff --git a/admin/widgets/recent-events.php b/admin/widgets/recent-events.php new file mode 100644 index 00000000..c70b9297 --- /dev/null +++ b/admin/widgets/recent-events.php @@ -0,0 +1,128 @@ + 'widget_recent_entries widget_sp_recent_events', 'description' => __( 'SportsPress widget.', 'sportspress' ) ); + parent::__construct('sp_recent_events', __( 'Recent Events', 'sportspress' ), $widget_ops); + } + + function widget( $args, $instance ) { + extract($args); + $title = apply_filters('widget_title', empty($instance['title']) ? __( 'Recent Events' ) : $instance['title'], $instance, $this->id_base); + $league = empty($instance['league']) ? null : $instance['league']; + $season = empty($instance['season']) ? null : $instance['season']; + $venue = empty($instance['venue']) ? null : $instance['venue']; + $team = empty($instance['team']) ? null : $instance['team']; + $number = empty($instance['number']) ? get_option( 'posts_per_page' ) : $instance['number']; + $args = array( + 'status' => 'publish', + 'league' => $league, + 'season' => $season, + 'venue' => $venue, + 'team' => $team, + 'number' => $number, + ); + echo $before_widget; + if ( $title ) + echo $before_title . $title . $after_title; + echo '
+
+ ++ 'sp_league', + 'name' => $this->get_field_name('league'), + 'id' => $this->get_field_id('league'), + 'selected' => $league, + 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), + 'hide_empty' => 0, + 'values' => 'term_id', + 'class' => 'widefat', + ); + wp_dropdown_categories( $args ); + ?> +
+ ++ 'sp_season', + 'name' => $this->get_field_name('season'), + 'id' => $this->get_field_id('season'), + 'selected' => $season, + 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ), + 'hide_empty' => 0, + 'values' => 'term_id', + 'class' => 'widefat', + ); + wp_dropdown_categories( $args ); + ?> +
+ ++ 'sp_venue', + 'name' => $this->get_field_name('venue'), + 'id' => $this->get_field_id('venue'), + 'selected' => $venue, + 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Venues', 'sportspress' ) ), + 'hide_empty' => 0, + 'values' => 'term_id', + 'class' => 'widefat', + ); + wp_dropdown_categories( $args ); + ?> +
+ ++ 'sp_team', + 'name' => $this->get_field_name('team'), + 'id' => $this->get_field_id('team'), + 'selected' => $team, + 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ), + 'values' => 'ID', + 'class' => 'widefat', + ); + if ( ! sportspress_dropdown_pages( $args ) ): + sportspress_post_adder( 'sp_table' ); + endif; + ?> +
+ ++
+ false, 'show_option_none' => false, + 'show_dates' => false, 'option_all_value' => 0, 'option_none_value' => -1, 'name' => 'page_id', @@ -270,15 +271,16 @@ if ( !function_exists( 'sportspress_dropdown_pages' ) ) { 'posts_per_page' => -1, 'child_of' => 0, 'sort_order' => 'ASC', - 'sort_column' => 'post_title', + 'sort_column' => 'post_title', 'hierarchical' => 1, - 'exclude' => null, - 'include' => null, - 'meta_key' => null, - 'meta_value' => null, - 'authors' => null, + 'exclude' => null, + 'include' => null, + 'meta_key' => null, + 'meta_value' => null, + 'authors' => null, 'exclude_tree' => null, 'post_type' => 'page', + 'post_status' => 'publish', 'values' => 'post_name', 'class' => null, ); @@ -292,19 +294,21 @@ if ( !function_exists( 'sportspress_dropdown_pages' ) ) { $posts = get_posts( $args ); if ( $posts ): printf( '' ); return true; else: diff --git a/sportspress.php b/sportspress.php index 0eee5009..1447fc2d 100644 --- a/sportspress.php +++ b/sportspress.php @@ -24,12 +24,12 @@ define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ ); // Libraries -include dirname( __FILE__ ) . '/lib/eos/eos.class.php' ; +require_once dirname( __FILE__ ) . '/lib/eos/eos.class.php' ; // Globals -include_once dirname( __FILE__ ) . '/admin/globals/continents.php'; -include_once dirname( __FILE__ ) . '/admin/globals/countries.php'; -include_once dirname( __FILE__ ) . '/admin/globals/sports.php'; +require_once dirname( __FILE__ ) . '/admin/globals/continents.php'; +require_once dirname( __FILE__ ) . '/admin/globals/countries.php'; +require_once dirname( __FILE__ ) . '/admin/globals/sports.php'; // Functions require_once dirname( __FILE__ ) . '/functions.php'; @@ -50,7 +50,7 @@ require_once dirname( __FILE__ ) . '/admin/templates/player-statistics.php'; require_once dirname( __FILE__ ) . '/admin/templates/team-columns.php'; // Settings -include dirname( __FILE__ ) . '/admin/settings/settings.php' ; +require_once dirname( __FILE__ ) . '/admin/settings/settings.php' ; // Custom post types require_once dirname( __FILE__ ) . '/admin/post-types/separator.php'; @@ -73,9 +73,11 @@ require_once dirname( __FILE__ ) . '/admin/terms/venue.php'; require_once dirname( __FILE__ ) . '/admin/terms/position.php'; // Widgets -require_once dirname( __FILE__ ) . '/admin/widgets/events.php'; -require_once dirname( __FILE__ ) . '/admin/widgets/calendar.php'; -require_once dirname( __FILE__ ) . '/admin/widgets/table.php'; +require_once dirname( __FILE__ ) . '/admin/widgets/recent-events.php'; +require_once dirname( __FILE__ ) . '/admin/widgets/future-events.php'; +require_once dirname( __FILE__ ) . '/admin/widgets/countdown-timer.php'; +require_once dirname( __FILE__ ) . '/admin/widgets/events-calendar.php'; +require_once dirname( __FILE__ ) . '/admin/widgets/league-table.php'; // Typical request actions require_once dirname( __FILE__ ) . '/admin/hooks/plugins-loaded.php';