Refactor sp_total_type => sp_type

This commit is contained in:
Brian Miyaji
2017-06-09 01:14:55 +10:00
parent 4f89694b12
commit 4877d8e256
2 changed files with 5 additions and 5 deletions

View File

@@ -26,7 +26,7 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
$precision = get_post_meta( $post->ID, 'sp_precision', true ); $precision = get_post_meta( $post->ID, 'sp_precision', true );
$section = get_post_meta( $post->ID, 'sp_section', true ); $section = get_post_meta( $post->ID, 'sp_section', true );
$format = get_post_meta( $post->ID, 'sp_format', true ); $format = get_post_meta( $post->ID, 'sp_format', true );
$total = get_post_meta( $post->ID, 'sp_total_type', true ); $total = get_post_meta( $post->ID, 'sp_type', true );
$visible = get_post_meta( $post->ID, 'sp_visible', true ); $visible = get_post_meta( $post->ID, 'sp_visible', true );
// Defaults // Defaults
@@ -68,7 +68,7 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
</p> </p>
<p><strong><?php _e( 'Type', 'sportspress' ); ?></strong></p> <p><strong><?php _e( 'Type', 'sportspress' ); ?></strong></p>
<p> <p>
<select name="sp_total_type"> <select name="sp_type">
<?php <?php
$options = apply_filters( 'sportspress_statistic_total_types', array( 'total' => __( 'Total', 'sportspress' ), 'average' => __( 'Average', 'sportspress' ) ) ); $options = apply_filters( 'sportspress_statistic_total_types', array( 'total' => __( 'Total', 'sportspress' ), 'average' => __( 'Average', 'sportspress' ) ) );
foreach ( $options as $key => $value ): foreach ( $options as $key => $value ):
@@ -104,7 +104,7 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
public static function save( $post_id, $post ) { public static function save( $post_id, $post ) {
self::delete_duplicate( $_POST ); self::delete_duplicate( $_POST );
update_post_meta( $post_id, 'sp_section', (int) sp_array_value( $_POST, 'sp_section', -1 ) ); update_post_meta( $post_id, 'sp_section', (int) sp_array_value( $_POST, 'sp_section', -1 ) );
update_post_meta( $post_id, 'sp_total_type', sp_array_value( $_POST, 'sp_total_type', 'total' ) ); update_post_meta( $post_id, 'sp_type', sp_array_value( $_POST, 'sp_type', 'total' ) );
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'number' ) ); update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'number' ) );
update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1 ) ); update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1 ) );
update_post_meta( $post_id, 'sp_visible', sp_array_value( $_POST, 'sp_visible', 1 ) ); update_post_meta( $post_id, 'sp_visible', sp_array_value( $_POST, 'sp_visible', 1 ) );

View File

@@ -642,7 +642,7 @@ class SP_Player extends SP_Custom_Post {
} }
$formats[ $post->post_name ] = $format; $formats[ $post->post_name ] = $format;
$total_type = get_post_meta( $post->ID, 'sp_total_type', true ); $total_type = get_post_meta( $post->ID, 'sp_type', true );
if ( '' === $total_type ) { if ( '' === $total_type ) {
$total_type = 'total'; $total_type = 'total';
} }
@@ -670,7 +670,7 @@ class SP_Player extends SP_Custom_Post {
// Calculate average-based statistics from performance // Calculate average-based statistics from performance
foreach ( $posts as $post ) { foreach ( $posts as $post ) {
$type = get_post_meta( $post->ID, 'sp_total_type', 'total' ); $type = get_post_meta( $post->ID, 'sp_type', 'total' );
if ( 'average' !== $type ) continue; if ( 'average' !== $type ) continue;
$value = sp_array_value( $equations, $post->post_name, null ); $value = sp_array_value( $equations, $post->post_name, null );
if ( null === $value || ! isset( $value['equation'] ) ) continue; if ( null === $value || ! isset( $value['equation'] ) ) continue;