Add all team statistics in player profile row
This commit is contained in:
@@ -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 ):
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _e( 'Metric', 'sportspress' ); ?></th>
|
||||
<th><?php _e( 'Value', 'sportspress' ); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ( $vars as $var ):
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<td>
|
||||
<?php echo $var->post_title; ?>
|
||||
</td>
|
||||
<?php
|
||||
$value = sportspress_array_value( $metrics, $var->post_name, '' );
|
||||
?>
|
||||
<td><input type="text" name="sp_metrics[<?php echo $var->post_name; ?>]" value="<?php echo $value; ?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
else:
|
||||
sportspress_post_adder( 'sp_metric' );
|
||||
endif;
|
||||
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
function sportspress_player_stats_meta( $post ) {
|
||||
$leagues = get_the_terms( $post->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' );
|
||||
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _e( 'Metric', 'sportspress' ); ?></th>
|
||||
<th><?php _e( 'Value', 'sportspress' ); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
$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 );
|
||||
|
||||
$i = 0;
|
||||
foreach ( $vars as $var ):
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<td>
|
||||
<?php echo $var->post_title; ?>
|
||||
</td>
|
||||
<?php
|
||||
$value = sportspress_array_value( $metrics, $var->post_name, '' );
|
||||
?>
|
||||
<td><input type="text" name="sp_metrics[<?php echo $var->post_name; ?>]" value="<?php echo $value; ?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
function sportspress_player_profile_meta( $post ) {
|
||||
wp_editor( $post->post_content, 'content' );
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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__ );
|
||||
|
||||
Reference in New Issue
Block a user