Option to hide total player performance in event

This commit is contained in:
Brian Miyaji
2014-07-20 00:03:04 +10:00
parent cb492ac7a2
commit 77cb3cdbec
2 changed files with 16 additions and 4 deletions

View File

@@ -82,7 +82,7 @@ class SP_Settings_Events extends SP_Settings_Page {
), ),
array( array(
'title' => __( 'Players', 'sportspress' ), 'title' => __( 'Player Performance', 'sportspress' ),
'desc' => __( 'Display players', 'sportspress' ), 'desc' => __( 'Display players', 'sportspress' ),
'id' => 'sportspress_event_show_players', 'id' => 'sportspress_event_show_players',
'default' => 'yes', 'default' => 'yes',
@@ -95,6 +95,14 @@ class SP_Settings_Events extends SP_Settings_Page {
'id' => 'sportspress_event_link_players', 'id' => 'sportspress_event_link_players',
'default' => 'yes', 'default' => 'yes',
'type' => 'checkbox', 'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Display total', 'sportspress' ),
'id' => 'sportspress_event_show_total',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end', 'checkboxgroup' => 'end',
), ),

View File

@@ -4,7 +4,7 @@
* *
* @author ThemeBoy * @author ThemeBoy
* @package SportsPress/Templates * @package SportsPress/Templates
* @version 1.2 * @version 1.2.1
*/ */
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -39,11 +39,15 @@ if ( is_array( $teams ) ):
$players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index ); $players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index );
$has_players = sizeof( $players ) > 1; $has_players = sizeof( $players ) > 1;
if ( ! $has_players && $status != 'results' ) continue; if ( ! $has_players ):
if ( $status != 'results' ) continue;
elseif ( get_option( 'sportspress_event_show_total', 'yes' ) != 'yes' ) continue;
endif;
$totals = array(); $totals = array();
$data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) ); $data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
?> ?>
<h4 class="sp-table=caption"><?php echo get_the_title( $team_id ); ?></h4> <h4 class="sp-table=caption"><?php echo get_the_title( $team_id ); ?></h4>
<?php <?php
@@ -144,7 +148,7 @@ if ( is_array( $teams ) ):
?> ?>
</tbody> </tbody>
<?php endif; ?> <?php endif; ?>
<?php if ( $status == 'results' && array_key_exists( 0, $data ) ): ?> <?php if ( $status == 'results' && get_option( 'sportspress_event_show_total', 'yes' ) == 'yes' && array_key_exists( 0, $data ) ): ?>
<<?php echo ( $show_players && $has_players ? 'tfoot' : 'tbody' ); ?>> <<?php echo ( $show_players && $has_players ? 'tfoot' : 'tbody' ); ?>>
<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '"> <tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">
<?php <?php