diff --git a/assets/css/menu.css b/assets/css/menu.css index c8ccc53e..0853cf87 100644 --- a/assets/css/menu.css +++ b/assets/css/menu.css @@ -124,7 +124,7 @@ .sp-icon-statistics:before { content: "\f489"; } -.sp-icon-stopwatch:before { +.sp-icon-time:before { content: "\f469"; } .sp-icon-ticket:before { diff --git a/assets/js/admin/sportspress-admin.js b/assets/js/admin/sportspress-admin.js index dd71d6bb..a4f05ce6 100644 --- a/assets/js/admin/sportspress-admin.js +++ b/assets/js/admin/sportspress-admin.js @@ -220,7 +220,7 @@ jQuery(document).ready(function($){ if(event.keyCode == 40){ row += 1; } - $el.closest("tbody").find("tr:nth-child("+row+") td:nth-child("+col+") input:text").focus(); + $el.closest("tbody").find("tr:nth-child("+row+") td:nth-child("+col+") input:text").first().focus(); } }); 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 ec609e18..3775fe4e 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 @@ -22,6 +22,11 @@ class SP_Meta_Box_Event_Performance { $event = new SP_Event( $post ); list( $labels, $columns, $stats, $teams, $formats, $order ) = $event->performance( true ); + if ( 'yes' == get_option( 'sportspress_event_performance_show_time', 'yes' ) ) + $timeline = $event->timeline( true ); + else + $timeline = false; + // Determine if columns are auto or manual if ( 'manual' == get_option( 'sportspress_event_performance_columns', 'auto' ) ) $manual = true; @@ -60,7 +65,7 @@ class SP_Meta_Box_Event_Performance { // Check if individual mode $is_individual = get_option( 'sportspress_load_individual_mode_module', 'no' ) === 'yes' ? true : false; - self::tables( $post->ID, $stats, $labels, $columns, $teams, $has_checkboxes, $positions, $status, $formats, $order, $numbers, $is_individual ); + self::tables( $post->ID, $stats, $labels, $columns, $teams, $has_checkboxes, $positions, $status, $formats, $order, $numbers, $is_individual, $timeline ); } /** @@ -70,12 +75,13 @@ class SP_Meta_Box_Event_Performance { update_post_meta( $post_id, 'sp_players', sp_array_value( $_POST, 'sp_players', array() ) ); update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) ); update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) ); + update_post_meta( $post_id, 'sp_timeline', sp_array_value( $_POST, 'sp_timeline', array() ) ); } /** * Admin edit tables */ - public static function tables( $post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $positions = array(), $status = true, $formats = array(), $order = array(), $numbers = true, $is_individual = false ) { + public static function tables( $post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $positions = array(), $status = true, $formats = array(), $order = array(), $numbers = true, $is_individual = false, $timeline = array() ) { $sections = get_option( 'sportspress_event_performance_sections', -1 ); if ( $is_individual ) { @@ -94,8 +100,23 @@ class SP_Meta_Box_Event_Performance { $players[] = -1; $data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) ); + // Get team timeline + if ( is_array( $timeline ) ): + $team_timeline = (array) sp_array_value( $timeline, $team_id, array() ); + else: + $team_timeline = false; + endif; + foreach ( $data as $player_id => $player_performance ): - self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, false, $numbers, -1, $formats ); + + // Get player timeline + if ( is_array( $team_timeline ) ): + $player_timeline = (array) sp_array_value( $team_timeline, $player_id, array() ); + else: + $player_timeline = false; + endif; + + self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, false, $numbers, -1, $formats, $player_timeline ); endforeach; endforeach; ?> @@ -114,10 +135,17 @@ class SP_Meta_Box_Event_Performance { $players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key ); $players[] = -1; $data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) ); + + // Get team timeline + if ( is_array( $timeline ) ): + $team_timeline = (array) sp_array_value( $timeline, $team_id, array() ); + else: + $team_timeline = false; + endif; ?>
- +
—
- +|
+
+
+ + + + |
diff --git a/includes/admin/settings/class-sp-settings-events.php b/includes/admin/settings/class-sp-settings-events.php
index 8d45459c..39090933 100644
--- a/includes/admin/settings/class-sp-settings-events.php
+++ b/includes/admin/settings/class-sp-settings-events.php
@@ -351,8 +351,8 @@ class SP_Settings_Events extends SP_Settings_Page {
),
array(
- 'title' => __( 'Players', 'sportspress' ),
- 'desc' => __( 'Display squad numbers', 'sportspress' ),
+ 'title' => __( 'Display', 'sportspress' ),
+ 'desc' => __( 'Squad Number', 'sportspress' ),
'id' => 'sportspress_event_show_player_numbers',
'default' => 'yes',
'type' => 'checkbox',
@@ -360,12 +360,20 @@ class SP_Settings_Events extends SP_Settings_Page {
),
array(
- 'desc' => __( 'Display positions', 'sportspress' ),
+ 'desc' => __( 'Position', 'sportspress' ),
'id' => 'sportspress_event_show_position',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
+
+ array(
+ 'desc' => __( 'Time', 'sportspress' ),
+ 'id' => 'sportspress_event_performance_show_time',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'end',
+ ),
array(
'title' => __( 'Performance', 'sportspress' ),
diff --git a/includes/class-sp-event.php b/includes/class-sp-event.php
index d32fc953..ca13f16a 100644
--- a/includes/class-sp-event.php
+++ b/includes/class-sp-event.php
@@ -164,10 +164,47 @@ class SP_Event extends SP_Custom_Post{
if ( 'no' == get_option( 'sportspress_event_show_player_numbers', 'yes' ) ):
unset( $labels['number'] );
endif;
+
+ if ( 'yes' == get_option( 'sportspress_event_performance_show_time', 'yes' ) ):
+ $timeline = $this->timeline();
+ if ( ! empty( $timeline ) ):
+ foreach ( $performance as $team => $players ):
+
+ // Get team timeline
+ $team_timeline = sp_array_value( $timeline, $team, array() );
+ if ( empty( $team_timeline ) ) continue;
+
+ foreach ( $players as $player => $player_performance ):
+ if ( ! $player_id ) continue;
+
+ // Get player timeline
+ $player_timeline = sp_array_value( $team_timeline, $player, array() );
+ if ( empty( $player_timeline ) ) continue;
+
+ foreach ( $player_performance as $performance_key => $performance_value ):
+
+ // Get performance times
+ $times = sp_array_value( $player_timeline, $performance_key, array() );
+ $times = array_filter( $times );
+ if ( empty( $times ) ) continue;
+
+ $performance[ $team ][ $player ][ $performance_key ] .= ' (' . implode( '\', ', $times ) . '\')';
+ endforeach;
+ endforeach;
+ endforeach;
+ endif;
+ endif;
+
+ // Add labels to box score
$performance[0] = $labels;
+
return apply_filters( 'sportspress_get_event_performance', $performance );
endif;
}
+
+ public function timeline( $admin = false) {
+ return (array) get_post_meta( $this->ID, 'sp_timeline', true );
+ }
public function main_results() {
// Get main result option
diff --git a/includes/class-sp-install.php b/includes/class-sp-install.php
index 3675e2b1..242f39ee 100644
--- a/includes/class-sp-install.php
+++ b/includes/class-sp-install.php
@@ -407,6 +407,7 @@ class SP_Install {
if ( version_compare( $version, '2.1', '<' ) ) {
update_option( 'sportspress_player_show_selector', 'no' );
+ update_option( 'sportspress_event_performance_show_time', 'no' );
}
}
diff --git a/modules/sportspress-icons.php b/modules/sportspress-icons.php
index 248dda2a..1f27e990 100644
--- a/modules/sportspress-icons.php
+++ b/modules/sportspress-icons.php
@@ -106,7 +106,12 @@ class SportsPress_Icons {
if ( null !== $icon && in_array( $icon, $this->icons ) ) {
$title = get_the_title( $id );
$color = get_post_meta( $id, 'sp_color', true );
- $icons = str_repeat( '' . ' ', $value );
+ preg_match( '#\((.*?)\)#', $value, $match );
+ if ( ! empty( $match ) && isset( $match[1] ) ) {
+ $icons = ' ' . $match[1] . '