Enable event player reordering
This commit is contained in:
@@ -55,7 +55,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false ) {
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table sp-performance-table">
|
||||
<table class="widefat sp-data-table sp-performance-table sp-sortable-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
@@ -77,12 +77,11 @@ class SP_Meta_Box_Event_Performance {
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ( $data as $player_id => $player_performance ):
|
||||
if ( !$player_id ) continue;
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>" data-player="<?php echo $player_id; ?>">
|
||||
<tr class="sp-row sp-post" data-player="<?php echo $player_id; ?>">
|
||||
<td><?php echo ( $number ? $number : ' ' ); ?></td>
|
||||
<td><?php echo get_the_title( $player_id ); ?></td>
|
||||
<?php foreach( $labels as $column => $label ):
|
||||
@@ -98,10 +97,11 @@ class SP_Meta_Box_Event_Performance {
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
?>
|
||||
<tr class="sp-row sp-total<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="sp-row sp-total">
|
||||
<td> </td>
|
||||
<td><strong><?php _e( 'Total', 'sportspress' ); ?></strong></td>
|
||||
<?php foreach( $labels as $column => $label ):
|
||||
@@ -113,7 +113,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
<?php endforeach; ?>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
@@ -252,13 +252,22 @@ if ( !function_exists( 'sp_array_value' ) ) {
|
||||
|
||||
if ( !function_exists( 'sp_array_combine' ) ) {
|
||||
function sp_array_combine( $keys = array(), $values = array() ) {
|
||||
if ( ! is_array( $keys ) ) return array();
|
||||
if ( ! is_array( $values ) ) $values = array();
|
||||
|
||||
$output = array();
|
||||
|
||||
foreach ( $values as $key => $value ):
|
||||
if ( in_array( $key, $keys ) ):
|
||||
$output[ $key ] = $value;
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
foreach ( $keys as $key ):
|
||||
if ( is_array( $values ) && array_key_exists( $key, $values ) )
|
||||
$output[ $key ] = $values[ $key ];
|
||||
else
|
||||
if ( ! array_key_exists( $key, $output ) )
|
||||
$output[ $key ] = array();
|
||||
endforeach;
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user