Add option to show and hide players in events

This commit is contained in:
Brian Miyaji
2014-06-22 13:01:01 +10:00
parent 885fe21a41
commit f6315d35ef
2 changed files with 17 additions and 6 deletions

View File

@@ -90,11 +90,20 @@ class SP_Settings_Events extends SP_Settings_Page {
),
array(
'title' => __( 'Player Performance', 'sportspress' ),
'title' => __( 'Players', 'sportspress' ),
'desc' => __( 'Display players', 'sportspress' ),
'id' => 'sportspress_event_show_players',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Link players', 'sportspress' ),
'id' => 'sportspress_event_link_players',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(

View File

@@ -26,6 +26,7 @@ $performance = array_filter( $performance );
$teams = (array)get_post_meta( $id, 'sp_team', false );
$status = $event->status();
$show_players = get_option( 'sportspress_event_show_players', 'yes' ) == 'yes' ? true : false;
$link_posts = get_option( 'sportspress_event_link_players', 'yes' ) == 'yes' ? true : false;
$sortable = get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false;
$responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false;
@@ -61,7 +62,7 @@ foreach( $teams as $index => $team_id ):
<?php endforeach; ?>
</tr>
</thead>
<?php if ( $has_players ): ?>
<?php if ( $show_players && $has_players ): ?>
<tbody>
<?php
@@ -143,7 +144,7 @@ foreach( $teams as $index => $team_id ):
</tbody>
<?php endif; ?>
<?php if ( $status == 'results' && array_key_exists( 0, $data ) ): ?>
<<?php echo ( $has_players ? 'tfoot' : 'tbody' ); ?>>
<<?php echo ( $show_players && $has_players ? 'tfoot' : 'tbody' ); ?>>
<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">
<?php
if ( $has_players ):
@@ -154,10 +155,11 @@ foreach( $teams as $index => $team_id ):
$row = $data[0];
foreach( $labels as $key => $label ):
if ( $key == 'name' ):
if ( $key == 'name' )
continue;
endif;
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
if ( $key == 'position' ):
$value = '&mdash;';
elseif ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
$value = $row[ $key ];
else:
$value = sp_array_value( $totals, $key, 0 );