Display team checkbox only once in player admin

This commit is contained in:
Brian Miyaji
2014-10-16 13:51:09 +11:00
parent cad627b28f
commit e81b94994b

View File

@@ -24,14 +24,17 @@ class SP_Meta_Box_Player_Statistics {
$league_num = sizeof( $leagues ); $league_num = sizeof( $leagues );
// Loop through statistics for each league // Loop through statistics for each league
if ( $leagues ): foreach ( $leagues as $league ): if ( $leagues ):
?> $i = 0;
<p><strong><?php echo $league->name; ?></strong></p> foreach ( $leagues as $league ):
<?php ?>
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = $player->data( $league->term_id, true ); <p><strong><?php echo $league->name; ?></strong></p>
self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams ); <?php
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = $player->data( $league->term_id, true );
endforeach; endif; self::table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, $i == 0 );
$i ++;
endforeach;
endif;
?> ?>
<p><strong><?php _e( 'Total', 'sportspress' ); ?></strong></p> <p><strong><?php _e( 'Total', 'sportspress' ); ?></strong></p>
<?php <?php
@@ -50,7 +53,7 @@ class SP_Meta_Box_Player_Statistics {
/** /**
* Admin edit table * Admin edit table
*/ */
public static function table( $id = null, $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $leagues = array(), $readonly = false ) { public static function table( $id = null, $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $leagues = array(), $has_checkboxes = false, $readonly = false ) {
$teams = array_filter( get_post_meta( $id, 'sp_team', false ) ); $teams = array_filter( get_post_meta( $id, 'sp_team', false ) );
?> ?>
<div class="sp-data-table-container"> <div class="sp-data-table-container">
@@ -59,10 +62,16 @@ class SP_Meta_Box_Player_Statistics {
<tr> <tr>
<th><?php _e( 'Season', 'sportspress' ); ?></th> <th><?php _e( 'Season', 'sportspress' ); ?></th>
<?php if ( $league_id ): ?> <?php if ( $league_id ): ?>
<th><label for="sp_columns_team"> <th>
<input type="checkbox" name="sp_columns[]" value="team" id="sp_columns_team" <?php checked( ! is_array( $columns ) || array_key_exists( 'team', $columns ) ); ?>> <?php if ( $has_checkboxes ): ?>
<?php _e( 'Team', 'sportspress' ); ?> <label for="sp_columns_team">
</label></th> <input type="checkbox" name="sp_columns[]" value="team" id="sp_columns_team" <?php checked( ! is_array( $columns ) || array_key_exists( 'team', $columns ) ); ?>>
<?php _e( 'Team', 'sportspress' ); ?>
</label>
<?php else: ?>
<?php _e( 'Team', 'sportspress' ); ?>
<?php endif; ?>
</th>
<?php endif; ?> <?php endif; ?>
<?php foreach ( $columns as $key => $label ): if ( $key == 'team' ) continue; ?> <?php foreach ( $columns as $key => $label ): if ( $key == 'team' ) continue; ?>
<th><?php echo $label; ?></th> <th><?php echo $label; ?></th>