Add option to record minutes for individual statistics
This commit is contained in:
@@ -20,7 +20,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$event = new SP_Event( $post );
|
||||
list( $labels, $columns, $stats, $teams, $formats, $order ) = $event->performance( true );
|
||||
list( $labels, $columns, $stats, $teams, $formats, $order, $timed ) = $event->performance( true );
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_event_performance_show_minutes', 'yes' ) )
|
||||
$timeline = $event->timeline( true );
|
||||
@@ -65,7 +65,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
// Check if individual mode
|
||||
$is_individual = get_option( 'sportspress_load_individual_mode_module', 'no' ) === 'yes' ? true : false;
|
||||
|
||||
self::tables( $post->ID, $stats, $labels, $columns, $teams, $has_checkboxes, $positions, $status, $formats, $order, $numbers, $is_individual, $timeline );
|
||||
self::tables( $post->ID, $stats, $labels, $columns, $teams, $has_checkboxes, $positions, $status, $formats, $order, $numbers, $is_individual, $timeline, $timed );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
/**
|
||||
* Admin edit tables
|
||||
*/
|
||||
public static function tables( $post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $positions = array(), $status = true, $formats = array(), $order = array(), $numbers = true, $is_individual = false, $timeline = array() ) {
|
||||
public static function tables( $post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $positions = array(), $status = true, $formats = array(), $order = array(), $numbers = true, $is_individual = false, $timeline = array(), $timed = array() ) {
|
||||
$sections = get_option( 'sportspress_event_performance_sections', -1 );
|
||||
|
||||
if ( $is_individual ) {
|
||||
@@ -116,7 +116,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
$player_timeline = false;
|
||||
endif;
|
||||
|
||||
self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, false, $numbers, -1, $formats, $player_timeline );
|
||||
self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, false, $numbers, -1, $formats, $player_timeline, $timed );
|
||||
endforeach;
|
||||
endforeach;
|
||||
?>
|
||||
@@ -145,7 +145,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
|
||||
<?php self::table( $labels, $columns, $data, $team_id, $has_checkboxes, $positions, $status, -1, $formats, $order, $numbers, $team_timeline ); ?>
|
||||
<?php self::table( $labels, $columns, $data, $team_id, $has_checkboxes, $positions, $status, -1, $formats, $order, $numbers, $team_timeline, $timed ); ?>
|
||||
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels, $columns, $data, $team_id ); ?>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
@@ -227,7 +227,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php echo get_the_title( $team_id ); ?> — <?php echo $section_label; ?></strong></p>
|
||||
<?php self::table( $labels[ $section_id ], $columns, $data[ $section_id ], $team_id, ( $has_checkboxes && 0 === $i ), $positions, $status, $section_id, $formats, $order, $numbers, $team_timeline ); ?>
|
||||
<?php self::table( $labels[ $section_id ], $columns, $data[ $section_id ], $team_id, ( $has_checkboxes && 0 === $i ), $positions, $status, $section_id, $formats, $order, $numbers, $team_timeline, $timed ); ?>
|
||||
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels[ $section_id ], $columns, $data[ $section_id ], $team_id ); ?>
|
||||
</div>
|
||||
<?php
|
||||
@@ -241,7 +241,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
/**
|
||||
* Admin edit table
|
||||
*/
|
||||
public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false, $positions = array(), $status = true, $section = -1, $formats = array(), $order = array(), $numbers = true, $team_timeline = array() ) {
|
||||
public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false, $positions = array(), $status = true, $section = -1, $formats = array(), $order = array(), $numbers = true, $team_timeline = array(), $timed = array() ) {
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table sp-performance-table sp-sortable-table">
|
||||
@@ -276,7 +276,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
$player_timeline = false;
|
||||
endif;
|
||||
|
||||
self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, true, $numbers, $section, $formats, $player_timeline );
|
||||
self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, true, $numbers, $section, $formats, $player_timeline, $timed );
|
||||
|
||||
endforeach;
|
||||
?>
|
||||
@@ -369,7 +369,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
/**
|
||||
* Admin edit table row
|
||||
*/
|
||||
public static function row( $labels = array(), $player_id = 0, $player_performance = array(), $team_id = 0, $data = array(), $positions = true, $status = true, $sortable = true, $numbers = true, $section = -1, $formats = array(), $player_timeline = array() ) {
|
||||
public static function row( $labels = array(), $player_id = 0, $player_performance = array(), $team_id = 0, $data = array(), $positions = true, $status = true, $sortable = true, $numbers = true, $section = -1, $formats = array(), $player_timeline = array(), $timed = array() ) {
|
||||
if ( $player_id <= 0 ) return;
|
||||
|
||||
$value = sp_array_value( $player_performance, 'number', '' );
|
||||
@@ -419,7 +419,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
?>
|
||||
<td>
|
||||
<input class="sp-player-<?php echo $column; ?>-input sp-sync-input" type="text" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo $placeholder; ?>" />
|
||||
<?php if ( $intval ) { ?>
|
||||
<?php if ( $intval && in_array( $column, $timed ) ) { ?>
|
||||
<?php
|
||||
// Get performance times
|
||||
if ( is_array( $player_timeline ) ) {
|
||||
|
||||
@@ -40,6 +40,13 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
|
||||
$format = 'number';
|
||||
}
|
||||
$precision = get_post_meta( $post->ID, 'sp_precision', true );
|
||||
if ( '' === $precision ) {
|
||||
$precision = 0;
|
||||
}
|
||||
$timed = get_post_meta( $post->ID, 'sp_timed', true );
|
||||
if ( '' === $timed ) {
|
||||
$timed = false;
|
||||
}
|
||||
?>
|
||||
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
@@ -68,10 +75,32 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Decimal Places', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<input name="sp_precision" type="text" size="4" id="sp_precision" value="<?php echo $precision; ?>" placeholder="0">
|
||||
</p>
|
||||
<div id="sp_precisiondiv">
|
||||
<p><strong><?php _e( 'Decimal Places', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<input name="sp_precision" type="text" size="4" id="sp_precision" value="<?php echo $precision; ?>" placeholder="0">
|
||||
</p>
|
||||
</div>
|
||||
<div id="sp_timeddiv">
|
||||
<p>
|
||||
<strong><?php _e( 'Timed', 'sportspress' ); ?></strong>
|
||||
<i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php _e( 'Record minutes?', 'sportspress' ); ?>"></i>
|
||||
</p>
|
||||
<ul class="sp-timed-selector">
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input name="sp_timed" id="sp_timed_yes" type="radio" value="1" <?php checked( $timed ); ?>>
|
||||
<?php _e( 'Yes', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input name="sp_timed" id="sp_timed_no" type="radio" value="0" <?php checked( ! $timed ); ?>>
|
||||
<?php _e( 'No', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
if ( 'auto' === get_option( 'sportspress_player_columns', 'auto' ) ) {
|
||||
$visible = get_post_meta( $post->ID, 'sp_visible', true );
|
||||
@@ -109,6 +138,7 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
|
||||
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', sp_array_value( $_POST, 'sp_precision', 0 ) );
|
||||
update_post_meta( $post_id, 'sp_timed', sp_array_value( $_POST, 'sp_timed', 0 ) );
|
||||
if ( 'auto' === get_option( 'sportspress_player_columns', 'auto' ) ) {
|
||||
update_post_meta( $post_id, 'sp_visible', sp_array_value( $_POST, 'sp_visible', 1 ) );
|
||||
}
|
||||
|
||||
@@ -98,15 +98,24 @@ class SP_Event extends SP_Custom_Post{
|
||||
|
||||
$labels = array();
|
||||
$formats = array();
|
||||
$timed = array();
|
||||
$equations = array();
|
||||
foreach ( $vars as $var ) {
|
||||
$labels[ $var->post_name ] = $var->post_title;
|
||||
|
||||
$format = get_post_meta( $var->ID, 'sp_format', true );
|
||||
if ( '' === $format ) {
|
||||
$format = 'number';
|
||||
}
|
||||
$formats[ $var->post_name ] = $format;
|
||||
|
||||
|
||||
if ( 'number' === $format ) {
|
||||
$is_timed = get_post_meta( $var->ID, 'sp_timed', true );
|
||||
if ( $is_timed ) {
|
||||
$timed[] = $var->post_name;
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'equation' === $format ) {
|
||||
$equation = get_post_meta( $var->ID, 'sp_equation', true );
|
||||
$precision = get_post_meta( $var->ID, 'sp_precision', true );
|
||||
@@ -162,7 +171,7 @@ class SP_Event extends SP_Custom_Post{
|
||||
endif;
|
||||
|
||||
if ( $admin ):
|
||||
return array( $labels, $columns, $performance, $teams, $formats, $order );
|
||||
return array( $labels, $columns, $performance, $teams, $formats, $order, $timed );
|
||||
else:
|
||||
// Add position to performance labels
|
||||
if ( taxonomy_exists( 'sp_position' ) ):
|
||||
@@ -220,6 +229,9 @@ class SP_Event extends SP_Custom_Post{
|
||||
|
||||
foreach ( $player_performance as $performance_key => $performance_value ):
|
||||
|
||||
// Continue if not timed
|
||||
if ( ! in_array( $performance_key, $timed ) ) continue;
|
||||
|
||||
// Get performance times
|
||||
$times = sp_array_value( $player_timeline, $performance_key, array() );
|
||||
$times = array_filter( $times );
|
||||
|
||||
Reference in New Issue
Block a user