Use slugs to save event players stats
This commit is contained in:
@@ -385,15 +385,23 @@ if ( !function_exists( 'sp_get_eos_keys' ) ) {
|
||||
|
||||
|
||||
if ( !function_exists( 'sp_get_var_columns' ) ) {
|
||||
function sp_get_var_columns( $post_type, $exclude ) {
|
||||
function sp_get_var_columns( $post_type, $indies = false ) {
|
||||
$args = array(
|
||||
'post_type' => $post_type,
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'exclude' => $exclude
|
||||
'order' => 'ASC'
|
||||
);
|
||||
if ( $indies ):
|
||||
$args['meta_query'] = array(
|
||||
array(
|
||||
'key' => 'sp_equation',
|
||||
'value'=>''
|
||||
)
|
||||
);
|
||||
endif;
|
||||
|
||||
$vars = get_posts( $args );
|
||||
|
||||
$output = array();
|
||||
@@ -660,8 +668,8 @@ if ( !function_exists( 'sp_stats_table' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sp_results_table' ) ) {
|
||||
function sp_results_table( $columns = array(), $data = array(), $placeholders = array() ) {
|
||||
if ( !function_exists( 'sp_event_results_table' ) ) {
|
||||
function sp_event_results_table( $columns = array(), $data = array() ) {
|
||||
?>
|
||||
<table class="widefat sp-stats-table">
|
||||
<thead>
|
||||
@@ -684,9 +692,8 @@ if ( !function_exists( 'sp_results_table' ) ) {
|
||||
</td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
$value = sp_array_value( $team_results, $column, '' );
|
||||
$placeholder = (int)sp_array_value( sp_array_value( $placeholders, $team_id, 0), $column, 0 );
|
||||
?>
|
||||
<td><input type="text" name="sp_results[<?php echo $team_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
|
||||
<td><input type="text" name="sp_results[<?php echo $team_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" /></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php
|
||||
@@ -699,13 +706,13 @@ if ( !function_exists( 'sp_results_table' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sp_players_table' ) ) {
|
||||
function sp_players_table( $columns = array(), $data = array(), $placeholders = array() ) {
|
||||
if ( !function_exists( 'sp_event_players_table' ) ) {
|
||||
function sp_event_players_table( $columns = array(), $data = array(), $team_id ) {
|
||||
?>
|
||||
<table class="widefat sp-stats-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _e( 'Team', 'sportspress' ); ?></th>
|
||||
<th><?php _e( 'Player', 'sportspress' ); ?></th>
|
||||
<?php foreach ( $columns as $label ): ?>
|
||||
<th><?php echo $label; ?></th>
|
||||
<?php endforeach; ?>
|
||||
@@ -714,18 +721,66 @@ if ( !function_exists( 'sp_players_table' ) ) {
|
||||
<tbody>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ( $data as $team_id => $team_results ):
|
||||
if ( !$team_id ) continue;
|
||||
foreach ( $data as $player_id => $player_metrics ):
|
||||
if ( !$player_id ) continue;
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<td>
|
||||
<?php echo get_the_title( $team_id ); ?>
|
||||
<?php echo get_the_title( $player_id ); ?>
|
||||
</td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
$value = sp_array_value( $team_results, $column, '' );
|
||||
$placeholder = (int)sp_array_value( sp_array_value( $placeholders, $team_id, 0), $column, 0 );
|
||||
$value = sp_array_value( $player_metrics, $column, '' );
|
||||
?>
|
||||
<td><input type="text" name="sp_results[<?php echo $team_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
|
||||
<td><input type="text" name="sp_stats[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="0" /></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
?>
|
||||
<tr class="sp-row sp-total<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<td><strong><?php _e( 'Total', 'sportspress' ); ?></strong></td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
$player_id = 0;
|
||||
$player_metrics = $data[0];
|
||||
$value = sp_array_value( $player_metrics, $column, '' );
|
||||
?>
|
||||
<td><input type="text" name="sp_stats[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="0" /></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sp_someother_table' ) ) {
|
||||
function sp_someother_table( $columns = array(), $data = array(), $placeholders = array(), $team_id ) {
|
||||
?>
|
||||
<table class="widefat sp-stats-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _e( 'Player', 'sportspress' ); ?></th>
|
||||
<?php foreach ( $columns as $label ): ?>
|
||||
<th><?php echo $label; ?></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ( $data as $player_id => $player_metrics ):
|
||||
if ( !$player_id ) continue;
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<td>
|
||||
<?php echo get_the_title( $player_id ); ?>
|
||||
</td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
$value = sp_array_value( $player_metrics, $column, '' );
|
||||
$placeholder = (int)sp_array_value( sp_array_value( $placeholders, $player_id, 0), $column, 0 );
|
||||
?>
|
||||
<td><input type="text" name="sp_stats[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php
|
||||
@@ -736,11 +791,11 @@ if ( !function_exists( 'sp_players_table' ) ) {
|
||||
<tr class="sp-row sp-total<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<td><strong><?php _e( 'Total', 'sportspress' ); ?></strong></td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
$team_id = 0;
|
||||
$value = sp_array_value( $team_results, $column, '' );
|
||||
$placeholder = (int)sp_array_value( sp_array_value( $placeholders, $team_id, 0), $column, 0 );
|
||||
$player_id = 0;
|
||||
$value = sp_array_value( $player_metrics, $column, '' );
|
||||
$placeholder = (int)sp_array_value( sp_array_value( $placeholders, $player_id, 0), $column, 0 );
|
||||
?>
|
||||
<td><input type="text" name="sp_results[<?php echo $team_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
|
||||
<td><input type="text" name="sp_stats[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user