diff --git a/admin/hooks/gettext.php b/admin/hooks/gettext.php index 2263f5e5..fc1b54c3 100644 --- a/admin/hooks/gettext.php +++ b/admin/hooks/gettext.php @@ -21,7 +21,7 @@ function sportspress_gettext( $translated_text, $untranslated_text, $domain ) { elseif ( in_array( $typenow, array( 'sp_event', 'sp_player', 'sp_staff' ) ) ): switch ( $untranslated_text ): case 'Enter title here': - $translated_text = __( 'Name', 'sportspress' ); + $translated_text = __( '(Auto)', 'sportspress' ); break; case 'Set featured image': $translated_text = sprintf( __( 'Select %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ); diff --git a/admin/hooks/the-content.php b/admin/hooks/the-content.php index abc42dc0..1e807908 100644 --- a/admin/hooks/the-content.php +++ b/admin/hooks/the-content.php @@ -33,9 +33,24 @@ add_filter( 'the_content', 'sportspress_default_team_content' ); function sportspress_default_table_content( $content ) { if ( is_singular( 'sp_table' ) && in_the_loop() ): + $id = get_the_ID(); + $leagues = get_the_terms( $id, 'sp_league' ); + $seasons = get_the_terms( $id, 'sp_season' ); + $terms = array(); + if ( $leagues ): + $league = reset( $leagues ); + $terms[] = $league->name; + endif; + if ( $seasons ): + $season = reset( $seasons ); + $terms[] = $season->name; + endif; + $title = ''; + if ( sizeof( $terms ) ) + $title = '

' . implode( ' — ', $terms ) . '

'; $table = sportspress_league_table(); $excerpt = has_excerpt() ? wpautop( get_the_excerpt() ) : ''; - $content = $table . $content . $excerpt; + $content = $title . $table . $content . $excerpt; endif; return $content; } diff --git a/admin/post-types/player.php b/admin/post-types/player.php index 9865e157..8e8daa2a 100644 --- a/admin/post-types/player.php +++ b/admin/post-types/player.php @@ -81,8 +81,8 @@ function sportspress_player_details_meta( $post ) {

@@ -50,6 +53,26 @@ class SportsPress_Widget_League_Table extends WP_Widget { endif; ?>

+ +

+
+ 'sp_column', + 'numberposts' => -1, + 'posts_per_page' => -1, + 'orderby' => 'menu_order', + 'order' => 'ASC' + ); + $the_columns = get_posts( $args ); + + $field_name = $this->get_field_name('columns') . '[]'; + $field_id = $this->get_field_id('columns'); + ?> + + + +

'widget_player_list widget_sp_player_list', 'description' => __( 'SportsPress widget.', 'sportspress' ) ); + parent::__construct('sp_player_list', __( 'Player List', 'sportspress' ), $widget_ops); + } + + function widget( $args, $instance ) { + extract($args); + $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); + $id = empty($instance['id']) ? null : $instance['id']; + $statistics = $instance['statistics']; + $orderby = empty($instance['orderby']) ? 'number' : $instance['orderby']; + $order = empty($instance['order']) ? 'ASC' : $instance['order']; + echo $before_widget; + if ( $title ) + echo $before_title . $title . $after_title; + echo '
'; + echo sportspress_player_list( $id, array( 'statistics' => $statistics, 'orderby' => $orderby , 'order' => $order ) ); + echo '
'; + echo $after_widget; + } + + function update( $new_instance, $old_instance ) { + $instance = $old_instance; + $instance['title'] = strip_tags($new_instance['title']); + $instance['id'] = intval($new_instance['id']); + $instance['statistics'] = (array)$new_instance['statistics']; + $instance['orderby'] = strip_tags($new_instance['orderby']); + $instance['order'] = strip_tags($new_instance['order']); + + return $instance; + } + + function form( $instance ) { + $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'statistics' => null, 'orderby' => 'number', 'order' => 'ASC' ) ); + $title = strip_tags($instance['title']); + $id = intval($instance['id']); + $statistics = $instance['statistics']; + $orderby = strip_tags($instance['orderby']); + $order = strip_tags($instance['order']); +?> +

+

+ +

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

+ +

+
+ 'sp_statistic', + 'numberposts' => -1, + 'posts_per_page' => -1, + 'orderby' => 'menu_order', + 'order' => 'ASC' + ); + $the_statistics = get_posts( $args ); + + $field_name = $this->get_field_name('statistics') . '[]'; + $field_id = $this->get_field_id('statistics'); + ?> + + + + +

+ +

+ 'sp_statistic', + 'show_option_all' => __( 'Number', 'sportspress' ), + 'option_all_value' => 'number', + 'show_option_none' => __( 'Played', 'sportspress' ), + 'option_none_value' => 'eventsplayed', + 'name' => $this->get_field_name('orderby'), + 'id' => $this->get_field_id('orderby'), + 'selected' => $orderby, + 'values' => 'slug', + 'class' => 'widefat', + ); + if ( ! sportspress_dropdown_pages( $args ) ): + sportspress_post_adder( 'sp_list' ); + endif; + ?> +

+ +

+

+ 0, 'option_none_value' => -1, 'name' => 'page_id', + 'id' => 'page_id', 'selected' => null, 'numberposts' => -1, 'posts_per_page' => -1, @@ -286,25 +287,27 @@ if ( !function_exists( 'sportspress_dropdown_pages' ) ) { $args = array_merge( $defaults, $args ); $name = $args['name']; unset( $args['name'] ); + $id = $args['id']; + unset( $args['id'] ); $values = $args['values']; unset( $args['values'] ); $class = $args['class']; unset( $args['class'] ); $posts = get_posts( $args ); if ( $posts ): - printf( '', $name, $id, $class ); if ( $args['show_option_all'] ): - printf( '', $args['option_all_value'], $args['show_option_all'] ); + printf( '', $args['option_all_value'], selected( $args['selected'], $args['option_all_value'], false ), $args['show_option_all'] ); endif; if ( $args['show_option_none'] ): - printf( '', $args['option_none_value'], $args['show_option_none'] ); + printf( '', $args['option_none_value'], selected( $args['selected'], $args['option_none_value'], false ), $args['show_option_none'] ); endif; foreach ( $posts as $post ): setup_postdata( $post ); if ( $values == 'ID' ): - printf( '', $post->ID, selected( true, $args['selected'] == $post->ID, false ), $post->post_title . ( $args['show_dates'] ? ' (' . $post->post_date . ')' : '' ) ); + printf( '', $post->ID, selected( $args['selected'], $post->ID, false ), $post->post_title . ( $args['show_dates'] ? ' (' . $post->post_date . ')' : '' ) ); else: - printf( '', $post->post_name, selected( true, $args['selected'] == $post->post_name, false ), $post->post_title ); + printf( '', $post->post_name, selected( $args['selected'], $post->post_name, false ), $post->post_title ); endif; endforeach; wp_reset_postdata(); @@ -1988,6 +1991,34 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) { } } +if ( !function_exists( 'sportspress_sort_list_players' ) ) { + function sportspress_sort_list_players ( $a, $b ) { + + global $sportspress_statistic_priorities; + + // Loop through priorities + foreach( $sportspress_statistic_priorities as $priority ): + + // Proceed if columns are not equal + if ( sportspress_array_value( $a, $priority['statistic'], 0 ) != sportspress_array_value( $b, $priority['statistic'], 0 ) ): + + // Compare statistic values + $output = sportspress_array_value( $a, $priority['statistic'], 0 ) - sportspress_array_value( $b, $priority['statistic'], 0 ); + + // Flip value if descending order + if ( $priority['order'] == 'DESC' ) $output = 0 - $output; + + return $output; + + endif; + + endforeach; + + // Default sort by number + return strcmp( sportspress_array_value( $a, 'number', '' ), sportspress_array_value( $b, 'number', '' ) ); + } +} + if ( !function_exists( 'sportspress_get_player_metrics_data' ) ) { function sportspress_get_player_metrics_data( $post_id ) { diff --git a/readme.txt b/readme.txt index 35d08120..0a0a95bb 100644 --- a/readme.txt +++ b/readme.txt @@ -1,14 +1,30 @@ -=== SportsPress === +=== SportsPress - Automated League Statistics === Contributors: themeboy Tags: sports, sports journalism, teams, team management, fixtures, results, standings, league tables, leagues, reporting, themeboy, wordpress sports, configurable 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.6 +Requires at least: 3.8 +Tested up to: 3.8.1 +Stable tag: 0.2.8 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html -SportsPress is a flexible sports management plugin that adds team management functionality to WordPress. Currently in beta for internal testing. +SportsPress is a fully configurable sports plugin that seemlessly automates league, team, and player statistics. Currently in beta. + +== Description == + +Add schedules, results, league tables, player profiles and statistics to your team or league site with SportsPress. It is designed to work with virtually every WordPress theme, and includes several language translations. + += Customizable = + +League table columns, player statistics, and match results can be customized to fit any sport. Presets are available for some of the most popular sports including soccer, rugby, American football, Australian Rules football, baseball, basketball, cricket, and hockey. + += Available Languages = +* English +* Spanish +* French +* Japanese + +[Let us know](http://wordpress.org/support/plugin/sportspress) if you come across any missing or inaccurate translations in your language. == Installation == @@ -69,9 +85,14 @@ SportsPress is currently in beta and is undergoing testing. We are still activel 2. Teams admin. 3. Players admin. 4. SportsPress Settings panel. +5. League Table widget. == Changelog == += 0.2.7 = +* Feature - Select columns to display in league table widget. +* Tweak - Start league table positions at 1 instead of 0. + = 0.2.6 = * Localization - Add French translations. * Preset - Update soccer preset. @@ -81,9 +102,9 @@ SportsPress is currently in beta and is undergoing testing. We are still activel = 0.2.4 = * Feature - Display venue map on event page and venue archive. -* Tweak - Sort sports presets alphabetically by localized name. * Fix - Add checks to prevent league table dividing by zero when no events have been played. * Fix - Flush rewrite rules for taxonomies on activation. +* Tweak - Sort sports presets alphabetically by localized name. = 0.2.3 = * Feature - Enable selecting main event result. diff --git a/sportspress.php b/sportspress.php index eb80870d..122ea944 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.6 +Version: 0.2.8 Author: ThemeBoy Author URI: http://themeboy.com/ License: GPLv3 @@ -18,7 +18,7 @@ if ( !function_exists( 'add_action' ) ) { exit; } -define( 'SPORTSPRESS_VERSION', '0.2.4' ); +define( 'SPORTSPRESS_VERSION', '0.2.8' ); define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ ); @@ -78,6 +78,7 @@ 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.php'; require_once dirname( __FILE__ ) . '/admin/widgets/events-calendar.php'; +require_once dirname( __FILE__ ) . '/admin/widgets/player-list.php'; require_once dirname( __FILE__ ) . '/admin/widgets/league-table.php'; // Typical request actions