diff --git a/assets/css/admin.css b/assets/css/admin.css index a83088f1..df5e6e22 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -145,6 +145,10 @@ font-family: monospace; } +.sp-data-table-container { + overflow: auto; +} + table.widefat.sp-data-table img { vertical-align: top; } diff --git a/includes/class-sp-player-list.php b/includes/class-sp-player-list.php index 3238c324..f5aa0731 100644 --- a/includes/class-sp-player-list.php +++ b/includes/class-sp-player-list.php @@ -81,11 +81,14 @@ class SP_Player_List extends SP_Custom_Post { $totals[ $player_id ][ $key ] = 0; endforeach; + // Get metrics + $metrics = get_post_meta( $player_id, 'sp_metrics', true ); + // Get static stats $static = get_post_meta( $player_id, 'sp_statistics', true ); - // Add static stats to placeholders - $placeholders[ $player_id ] = sp_array_value( sp_array_value( $static, $league_id, array() ), $div_id, array() ); + // Add metrics and static stats to placeholders + $placeholders[ $player_id ] = array_merge( $metrics, sp_array_value( sp_array_value( $static, $league_id, array() ), $div_id, array() ) ); endforeach; @@ -219,7 +222,7 @@ class SP_Player_List extends SP_Custom_Post { endforeach; $args = array( - 'post_type' => 'sp_statistic', + 'post_type' => array( 'sp_metric', 'sp_statistic' ), 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', @@ -235,7 +238,7 @@ class SP_Player_List extends SP_Custom_Post { $meta = get_post_meta( $stat->ID ); // 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 ); // Add column name to columns @@ -251,11 +254,15 @@ class SP_Player_List extends SP_Custom_Post { foreach ( $stats as $stat ): if ( sp_array_value( $placeholders[ $player_id ], $stat->post_name, '' ) == '' ): - // Solve - $placeholder = sp_solve( $stat->equation, sp_array_value( $totals, $player_id, array() ), $stat->precision ); + if ( $stat->equation == null ): + $placeholder = '-'; + else: + // Solve + $placeholder = sp_solve( $stat->equation, sp_array_value( $totals, $player_id, array() ), $stat->precision ); - // Adjustments - $placeholder += sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $stat->post_name, 0 ); + // Adjustments + $placeholder += sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $stat->post_name, 0 ); + endif; $placeholders[ $player_id ][ $stat->post_name ] = $placeholder; endif;