Move extras to extension
This commit is contained in:
@@ -22,6 +22,17 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
$event = new SP_Event( $post );
|
$event = new SP_Event( $post );
|
||||||
list( $labels, $columns, $stats, $teams ) = $event->performance( true );
|
list( $labels, $columns, $stats, $teams ) = $event->performance( true );
|
||||||
|
|
||||||
|
// Determine if we are splitting positions
|
||||||
|
if ( 'yes' == get_option( 'sportspress_event_split_players_by_position', 'no' ) )
|
||||||
|
$split_positions = true;
|
||||||
|
else
|
||||||
|
$split_positions = false;
|
||||||
|
|
||||||
|
if ( 'manual' == get_option( 'sportspress_event_performance_columns', 'auto' ) )
|
||||||
|
$manual = true;
|
||||||
|
else
|
||||||
|
$manual = false;
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
foreach ( $teams as $key => $team_id ):
|
foreach ( $teams as $key => $team_id ):
|
||||||
@@ -33,32 +44,24 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||||
|
|
||||||
// Determine if we need checkboxes
|
// Determine if we need checkboxes
|
||||||
if ( 'manual' == get_option( 'sportspress_event_performance_columns', 'auto' ) && $i == 0 )
|
if ( $manual && $i == 0 )
|
||||||
$has_checkboxes = true;
|
$has_checkboxes = true;
|
||||||
else
|
else
|
||||||
$has_checkboxes = false;
|
$has_checkboxes = false;
|
||||||
|
|
||||||
// Determine if we need extras
|
|
||||||
if ( 'yes' == get_option( 'sportspress_event_show_extras', 'no' ) )
|
|
||||||
$show_extras = true;
|
|
||||||
else
|
|
||||||
$show_extras = false;
|
|
||||||
|
|
||||||
// Determine if we are splitting positions
|
|
||||||
if ( 'yes' == get_option( 'sportspress_event_split_players_by_position', 'no' ) )
|
|
||||||
$split_positions = true;
|
|
||||||
else
|
|
||||||
$split_positions = false;
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
<?php if ( get_option( 'sportspress_event_split_players_by_team' ) ) { ?>
|
||||||
<div>
|
<div>
|
||||||
<?php if ( $team_id ): ?>
|
<?php if ( $team_id ): ?>
|
||||||
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
|
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
|
||||||
<?php elseif ( $i ): ?>
|
<?php elseif ( $i ): ?>
|
||||||
<br>
|
<br>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php self::table( $labels, $columns, $data, $team_id, $has_checkboxes, $show_extras, $split_positions ); ?>
|
<?php self::table( $labels, $columns, $data, $team_id, $has_checkboxes, $split_positions ); ?>
|
||||||
</div>
|
</div>
|
||||||
|
<?php } else { ?>
|
||||||
|
<?php self::table( $labels, $columns, $data, $team_id, $has_checkboxes, $split_positions ); ?>
|
||||||
|
<?php } ?>
|
||||||
<?php
|
<?php
|
||||||
$i ++;
|
$i ++;
|
||||||
endforeach;
|
endforeach;
|
||||||
@@ -75,7 +78,7 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
/**
|
/**
|
||||||
* Admin edit table
|
* Admin edit table
|
||||||
*/
|
*/
|
||||||
public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false, $show_extras = false, $split_positions = false ) {
|
public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false, $split_positions = false ) {
|
||||||
?>
|
?>
|
||||||
<div class="sp-data-table-container">
|
<div class="sp-data-table-container">
|
||||||
<table class="widefat sp-data-table sp-performance-table sp-sortable-table">
|
<table class="widefat sp-data-table sp-performance-table sp-sortable-table">
|
||||||
@@ -111,22 +114,7 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<?php if ( $show_extras ) { ?>
|
<?php do_action( 'sportspress_event_performance_meta_box_table_footer', $data, $labels, $team_id ); ?>
|
||||||
<tr class="sp-row sp-post sp-extras">
|
|
||||||
<td> </td>
|
|
||||||
<td> </td>
|
|
||||||
<td><strong><?php _e( 'Extras', 'sportspress' ); ?></strong></td>
|
|
||||||
<td> </td>
|
|
||||||
<?php foreach( $labels as $column => $label ):
|
|
||||||
$player_id = -1;
|
|
||||||
$player_performance = sp_array_value( $data, $player_id, array() );
|
|
||||||
$value = sp_array_value( $player_performance, $column, '' );
|
|
||||||
?>
|
|
||||||
<td><input type="text" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" /></td>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<td> </td>
|
|
||||||
</tr>
|
|
||||||
<?php } ?>
|
|
||||||
<tr class="sp-row sp-total">
|
<tr class="sp-row sp-total">
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
@@ -145,7 +133,21 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
foreach ( $data as $player_id => $player_performance ):
|
foreach ( $data as $player_id => $player_performance ):
|
||||||
if ( $player_id <= 0 ) continue;
|
self::row( $labels, $player_id, $player_performance, $team_id, $data );
|
||||||
|
endforeach;
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Admin edit table row
|
||||||
|
*/
|
||||||
|
public static function row( $labels = array(), $player_id = 0, $player_performance = array(), $team_id = 0, $data = array() ) {
|
||||||
|
if ( $player_id <= 0 ) return;
|
||||||
|
|
||||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||||
$value = sp_array_value( $player_performance, 'number', '' );
|
$value = sp_array_value( $player_performance, 'number', '' );
|
||||||
?>
|
?>
|
||||||
@@ -212,12 +214,6 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
endforeach;
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -228,10 +224,10 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
if ( ! $team_id || ! $player_id )
|
if ( ! $team_id || ! $player_id )
|
||||||
return '—';
|
return '—';
|
||||||
|
|
||||||
$options = array(
|
$options = apply_filters( 'sportspress_event_performance_status_options', array(
|
||||||
'lineup' => __( 'Starting Lineup', 'sportspress' ),
|
'lineup' => __( 'Starting Lineup', 'sportspress' ),
|
||||||
'sub' => __( 'Substitute', 'sportspress' ),
|
'sub' => __( 'Substitute', 'sportspress' ),
|
||||||
);
|
) );
|
||||||
|
|
||||||
$output = '<select name="sp_players[' . $team_id . '][' . $player_id . '][status]">';
|
$output = '<select name="sp_players[' . $team_id . '][' . $player_id . '][status]">';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user