Add time format option to statistics

This commit is contained in:
Brian Miyaji
2017-01-11 16:30:15 +11:00
parent 3228f1dbc9
commit 90533c42e5

View File

@@ -52,6 +52,17 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
?>
</select>
</p>
<p><strong><?php _e( 'Format', 'sportspress' ); ?></strong></p>
<p>
<select name="sp_format">
<?php
$options = apply_filters( 'sportspress_statistic_formats', array( 'number' => __( 'Number', 'sportspress' ), 'time' => __( 'Time', 'sportspress' ) ) );
foreach ( $options as $key => $value ):
printf( '<option value="%s" %s>%s</option>', $key, selected( $key == $format, true, false ), $value );
endforeach;
?>
</select>
</p>
<p>
<strong><?php _e( 'Visible', 'sportspress' ); ?></strong>
<i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php _e( 'Display in player profile?', 'sportspress' ); ?>"></i>
@@ -79,6 +90,7 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
public static function save( $post_id, $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_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_visible', sp_array_value( $_POST, 'sp_visible', 1 ) );
}