From cdbd94a74039c3e9a844e538d05f4310385d3f9d Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Thu, 13 Feb 2014 17:11:50 +1100 Subject: [PATCH] Add all team statistics in player profile row --- admin/post-types/player.php | 130 +++++++++++++++++++----------------- functions.php | 22 +++--- readme.txt | 8 ++- sportspress.php | 4 +- 4 files changed, 88 insertions(+), 76 deletions(-) diff --git a/admin/post-types/player.php b/admin/post-types/player.php index 8e8daa2a..a73a1a80 100644 --- a/admin/post-types/player.php +++ b/admin/post-types/player.php @@ -115,6 +115,73 @@ function sportspress_player_team_meta( $post ) { sportspress_post_adder( 'sp_team' ); } +function sportspress_player_metrics_meta( $post ) { + $metrics = get_post_meta( $post->ID, 'sp_metrics', true ); + $positions = get_the_terms( $post->ID, 'sp_position' ); + + $args = array( + 'post_type' => 'sp_metric', + 'numberposts' => -1, + 'posts_per_page' => -1, + 'orderby' => 'menu_order', + 'order' => 'ASC', + ); + + if ( $positions ): + $position_ids = array(); + foreach( $positions as $position ): + $position_ids[] = $position->term_id; + endforeach; + $args['tax_query'] = array( + array( + 'taxonomy' => 'sp_position', + 'field' => 'id', + 'terms' => $position_ids, + ), + ); + endif; + + $vars = get_posts( $args ); + + if ( $vars ): + ?> +
+ + + + + + + + + + + + post_name, '' ); + ?> + + + + +
+ post_title; ?> +
+
+ ID, 'sp_league' ); @@ -136,69 +203,6 @@ function sportspress_player_stats_meta( $post ) { endforeach; } -function sportspress_player_metrics_meta( $post ) { - $metrics = get_post_meta( $post->ID, 'sp_metrics', true ); - $positions = get_the_terms( $post->ID, 'sp_position' ); - - ?> -
- - - - - - - - - 'sp_metric', - 'numberposts' => -1, - 'posts_per_page' => -1, - 'orderby' => 'menu_order', - 'order' => 'ASC', - ); - - if ( $positions ): - $position_ids = array(); - foreach( $positions as $position ): - $position_ids[] = $position->term_id; - endforeach; - $args['tax_query'] = array( - array( - 'taxonomy' => 'sp_position', - 'field' => 'id', - 'terms' => $position_ids, - ), - ); - endif; - - $vars = get_posts( $args ); - - $i = 0; - foreach ( $vars as $var ): - ?> - - - post_name, '' ); - ?> - - - - -
- post_title; ?> -
-
- post_content, 'content' ); } diff --git a/functions.php b/functions.php index 031583f8..480b77d0 100644 --- a/functions.php +++ b/functions.php @@ -2148,11 +2148,11 @@ if ( !function_exists( 'sportspress_get_player_statistics_data' ) ) { 'numberposts' => -1, 'posts_per_page' => -1, 'meta_query' => array( - 'relation' => 'AND', - array( - 'key' => 'sp_team', - 'value' => $team_id - ), +// 'relation' => 'AND', +// array( +// 'key' => 'sp_team', +// 'value' => $team_id +// ), array( 'key' => 'sp_player', 'value' => $post_id @@ -2178,17 +2178,21 @@ if ( !function_exists( 'sportspress_get_player_statistics_data' ) ) { $totals['eventsattended']++; $totals['eventsplayed']++; $team_statistics = (array)get_post_meta( $event->ID, 'sp_players', true ); - if ( array_key_exists( $team_id, $team_statistics ) ): - $players = sportspress_array_value( $team_statistics, $team_id, array() ); + + // Add all team statistics +// if ( array_key_exists( $team_id, $team_statistics ) ): + foreach ( $team_statistics as $players ): +// $players = sportspress_array_value( $team_statistics, $team_id, array() ); if ( array_key_exists( $post_id, $players ) ): $player_statistics = sportspress_array_value( $players, $post_id, array() ); foreach ( $player_statistics as $key => $value ): - if ( array_key_exists( $key, $totals ) ): + array_key_exists( $key, $totals ) ): $totals[ $key ] += $value; endif; endforeach; endif; - endif; +// endif; + endforeach; endforeach; // Generate array of placeholder values for each league diff --git a/readme.txt b/readme.txt index 419ecf40..ac6aadb7 100644 --- a/readme.txt +++ b/readme.txt @@ -1,10 +1,10 @@ -=== SportsPress - Automated League Statistics === +=== 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.8 Tested up to: 3.8.1 -Stable tag: 0.2.8 +Stable tag: 0.2.9 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -91,6 +91,10 @@ SportsPress is currently in beta and is undergoing testing. We are still activel == Changelog == += 0.2.9 = +* Feature - Ability to select players from all teams in player list. +* Fix - Decimal sorting in league tables and player lists. + = 0.2.8 = * Feature - Add player list widget. * Localization - Add German translations. diff --git a/sportspress.php b/sportspress.php index 122ea944..188c2d99 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.8 +Version: 0.2.9 Author: ThemeBoy Author URI: http://themeboy.com/ License: GPLv3 @@ -18,7 +18,7 @@ if ( !function_exists( 'add_action' ) ) { exit; } -define( 'SPORTSPRESS_VERSION', '0.2.8' ); +define( 'SPORTSPRESS_VERSION', '0.2.9' ); define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ );