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', 'taxonomy' => 'sp_league',
'name' => 'sp_league', 'name' => 'sp_league',
'selected' => $league_id, 'selected' => $league_id,
'values' => 'term_id' 'values' => 'term_id',
); );
sportspress_dropdown_taxonomies( $args ); sportspress_dropdown_taxonomies( $args );
?> ?>
@@ -74,7 +74,7 @@ function sportspress_list_player_meta( $post ) {
'taxonomy' => 'sp_season', 'taxonomy' => 'sp_season',
'name' => 'sp_season', 'name' => 'sp_season',
'selected' => $season_id, 'selected' => $season_id,
'values' => 'term_id' 'values' => 'term_id',
); );
sportspress_dropdown_taxonomies( $args ); sportspress_dropdown_taxonomies( $args );
?> ?>
@@ -85,9 +85,11 @@ function sportspress_list_player_meta( $post ) {
$args = array( $args = array(
'post_type' => 'sp_team', 'post_type' => 'sp_team',
'name' => '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>
<p><strong><?php _e( 'Players', 'sportspress' ); ?></strong></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 <li class="sp-post<?php
if ( $filter ): if ( $filter ):
echo ' sp-filter-0';
foreach ( $filter_values as $filter_value ): foreach ( $filter_values as $filter_value ):
echo ' sp-filter-' . $filter_value; echo ' sp-filter-' . $filter_value;
endforeach; endforeach;
@@ -1849,15 +1848,26 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) {
'taxonomy' => 'sp_season', 'taxonomy' => 'sp_season',
'field' => 'id', 'field' => 'id',
'terms' => $div_id 'terms' => $div_id
) ),
), ),
'meta_query' => array( 'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'sp_team',
'compare' => 'EXISTS',
),
),
);
if ( $team_id ):
$args['meta_query'] = array(
array( array(
'key' => 'sp_team', 'key' => 'sp_team',
'value' => $team_id, 'value' => $team_id,
) ),
) );
); endif;
$events = get_posts( $args ); $events = get_posts( $args );
// Event loop // Event loop
@@ -1865,28 +1875,56 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) {
$teams = (array)get_post_meta( $event->ID, 'sp_players', true ); $teams = (array)get_post_meta( $event->ID, 'sp_players', true );
if ( ! array_key_exists( $team_id, $teams ) ) if ( $team_id ):
continue;
$players = sportspress_array_value( $teams, $team_id, array() ); if ( ! array_key_exists( $team_id, $teams ) )
foreach ( $players as $player_id => $player_statistics ):
if ( ! $player_id || ! in_array( $player_id, $player_ids ) )
continue; continue;
// Increment events played $players = sportspress_array_value( $teams, $team_id, array() );
$totals[ $player_id ]['eventsplayed']++;
foreach ( $player_statistics as $key => $value ): foreach ( $players as $player_id => $player_statistics ):
if ( array_key_exists( $key, $totals[ $player_id ] ) ): if ( ! $player_id || ! in_array( $player_id, $player_ids ) )
$totals[ $player_id ][ $key ] += $value; continue;
endif;
// 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;
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; endforeach;