Override player event metrics with static metrics in player list
This commit is contained in:
@@ -92,14 +92,28 @@ function sp_list_stats_meta( $post ) {
|
|||||||
|
|
||||||
// Create entry for each player in totals
|
// Create entry for each player in totals
|
||||||
$totals = array();
|
$totals = array();
|
||||||
|
$placeholders = array();
|
||||||
|
|
||||||
foreach ( $player_ids as $player_id ):
|
foreach ( $player_ids as $player_id ):
|
||||||
if ( ! $player_id )
|
if ( ! $player_id )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$totals[ $player_id ] = array( 'eventsattended' => 0, 'eventsplayed' => 0 );
|
$totals[ $player_id ] = array( 'eventsattended' => 0, 'eventsplayed' => 0 );
|
||||||
|
|
||||||
foreach ( $metric_labels as $key => $value ):
|
foreach ( $metric_labels as $key => $value ):
|
||||||
$totals[ $player_id ][ $key ] = 0;
|
$totals[ $player_id ][ $key ] = 0;
|
||||||
endforeach;
|
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;
|
endforeach;
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
@@ -150,10 +164,9 @@ function sp_list_stats_meta( $post ) {
|
|||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
// Generate placeholder values for each team
|
// Generate placeholder values for each team
|
||||||
$placeholders = array();
|
|
||||||
foreach ( $player_ids as $player_id ):
|
foreach ( $player_ids as $player_id ):
|
||||||
$placeholders[ $player_id ] = array();
|
|
||||||
foreach ( $equations as $key => $value ):
|
foreach ( $equations as $key => $value ):
|
||||||
|
if ( sp_array_value( $placeholders[ $player_id ], $key, '' ) == '' ):
|
||||||
|
|
||||||
if ( empty( $value ) ):
|
if ( empty( $value ) ):
|
||||||
|
|
||||||
@@ -167,6 +180,8 @@ function sp_list_stats_meta( $post ) {
|
|||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
endforeach;
|
endforeach;
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ function sp_table_stats_meta( $post ) {
|
|||||||
$placeholders = array();
|
$placeholders = array();
|
||||||
|
|
||||||
foreach ( $team_ids as $team_id ):
|
foreach ( $team_ids as $team_id ):
|
||||||
|
if ( ! $team_id )
|
||||||
|
continue;
|
||||||
|
|
||||||
$totals[ $team_id ] = array( 'eventsplayed' => 0 );
|
$totals[ $team_id ] = array( 'eventsplayed' => 0 );
|
||||||
|
|
||||||
foreach ( $result_labels as $key => $value ):
|
foreach ( $result_labels as $key => $value ):
|
||||||
@@ -94,6 +97,7 @@ function sp_table_stats_meta( $post ) {
|
|||||||
$totals[ $team_id ][ $key ] = 0;
|
$totals[ $team_id ][ $key ] = 0;
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
|
// Get statis stats
|
||||||
$static = get_post_meta( $team_id, 'sp_stats', true );
|
$static = get_post_meta( $team_id, 'sp_stats', true );
|
||||||
|
|
||||||
// Create placeholders entry for the team
|
// Create placeholders entry for the team
|
||||||
|
|||||||
Reference in New Issue
Block a user