Calculate sum/average statistics, delete duplicate configs, sort player list by number
This commit is contained in:
@@ -75,6 +75,9 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) {
|
||||
case 'sp_precision':
|
||||
echo sportspress_get_post_precision( $post_id );
|
||||
break;
|
||||
case 'sp_calculate':
|
||||
echo sportspress_get_post_calculate( $post_id );
|
||||
break;
|
||||
case 'sp_player':
|
||||
echo sportspress_the_posts( $post_id, 'sp_player' );
|
||||
break;
|
||||
|
||||
@@ -11,7 +11,9 @@ function sportspress_sanitize_title( $title ) {
|
||||
|
||||
if ( ! $key ) $key = $_POST['post_title'];
|
||||
|
||||
$title = sportspress_get_eos_safe_slug( $key, sportspress_array_value( $_POST, 'ID', 'var' ) );
|
||||
$id = sportspress_array_value( $_POST, 'post_ID', 'var' );
|
||||
|
||||
$title = sportspress_get_eos_safe_slug( $key, $id );
|
||||
|
||||
elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && $_POST['post_type'] == 'sp_event' ):
|
||||
|
||||
|
||||
@@ -47,7 +47,24 @@ function sportspress_save_post( $post_id ) {
|
||||
|
||||
break;
|
||||
|
||||
case ( 'sp_result' ):
|
||||
|
||||
// Delete posts with duplicate key
|
||||
sportspress_delete_duplicate_post( $_POST );
|
||||
|
||||
break;
|
||||
|
||||
case ( 'sp_outcome' ):
|
||||
|
||||
// Delete posts with duplicate key
|
||||
sportspress_delete_duplicate_post( $_POST );
|
||||
|
||||
break;
|
||||
|
||||
case ( 'sp_column' ):
|
||||
|
||||
// Delete posts with duplicate key
|
||||
sportspress_delete_duplicate_post( $_POST );
|
||||
|
||||
// Update equation as string
|
||||
update_post_meta( $post_id, 'sp_equation', implode( ' ', sportspress_array_value( $_POST, 'sp_equation', array() ) ) );
|
||||
@@ -65,8 +82,11 @@ function sportspress_save_post( $post_id ) {
|
||||
|
||||
case ( 'sp_statistic' ):
|
||||
|
||||
// Update equation as string
|
||||
update_post_meta( $post_id, 'sp_equation', implode( ' ', sportspress_array_value( $_POST, 'sp_equation', array() ) ) );
|
||||
// Delete posts with duplicate key
|
||||
sportspress_delete_duplicate_post( $_POST );
|
||||
|
||||
// Update calculation method as string
|
||||
update_post_meta( $post_id, 'sp_calculate', sportspress_array_value( $_POST, 'sp_calculate', 'DESC' ) );
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ function sportspress_column_details_meta( $post ) {
|
||||
<p class="sp-equation-selector">
|
||||
<?php
|
||||
foreach ( $equation as $piece ):
|
||||
sportspress_get_equation_selector( $post->ID, $piece, array( 'team_event', 'result', 'outcome' ) );
|
||||
sportspress_equation_selector( $post->ID, $piece, array( 'team_event', 'result', 'outcome' ) );
|
||||
endforeach;
|
||||
?>
|
||||
</p>
|
||||
|
||||
@@ -25,7 +25,7 @@ function sportspress_statistic_edit_columns() {
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_positions' => __( 'Positions', 'sportspress' ),
|
||||
'sp_equation' => __( 'Equation', 'sportspress' ),
|
||||
'sp_calculate' => __( 'Calculate', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
@@ -36,15 +36,11 @@ function sportspress_statistic_meta_init() {
|
||||
}
|
||||
|
||||
function sportspress_statistic_equation_meta( $post ) {
|
||||
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
|
||||
$calculate = get_post_meta( $post->ID, 'sp_calculate', true );
|
||||
?>
|
||||
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
|
||||
<p class="sp-equation-selector">
|
||||
<?php
|
||||
foreach ( $equation as $piece ):
|
||||
sportspress_get_equation_selector( $post->ID, $piece, array( 'player_event' ) );
|
||||
endforeach;
|
||||
?>
|
||||
<p><strong><?php _e( 'Calculate', 'sportspress' ); ?></strong></p>
|
||||
<p class="sp-calculate-selector">
|
||||
<?php sportspress_calculate_selector( $post->ID, $calculate ); ?>
|
||||
</p>
|
||||
<?php
|
||||
sportspress_nonce();
|
||||
|
||||
@@ -46,14 +46,14 @@ $data = get_posts( $args );
|
||||
<tr>
|
||||
<th><?php _e( 'Label', 'sportspress' ); ?></th>
|
||||
<th><?php _e( 'Positions', 'sportspress' ); ?></th>
|
||||
<th><?php _e( 'Equation', 'sportspress' ); ?></th>
|
||||
<th><?php _e( 'Calculate', 'sportspress' ); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php $i = 0; foreach ( $data as $row ): ?>
|
||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||
<td><?php echo get_the_terms ( $row->ID, 'sp_position' ) ? the_terms( $row->ID, 'sp_position' ) : sprintf( __( 'All %s', 'sportspress' ), __( 'positions', 'sportspress' ) ); ?></td>
|
||||
<td><?php echo sportspress_get_post_equation( $row->ID ); ?></td>
|
||||
<td><?php echo sportspress_get_post_calculate( $row->ID ); ?></td>
|
||||
</tr>
|
||||
<?php $i++; endforeach; ?>
|
||||
<tfoot>
|
||||
|
||||
Reference in New Issue
Block a user