Fix multiple division player metric duplication issue
This commit is contained in:
@@ -52,7 +52,9 @@ function sp_player_stats_meta( $post ) {
|
|||||||
$div_ids[] = $value->term_id;
|
$div_ids[] = $value->term_id;
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
if ( empty( $team_ids ) || $team_ids == array(0) ):
|
unset( $team_ids[0] );
|
||||||
|
|
||||||
|
if ( empty( $team_ids ) ):
|
||||||
?>
|
?>
|
||||||
<p><strong><?php printf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ); ?></strong></p>
|
<p><strong><?php printf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ); ?></strong></p>
|
||||||
<?php
|
<?php
|
||||||
@@ -62,9 +64,12 @@ function sp_player_stats_meta( $post ) {
|
|||||||
// Initialize placeholders array
|
// Initialize placeholders array
|
||||||
$placeholders = array();
|
$placeholders = array();
|
||||||
|
|
||||||
|
$team_num = sizeof( $team_ids );
|
||||||
|
|
||||||
// Loop through statistics for each team
|
// Loop through statistics for each team
|
||||||
foreach ( $team_ids as $team_id ):
|
foreach ( $team_ids as $team_id ):
|
||||||
if ( !$team_id ) continue;
|
|
||||||
|
$data = array();
|
||||||
|
|
||||||
// Get all divisions populated with stats where available
|
// Get all divisions populated with stats where available
|
||||||
$data[ $team_id ] = sp_array_combine( $div_ids, $stats[ $team_id ] );
|
$data[ $team_id ] = sp_array_combine( $div_ids, $stats[ $team_id ] );
|
||||||
@@ -144,9 +149,11 @@ function sp_player_stats_meta( $post ) {
|
|||||||
// Get columns from statistics variables
|
// Get columns from statistics variables
|
||||||
$columns = sp_get_var_labels( 'sp_metric' );
|
$columns = sp_get_var_labels( 'sp_metric' );
|
||||||
|
|
||||||
|
if ( $team_num > 1 ):
|
||||||
?>
|
?>
|
||||||
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
|
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
|
||||||
<?php
|
<?php
|
||||||
|
endif;
|
||||||
|
|
||||||
sp_player_metrics_table( $columns, $data, $placeholders );
|
sp_player_metrics_table( $columns, $data, $placeholders );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user