diff --git a/admin/hooks/admin-enqueue-scripts.php b/admin/hooks/admin-enqueue-scripts.php index 998282c0..c08a14a5 100644 --- a/admin/hooks/admin-enqueue-scripts.php +++ b/admin/hooks/admin-enqueue-scripts.php @@ -1,5 +1,9 @@ 'sp_league', 'name' => 'sp_league', 'selected' => $league_id, - 'value' => 'term_id', + 'values' => 'term_id', 'show_option_none' => __( '-- Not set --', 'sportspress' ), ); sportspress_dropdown_taxonomies( $args ); @@ -73,7 +73,7 @@ function sportspress_event_details_meta( $post ) { 'taxonomy' => 'sp_season', 'name' => 'sp_season', 'selected' => $season_id, - 'value' => 'term_id', + 'values' => 'term_id', 'show_option_none' => __( '-- Not set --', 'sportspress' ), ); sportspress_dropdown_taxonomies( $args ); @@ -86,7 +86,7 @@ function sportspress_event_details_meta( $post ) { 'taxonomy' => 'sp_venue', 'name' => 'sp_venue', 'selected' => $venue_id, - 'value' => 'term_id', + 'values' => 'term_id', 'show_option_none' => __( '-- Not set --', 'sportspress' ), ); sportspress_dropdown_taxonomies( $args ); diff --git a/admin/post-types/list.php b/admin/post-types/list.php index ef5428c3..94858dc9 100644 --- a/admin/post-types/list.php +++ b/admin/post-types/list.php @@ -60,7 +60,7 @@ function sportspress_list_player_meta( $post ) { 'taxonomy' => 'sp_league', 'name' => 'sp_league', 'selected' => $league_id, - 'value' => 'term_id' + 'values' => 'term_id' ); sportspress_dropdown_taxonomies( $args ); ?> @@ -72,7 +72,7 @@ function sportspress_list_player_meta( $post ) { 'taxonomy' => 'sp_season', 'name' => 'sp_season', 'selected' => $season_id, - 'value' => 'term_id' + 'values' => 'term_id' ); sportspress_dropdown_taxonomies( $args ); ?> diff --git a/admin/post-types/table.php b/admin/post-types/table.php index b4916bba..138df389 100644 --- a/admin/post-types/table.php +++ b/admin/post-types/table.php @@ -38,6 +38,7 @@ function sportspress_table_meta_init( $post ) { $teams = (array)get_post_meta( $post->ID, 'sp_team', false ); remove_meta_box( 'sp_seasondiv', 'sp_table', 'side' ); + remove_meta_box( 'sp_leaguediv', 'sp_table', 'side' ); add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sportspress_table_team_meta', 'sp_table', 'side', 'high' ); if ( $teams && $teams != array(0) ): @@ -57,7 +58,7 @@ function sportspress_table_team_meta( $post, $test ) { 'taxonomy' => 'sp_league', 'name' => 'sp_league', 'selected' => $league_id, - 'value' => 'term_id' + 'values' => 'term_id' ); sportspress_dropdown_taxonomies( $args ); ?> @@ -69,7 +70,7 @@ function sportspress_table_team_meta( $post, $test ) { 'taxonomy' => 'sp_season', 'name' => 'sp_season', 'selected' => $season_id, - 'value' => 'term_id' + 'values' => 'term_id' ); sportspress_dropdown_taxonomies( $args ); ?> diff --git a/admin/templates/events-calendar.php b/admin/templates/events-calendar.php index 42960b54..a704d855 100644 --- a/admin/templates/events-calendar.php +++ b/admin/templates/events-calendar.php @@ -80,7 +80,7 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) { '; if ( $previous ) { - $calendar_output .= "\n\t\t".'« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . ''; + $calendar_output .= "\n\t\t".'« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . ''; } else { $calendar_output .= "\n\t\t".' '; } @@ -88,7 +88,7 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) { $calendar_output .= "\n\t\t".' '; if ( $next ) { - $calendar_output .= "\n\t\t".'' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »'; + $calendar_output .= "\n\t\t".'' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »'; } else { $calendar_output .= "\n\t\t".' '; } @@ -157,7 +157,7 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) { $calendar_output .= ''; if ( array_key_exists($day, $daywithpost) ) // any posts today? - $calendar_output .= '$day"; + $calendar_output .= '$day"; else $calendar_output .= $day; $calendar_output .= ''; diff --git a/admin/templates/events.php b/admin/templates/events.php new file mode 100644 index 00000000..aeee8542 --- /dev/null +++ b/admin/templates/events.php @@ -0,0 +1,65 @@ + 'sp_event', + 'posts_per_page' => 1, + 'post_status' => 'publish', + 'tax_query' => array(), + ); + + if ( isset( $args['number'] ) ): + $options['posts_per_page'] = $args['number']; + endif; + + if ( isset( $args['status'] ) && $args['status'] == 'any' || $args['status'] == 'scheduled' ): + $options['post_status'] = array( 'publish', 'future' ); + endif; + + if ( isset( $args['league'] ) ): + $options['tax_query'][] = array( + 'taxonomy' => 'sp_league', + 'field' => 'id', + 'terms' => $league + ); + endif; + + if ( isset( $args['season'] ) ): + $options['tax_query'][] = array( + 'taxonomy' => 'sp_season', + 'field' => 'id', + 'terms' => $season + ); + endif; + + if ( isset( $args['venue'] ) ): + $options['tax_query'][] = array( + 'taxonomy' => 'sp_venue', + 'field' => 'id', + 'terms' => $venue + ); + endif; + + $query = new WP_Query( $options ); + + if ( $query->have_posts() ): + $output = ''; + wp_reset_postdata(); + endif; + + return apply_filters( 'sportspress_events', $output ); + + } +} diff --git a/admin/templates/league-table.php b/admin/templates/league-table.php index 7f84b3c1..8cf5f5bd 100644 --- a/admin/templates/league-table.php +++ b/admin/templates/league-table.php @@ -17,19 +17,23 @@ if ( !function_exists( 'sportspress_league_table' ) ) { $seasons = get_the_terms( $id, 'sp_season' ); $terms = array(); - if ( sizeof( $leagues ) ): + if ( $leagues ): $league = reset( $leagues ); $terms[] = $league->name; endif; - if ( sizeof( $seasons ) ): + if ( $seasons ): $season = reset( $seasons ); $terms[] = $season->name; endif; $title = sizeof( $terms ) ? implode( ' — ', $terms ) : get_the_title( $id ); - $output = '

' . $title . '

' . - '
' . + if ( ! is_singular( 'sp_table' ) ) + $output = '

' . $title . '

'; + else + $output = '

' . $title . '

'; + + $output .= '
' . '' . '' . ''; $data = sportspress_get_league_table_data( $id ); diff --git a/admin/widgets/events.php b/admin/widgets/events.php new file mode 100644 index 00000000..a43d0253 --- /dev/null +++ b/admin/widgets/events.php @@ -0,0 +1,145 @@ + 'widget_recent_entries widget_sp_events', 'description' => __( 'SportsPress widget.', 'sportspress' ) ); + parent::__construct('sp_events', __( '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']; + $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, + 'league' => $league, + 'season' => $season, + 'venue' => $venue, + 'team' => $team, + 'number' => $number, + ); + echo $before_widget; + if ( $title ) + echo $before_title . $title . $after_title; + echo '
'; + echo sportspress_events( $args ); + echo '
'; + echo $after_widget; + } + + function update( $new_instance, $old_instance ) { + $instance = $old_instance; + $instance['title'] = strip_tags($new_instance['title']); + $instance['status'] = strip_tags($new_instance['status']); + $instance['league'] = intval($new_instance['league']); + $instance['season'] = intval($new_instance['season']); + $instance['venue'] = intval($new_instance['venue']); + $instance['team'] = intval($new_instance['team']); + $instance['number'] = intval($new_instance['number']); + + return $instance; + } + + function form( $instance ) { + $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'status' => '', 'league' => '', 'season' => '', 'venue' => '', 'team' => '', 'number' => 3 ) ); + $title = strip_tags($instance['title']); + $status = strip_tags($instance['status']); + $league = intval($instance['league']); + $season = intval($instance['season']); + $venue = intval($instance['venue']); + $team = intval($instance['team']); + $number = intval($instance['number']); +?> +

+

+ +

+ __( 'Any', 'sportspress' ), + 'played' => __( 'Played', 'sportspress' ), + 'scheduled' => __( 'Scheduled', 'sportspress' ), + ); + ?> + + +

+ '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; + ?> +

+ +

+

+ 'widget_league_table widget_sp_league_table', 'description' => __( 'SportsPress widget.', 'sportspress' ) ); - parent::__construct('sp_table', __( 'League Table', 'sportspress', 'sportspress' ), $widget_ops); + parent::__construct('sp_table', __( 'League Table', 'sportspress' ), $widget_ops); } function widget( $args, $instance ) { @@ -35,17 +35,19 @@ class SportsPress_Widget_League_Table extends WP_Widget {

-

+

'sp_table', 'name' => $this->get_field_name('id'), 'id' => $this->get_field_id('id'), - 'show_option_none' => __( '-- Select --', 'sportspress' ), 'selected' => $id, 'values' => 'ID', + 'class' => 'widefat', ); - sportspress_dropdown_pages( $args ); + if ( ! sportspress_dropdown_pages( $args ) ): + sportspress_post_adder( 'sp_table' ); + endif; ?>

+ + +Generated by IcoMoon + + + + + + + + \ No newline at end of file diff --git a/assets/fonts/themeboy.ttf b/assets/fonts/themeboy.ttf new file mode 100755 index 00000000..0c0606d4 Binary files /dev/null and b/assets/fonts/themeboy.ttf differ diff --git a/assets/fonts/themeboy.woff b/assets/fonts/themeboy.woff new file mode 100755 index 00000000..c57642cc Binary files /dev/null and b/assets/fonts/themeboy.woff differ diff --git a/functions.php b/functions.php index c96176bf..9483911b 100644 --- a/functions.php +++ b/functions.php @@ -230,13 +230,16 @@ if ( !function_exists( 'sportspress_dropdown_taxonomies' ) ) { 'name' => null, 'selected' => null, 'hide_empty' => false, - 'value' => 'slug', + 'values' => 'slug', + 'class' => null, ); $args = array_merge( $defaults, $args ); $terms = get_terms( $args['taxonomy'], $args ); $name = ( $args['name'] ) ? $args['name'] : $args['taxonomy']; + $class = $args['class']; + unset( $args['class'] ); if ( $terms ) { - printf( '', $name, $class ); if ( $args['show_option_all'] ) { printf( '', $args['show_option_all'] ); } @@ -244,7 +247,7 @@ if ( !function_exists( 'sportspress_dropdown_taxonomies' ) ) { printf( '', $args['show_option_none'] ); } foreach ( $terms as $term ) { - if ( $args['value'] == 'term_id' ) + if ( $args['values'] == 'term_id' ) printf( '', $term->term_id, selected( true, $args['selected'] == $term->term_id, false ), $term->name ); else printf( '', $term->slug, selected( true, $args['selected'] == $term->slug, false ), $term->name ); @@ -259,6 +262,8 @@ if ( !function_exists( 'sportspress_dropdown_pages' ) ) { $defaults = array( 'show_option_all' => false, 'show_option_none' => false, + 'option_all_value' => 0, + 'option_none_value' => -1, 'name' => 'page_id', 'selected' => null, 'numberposts' => -1, @@ -275,20 +280,23 @@ if ( !function_exists( 'sportspress_dropdown_pages' ) ) { 'exclude_tree' => null, 'post_type' => 'page', 'values' => 'post_name', + 'class' => null, ); $args = array_merge( $defaults, $args ); $name = $args['name']; unset( $args['name'] ); $values = $args['values']; unset( $args['values'] ); + $class = $args['class']; + unset( $args['class'] ); $posts = get_posts( $args ); - if ( $posts ) { - printf( '', $name, $class ); if ( $args['show_option_all'] ) { - printf( '', $args['show_option_all'] ); + printf( '', $args['option_all_value'], $args['show_option_all'] ); } if ( $args['show_option_none'] ) { - printf( '', $args['show_option_none'] ); + printf( '', $args['option_none_value'], $args['show_option_none'] ); } foreach ( $posts as $post ) { if ( $values == 'ID' ): @@ -298,7 +306,10 @@ if ( !function_exists( 'sportspress_dropdown_pages' ) ) { endif; } print( '' ); - } + return true; + else: + return false; + endif; } } @@ -882,7 +893,7 @@ if ( !function_exists( 'sportspress_edit_event_results_table' ) ) { 'post_type' => 'sp_outcome', 'name' => 'sp_results[' . $team_id . '][outcome]', 'show_option_none' => __( '-- Not set --', 'sportspress' ), - 'option_none_value' => 0, + 'option_none_value' => '', 'sort_order' => 'ASC', 'sort_column' => 'menu_order', 'selected' => $value diff --git a/readme.txt b/readme.txt index ebcf6b14..fd8ba6a1 100644 --- a/readme.txt +++ b/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 Requires at least: 3.5 Tested up to: 3.8 -Stable tag: 0.2.1 +Stable tag: 0.2.2 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html diff --git a/sportspress.php b/sportspress.php index 8a66c514..0eee5009 100644 --- a/sportspress.php +++ b/sportspress.php @@ -6,7 +6,7 @@ Plugin Name: SportsPress Plugin URI: http://themeboy.com/sportspress Description: Manage your club and its players, staff, events, league tables, and player lists. -Version: 0.2.1 +Version: 0.2.2 Author: ThemeBoy Author URI: http://themeboy.com/ License: GPLv3 @@ -18,7 +18,7 @@ if ( !function_exists( 'add_action' ) ) { exit; } -define( 'SPORTSPRESS_VERSION', '0.2' ); +define( 'SPORTSPRESS_VERSION', '0.2.2' ); define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ ); @@ -40,6 +40,7 @@ require_once dirname( __FILE__ ) . '/admin/templates/event-players.php'; require_once dirname( __FILE__ ) . '/admin/templates/event-results.php'; require_once dirname( __FILE__ ) . '/admin/templates/event-staff.php'; require_once dirname( __FILE__ ) . '/admin/templates/event-venue.php'; +require_once dirname( __FILE__ ) . '/admin/templates/events.php'; require_once dirname( __FILE__ ) . '/admin/templates/events-calendar.php'; require_once dirname( __FILE__ ) . '/admin/templates/league-table.php'; require_once dirname( __FILE__ ) . '/admin/templates/player-league-statistics.php'; @@ -72,6 +73,7 @@ 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';