Enable metrics display in player list
This commit is contained in:
@@ -145,6 +145,10 @@
|
|||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sp-data-table-container {
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
table.widefat.sp-data-table img {
|
table.widefat.sp-data-table img {
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,11 +81,14 @@ class SP_Player_List extends SP_Custom_Post {
|
|||||||
$totals[ $player_id ][ $key ] = 0;
|
$totals[ $player_id ][ $key ] = 0;
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
|
// Get metrics
|
||||||
|
$metrics = get_post_meta( $player_id, 'sp_metrics', true );
|
||||||
|
|
||||||
// Get static stats
|
// Get static stats
|
||||||
$static = get_post_meta( $player_id, 'sp_statistics', true );
|
$static = get_post_meta( $player_id, 'sp_statistics', true );
|
||||||
|
|
||||||
// Add static stats to placeholders
|
// Add metrics and static stats to placeholders
|
||||||
$placeholders[ $player_id ] = sp_array_value( sp_array_value( $static, $league_id, array() ), $div_id, array() );
|
$placeholders[ $player_id ] = array_merge( $metrics, sp_array_value( sp_array_value( $static, $league_id, array() ), $div_id, array() ) );
|
||||||
|
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
@@ -219,7 +222,7 @@ class SP_Player_List extends SP_Custom_Post {
|
|||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_statistic',
|
'post_type' => array( 'sp_metric', 'sp_statistic' ),
|
||||||
'numberposts' => -1,
|
'numberposts' => -1,
|
||||||
'posts_per_page' => -1,
|
'posts_per_page' => -1,
|
||||||
'orderby' => 'menu_order',
|
'orderby' => 'menu_order',
|
||||||
@@ -235,7 +238,7 @@ class SP_Player_List extends SP_Custom_Post {
|
|||||||
$meta = get_post_meta( $stat->ID );
|
$meta = get_post_meta( $stat->ID );
|
||||||
|
|
||||||
// Add equation to object
|
// Add equation to object
|
||||||
$stat->equation = sp_array_value( sp_array_value( $meta, 'sp_equation', array() ), 0, 0 );
|
$stat->equation = sp_array_value( sp_array_value( $meta, 'sp_equation', array() ), 0, null );
|
||||||
$stat->precision = sp_array_value( sp_array_value( $meta, 'sp_precision', array() ), 0, 0 );
|
$stat->precision = sp_array_value( sp_array_value( $meta, 'sp_precision', array() ), 0, 0 );
|
||||||
|
|
||||||
// Add column name to columns
|
// Add column name to columns
|
||||||
@@ -251,11 +254,15 @@ class SP_Player_List extends SP_Custom_Post {
|
|||||||
foreach ( $stats as $stat ):
|
foreach ( $stats as $stat ):
|
||||||
if ( sp_array_value( $placeholders[ $player_id ], $stat->post_name, '' ) == '' ):
|
if ( sp_array_value( $placeholders[ $player_id ], $stat->post_name, '' ) == '' ):
|
||||||
|
|
||||||
|
if ( $stat->equation == null ):
|
||||||
|
$placeholder = '-';
|
||||||
|
else:
|
||||||
// Solve
|
// Solve
|
||||||
$placeholder = sp_solve( $stat->equation, sp_array_value( $totals, $player_id, array() ), $stat->precision );
|
$placeholder = sp_solve( $stat->equation, sp_array_value( $totals, $player_id, array() ), $stat->precision );
|
||||||
|
|
||||||
// Adjustments
|
// Adjustments
|
||||||
$placeholder += sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $stat->post_name, 0 );
|
$placeholder += sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $stat->post_name, 0 );
|
||||||
|
endif;
|
||||||
|
|
||||||
$placeholders[ $player_id ][ $stat->post_name ] = $placeholder;
|
$placeholders[ $player_id ][ $stat->post_name ] = $placeholder;
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
Reference in New Issue
Block a user