Enable individual players to compete in events

This commit is contained in:
Brian Miyaji
2014-12-10 04:11:08 +11:00
parent e90e32af8b
commit 46cd25d73d
7 changed files with 54 additions and 22 deletions

View File

@@ -125,6 +125,8 @@ class SP_Admin_Meta_Boxes {
add_meta_box( 'sp_videodiv', __( 'Video', 'sportspress' ), 'SP_Meta_Box_Event_Video::output', 'sp_event', 'side', 'low' );
if ( sizeof( array_filter( sp_array_value( $post_meta, 'sp_team', array() ) ) ) ):
add_meta_box( 'sp_resultsdiv', __( 'Team Results', 'sportspress' ), 'SP_Meta_Box_Event_Results::output', 'sp_event', 'normal', 'high' );
endif;
if ( sizeof( array_filter( sp_array_value( $post_meta, 'sp_player', array() ) ) ) ):
add_meta_box( 'sp_performancediv', __( 'Player Performance', 'sportspress' ), 'SP_Meta_Box_Event_Performance::output', 'sp_event', 'normal', 'high' );
endif;
add_meta_box( 'sp_editordiv', __( 'Article', 'sportspress' ), 'SP_Meta_Box_Event_Editor::output', 'sp_event', 'normal', 'low' );

View File

@@ -25,7 +25,7 @@ class SP_Meta_Box_Event_Performance {
$i = 0;
foreach ( $teams as $key => $team_id ):
if ( ! $team_id ) continue;
if ( -1 == $team_id ) continue;
// Get results for players in the team
$players = sp_array_between( (array)get_post_meta( $post->ID, 'sp_player', false ), 0, $key );
@@ -33,7 +33,11 @@ class SP_Meta_Box_Event_Performance {
?>
<div>
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
<?php if ( $team_id ): ?>
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
<?php elseif ( $i ): ?>
<br>
<?php endif; ?>
<?php self::table( $labels, $columns, $data, $team_id, $i == 0 ); ?>
</div>
<?php
@@ -83,7 +87,9 @@ class SP_Meta_Box_Event_Performance {
<?php endif; ?>
</th>
<?php endforeach; ?>
<th><?php _e( 'Status', 'sportspress' ); ?></th>
<?php if ( $team_id ): ?>
<th><?php _e( 'Status', 'sportspress' ); ?></th>
<?php endif; ?>
</tr>
</thead>
<tfoot>
@@ -99,7 +105,9 @@ class SP_Meta_Box_Event_Performance {
?>
<td><input type="text" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="0" /></td>
<?php endforeach; ?>
<td>&nbsp;</td>
<?php if ( $team_id ): ?>
<td>&nbsp;</td>
<?php endif; ?>
</tr>
</tfoot>
<tbody>
@@ -137,10 +145,12 @@ class SP_Meta_Box_Event_Performance {
<input class="sp-player-<?php echo $column; ?>-input" type="text" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="0" />
</td>
<?php endforeach; ?>
<td class="sp-status-selector">
<?php echo self::status_select( $team_id, $player_id, sp_array_value( $player_performance, 'status', null ) ); ?>
<?php echo self::sub_select( $team_id, $player_id, sp_array_value( $player_performance, 'sub', null ), $data ); ?>
</td>
<?php if ( $team_id ): ?>
<td class="sp-status-selector">
<?php echo self::status_select( $team_id, $player_id, sp_array_value( $player_performance, 'status', null ) ); ?>
<?php echo self::sub_select( $team_id, $player_id, sp_array_value( $player_performance, 'sub', null ), $data ); ?>
</td>
<?php endif; ?>
</tr>
<?php
endforeach;

View File

@@ -59,10 +59,12 @@ class SP_Meta_Box_Event_Teams {
'post_type' => 'sp_team',
'name' => 'sp_team[]',
'class' => 'sportspress-pages',
'show_option_none' => sprintf( __( '&mdash; None &mdash;', 'sportspress' ), 'Team' ),
'show_option_none' => __( '&mdash; None &mdash;', 'sportspress' ),
'show_option_all' => __( '&mdash; Individual &mdash;', 'sportspress' ),
'values' => 'ID',
'selected' => $team,
);
wp_dropdown_pages( $args );
sp_dropdown_pages( $args );
?>
</p>
<ul id="sp_team-tabs" class="wp-tab-bar sp-tab-bar">

View File

@@ -103,6 +103,7 @@ class SP_Meta_Box_Player_Statistics {
'post_type' => 'sp_team',
'name' => 'sp_leagues[' . $league_id . '][' . $div_id . ']',
'show_option_none' => __( '&mdash; None &mdash;', 'sportspress' ),
'show_option_all' => __( '&mdash; Individual &mdash;', 'sportspress' ),
'sort_order' => 'ASC',
'sort_column' => 'menu_order',
'selected' => $value,