From 2b26d1166fd401f49dda7398183ebaec5da910ef Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Wed, 2 Mar 2016 23:09:43 +1100 Subject: [PATCH] Add player performance format selector --- includes/admin/class-sp-admin-sports.php | 1 + .../class-sp-meta-box-event-performance.php | 19 +++++++++++++++---- .../class-sp-meta-box-performance-details.php | 4 ++-- templates/event-performance-table.php | 7 ++++--- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/includes/admin/class-sp-admin-sports.php b/includes/admin/class-sp-admin-sports.php index c329636b..954c23a0 100644 --- a/includes/admin/class-sp-admin-sports.php +++ b/includes/admin/class-sp-admin-sports.php @@ -167,6 +167,7 @@ class SP_Admin_Sports { update_post_meta( $id, 'sp_icon', sp_array_value( $performance, 'icon', null ) ); update_post_meta( $id, 'sp_color', sp_array_value( $performance, 'color', null ) ); update_post_meta( $id, 'sp_section', sp_array_value( $performance, 'section', -1 ) ); + update_post_meta( $id, 'sp_format', sp_array_value( $performance, 'format', 'number' ) ); $i ++; } diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php index 6e3ab3e0..825a52ca 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php @@ -202,10 +202,21 @@ class SP_Meta_Box_Event_Performance { $player ) { + if ( ! array_key_exists( $key, $players ) ) { + $players[ $key ] = $player; + } + } + $data = $players; } foreach ( $data as $player_id => $player_performance ): self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, true, $numbers, $section, $formats ); @@ -248,7 +259,7 @@ class SP_Meta_Box_Event_Performance { - + @@ -286,7 +297,7 @@ class SP_Meta_Box_Event_Performance { ?> - +   @@ -349,7 +360,7 @@ class SP_Meta_Box_Event_Performance { - + diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-details.php index 71b13d22..caa9d8da 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-performance-details.php @@ -49,7 +49,7 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config { __( 'All', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) ); foreach ( $options as $key => $value ): - printf( '', $key, selected( $key == $section ), $value ); + printf( '', $key, selected( $key == $section, true, false ), $value ); endforeach; ?> @@ -60,7 +60,7 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config { __( 'Number', 'sportspress' ), 'text' => __( 'Text', 'sportspress' ) ) ); foreach ( $options as $key => $value ): - printf( '', $key, selected( $key == $format ), $value ); + printf( '', $key, selected( $key == $format, true, false ), $value ); endforeach; ?> diff --git a/templates/event-performance-table.php b/templates/event-performance-table.php index 94a93deb..2d853aa6 100644 --- a/templates/event-performance-table.php +++ b/templates/event-performance-table.php @@ -13,7 +13,8 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly $totals = array(); // Set null -if ( ! isset( $section ) ) $section = null; +if ( ! isset( $section ) ) $section = -1; +if ( ! isset( $section_label ) ) $section_label = null; if ( ! isset( $class ) ) $class = null; // Initialize arrays @@ -33,8 +34,8 @@ if ( ! isset( $subs ) ) $subs = array(); # - - + +