All teams option in player list

This commit is contained in:
Brian Miyaji
2014-02-13 01:59:59 +11:00
parent b3b956b1a6
commit a69ee99df9
2 changed files with 63 additions and 23 deletions

View File

@@ -62,7 +62,7 @@ function sportspress_list_player_meta( $post ) {
'taxonomy' => 'sp_league',
'name' => 'sp_league',
'selected' => $league_id,
'values' => 'term_id'
'values' => 'term_id',
);
sportspress_dropdown_taxonomies( $args );
?>
@@ -74,7 +74,7 @@ function sportspress_list_player_meta( $post ) {
'taxonomy' => 'sp_season',
'name' => 'sp_season',
'selected' => $season_id,
'values' => 'term_id'
'values' => 'term_id',
);
sportspress_dropdown_taxonomies( $args );
?>
@@ -85,9 +85,11 @@ function sportspress_list_player_meta( $post ) {
$args = array(
'post_type' => 'sp_team',
'name' => 'sp_team',
'selected' => $team_id
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
'selected' => $team_id,
'values' => 'ID',
);
wp_dropdown_pages( $args );
sportspress_dropdown_pages( $args );
?>
</p>
<p><strong><?php _e( 'Players', 'sportspress' ); ?></strong></p>

View File

@@ -386,7 +386,6 @@ if ( !function_exists( 'sportspress_post_checklist' ) ) {
?>
<li class="sp-post<?php
if ( $filter ):
echo ' sp-filter-0';
foreach ( $filter_values as $filter_value ):
echo ' sp-filter-' . $filter_value;
endforeach;
@@ -1849,15 +1848,26 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) {
'taxonomy' => 'sp_season',
'field' => 'id',
'terms' => $div_id
)
),
),
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'sp_team',
'compare' => 'EXISTS',
),
),
);
if ( $team_id ):
$args['meta_query'] = array(
array(
'key' => 'sp_team',
'value' => $team_id,
)
)
),
);
endif;
$events = get_posts( $args );
// Event loop
@@ -1865,6 +1875,8 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) {
$teams = (array)get_post_meta( $event->ID, 'sp_players', true );
if ( $team_id ):
if ( ! array_key_exists( $team_id, $teams ) )
continue;
@@ -1888,6 +1900,32 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) {
endforeach;
else:
foreach ( $teams as $players ):
foreach ( $players as $player_id => $player_statistics ):
if ( ! $player_id || ! in_array( $player_id, $player_ids ) )
continue;
// Increment events played
$totals[ $player_id ]['eventsplayed']++;
foreach ( $player_statistics as $key => $value ):
if ( array_key_exists( $key, $totals[ $player_id ] ) ):
$totals[ $player_id ][ $key ] += $value;
endif;
endforeach;
endforeach;
endforeach;
endif;
endforeach;
$args = array(