diff --git a/admin/post-types/list.php b/admin/post-types/list.php index 1d893dd7..0813f6c1 100644 --- a/admin/post-types/list.php +++ b/admin/post-types/list.php @@ -92,14 +92,28 @@ function sp_list_stats_meta( $post ) { // Create entry for each player in totals $totals = array(); + $placeholders = array(); + foreach ( $player_ids as $player_id ): if ( ! $player_id ) continue; + $totals[ $player_id ] = array( 'eventsattended' => 0, 'eventsplayed' => 0 ); foreach ( $metric_labels as $key => $value ): $totals[ $player_id ][ $key ] = 0; endforeach; + + // Get statis metrics + $static = get_post_meta( $player_id, 'sp_metrics', true ); + + // Create placeholders entry for the player + $placeholders[ $player_id ] = array(); + + // Add static metrics to placeholders + if ( array_key_exists( $team_id, $static ) && array_key_exists( $div_id, $static[ $team_id ] ) ): + $placeholders[ $player_id ] = $static[ $team_id ][ $div_id ]; + endif; endforeach; $args = array( @@ -150,20 +164,21 @@ function sp_list_stats_meta( $post ) { endforeach; // Generate placeholder values for each team - $placeholders = array(); foreach ( $player_ids as $player_id ): - $placeholders[ $player_id ] = array(); foreach ( $equations as $key => $value ): + if ( sp_array_value( $placeholders[ $player_id ], $key, '' ) == '' ): - if ( empty( $value ) ): + if ( empty( $value ) ): - // Reflect totals - $placeholders[ $player_id ][ $key ] = sp_array_value( sp_array_value( $totals, $player_id, array() ), $key, 0 ); + // Reflect totals + $placeholders[ $player_id ][ $key ] = sp_array_value( sp_array_value( $totals, $player_id, array() ), $key, 0 ); - else: + else: - // Calculate value - $placeholders[ $player_id ][ $key ] = $eos->solveIF( str_replace( ' ', '', $value ), sp_array_value( $totals, $player_id, array() ) ); + // Calculate value + $placeholders[ $player_id ][ $key ] = $eos->solveIF( str_replace( ' ', '', $value ), sp_array_value( $totals, $player_id, array() ) ); + + endif; endif; diff --git a/admin/post-types/table.php b/admin/post-types/table.php index 612e3c0c..baf566e3 100644 --- a/admin/post-types/table.php +++ b/admin/post-types/table.php @@ -83,6 +83,9 @@ function sp_table_stats_meta( $post ) { $placeholders = array(); foreach ( $team_ids as $team_id ): + if ( ! $team_id ) + continue; + $totals[ $team_id ] = array( 'eventsplayed' => 0 ); foreach ( $result_labels as $key => $value ): @@ -94,6 +97,7 @@ function sp_table_stats_meta( $post ) { $totals[ $team_id ][ $key ] = 0; endforeach; + // Get statis stats $static = get_post_meta( $team_id, 'sp_stats', true ); // Create placeholders entry for the team