diff --git a/includes/admin/settings/class-sp-settings-players.php b/includes/admin/settings/class-sp-settings-players.php index c7a918e0..478e394e 100644 --- a/includes/admin/settings/class-sp-settings-players.php +++ b/includes/admin/settings/class-sp-settings-players.php @@ -148,6 +148,17 @@ class SP_Settings_Players extends SP_Settings_Page { 'manual' => __( 'Manual', 'sportspress' ), ), ), + + array( + 'title' => __( 'Mode', 'sportspress' ), + 'id' => 'sportspress_player_statistics_mode', + 'default' => 'values', + 'type' => 'radio', + 'options' => array( + 'values' => __( 'Values', 'sportspress' ), + 'icons' => __( 'Icons', 'sportspress' ), + ), + ), array( 'title' => __( 'Categories', 'sportspress' ), diff --git a/includes/class-sp-player-list.php b/includes/class-sp-player-list.php index b66ba107..fe5fea27 100644 --- a/includes/class-sp-player-list.php +++ b/includes/class-sp-player-list.php @@ -213,8 +213,19 @@ class SP_Player_List extends SP_Secondary_Post { // Add precision to object $stat->precision = sp_array_value( sp_array_value( $meta, 'sp_precision', array() ), 0, 0 ) + 0; - // Add column name to columns - $columns[ $stat->post_name ] = $stat->post_title; + // Add column icons to columns were is available + if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' && ( $stat->post_type == 'sp_performance' || $stat->post_type == 'sp_statistic' ) ) { + $icon = apply_filters( 'sportspress_event_performance_icons', '', $stat->ID, 1 ); + if ( $icon != '' ) { + $columns[ $stat->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $stat->ID, 1 ); + }else{ + $columns[ $stat->post_name ] = $stat->post_title; + } + }else{ + $columns[ $stat->post_name ] = $stat->post_title; + } + // Add columns titles for using with data-label + $columns_title[ $stat->post_name ] = $stat->post_title; // Add format $format = get_post_meta( $stat->ID, 'sp_format', true ); @@ -669,16 +680,20 @@ class SP_Player_List extends SP_Secondary_Post { foreach( $this->columns as $key ): if ( $key == 'number' ): $labels[ $key ] = '#'; + $labels_title[ $key ] = '#'; elseif ( $key == 'team' ): $labels[ $key ] = __( 'Team', 'sportspress' ); + $labels_title[ $key ] = __( 'Team', 'sportspress' ); elseif ( $key == 'position' ): $labels[ $key ] = __( 'Position', 'sportspress' ); + $labels_title[ $key ] = __( 'Position', 'sportspress' ); elseif ( array_key_exists( $key, $columns ) ): $labels[ $key ] = $columns[ $key ]; + $labels_title[ $key ] = $columns_title[ $key ]; endif; endforeach; - return array( $labels, $data, $placeholders, $merged, $orderby ); + return array( $labels, $labels_title, $data, $placeholders, $merged, $orderby ); else: // Convert to time notation @@ -716,10 +731,18 @@ class SP_Player_List extends SP_Secondary_Post { $labels = array(); if ( in_array( 'number', $this->columns ) ) $labels['number'] = '#'; $labels['name'] = __( 'Player', 'sportspress' ); - if ( in_array( 'team', $this->columns ) ) $labels['team'] = __( 'Team', 'sportspress' ); - if ( in_array( 'position', $this->columns ) ) $labels['position'] = __( 'Position', 'sportspress' ); + $labels_title['name'] = __( 'Player', 'sportspress' ); + if ( in_array( 'team', $this->columns ) ) { + $labels['team'] = __( 'Team', 'sportspress' ); + $labels_title['team'] = __( 'Team', 'sportspress' ); + } + if ( in_array( 'position', $this->columns ) ) { + $labels['position'] = __( 'Position', 'sportspress' ); + $labels_title['position'] = __( 'Position', 'sportspress' ); + } - $merged[0] = array_merge( $labels, $columns ); + $merged['head'] = array_merge( $labels, $columns ); + $merged[0] = array_merge( $labels, $columns_title ); return $merged; endif; } diff --git a/templates/player-list.php b/templates/player-list.php index 723aa263..900678fd 100644 --- a/templates/player-list.php +++ b/templates/player-list.php @@ -53,17 +53,21 @@ if ( isset( $columns ) && null !== $columns ): endif; $data = $list->data(); -// The first row should be column labels +// The first row should be data-label labels $labels = $data[0]; +// The 'head' row should be column labels +$labels_head = $data['head']; + //Create a unique identifier based on the current time in microseconds $identifier = uniqid( 'playerlist_' ); // If responsive tables are enabled then load the inline css code if ( true == $responsive ){ //sportspress_responsive_tables_css( $identifier ); } -// Remove the first row to leave us with the actual data +// Remove the first row and 'head' row to leave us with the actual data unset( $data[0] ); +unset( $data['head'] ); if ( $grouping === null || $grouping === 'default' ): $grouping = $list->grouping; @@ -223,7 +227,7 @@ foreach ( $groups as $group ): endif; endif; - foreach( $labels as $key => $label ): + foreach( $labels_head as $key => $label ): if ( $key !== 'number' && ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) ) ) $output .= ''. $label . ''; endforeach;