Calculate equation-based box score totals
This commit is contained in:
@@ -174,22 +174,6 @@ if ( ! isset( $subs ) ) $subs = array();
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
if ( sizeof( $equations ) ):
|
||||
|
||||
// Prepare total values for equation calculation
|
||||
$vars = $totals;
|
||||
foreach ( $vars as $key => $var ):
|
||||
if ( empty( $var ) ) $vars[ $key ] = 0;
|
||||
endforeach;
|
||||
$vars = array_merge( $vars, array( 'eventsplayed' => 1 ) );
|
||||
|
||||
// Calculate equation-based totals
|
||||
foreach ( $equations as $key => $equation ):
|
||||
$totals[ $key ] = sp_solve( $equation['equation'], $vars, $equation['precision'] );
|
||||
endforeach;
|
||||
|
||||
endif;
|
||||
?>
|
||||
</tbody>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -77,30 +77,16 @@ if ( is_array( $teams ) ):
|
||||
|
||||
$columns = get_posts( $args );
|
||||
|
||||
// Get formats and equations
|
||||
// Get formats
|
||||
$formats = array();
|
||||
$equations = array();
|
||||
|
||||
// Add to formats and equations
|
||||
// Add to formats
|
||||
foreach ( $columns as $column ) {
|
||||
$format = get_post_meta( $column->ID, 'sp_format', true );
|
||||
if ( '' === $format ) {
|
||||
$format = 'number';
|
||||
}
|
||||
$formats[ $column->post_name ] = $format;
|
||||
|
||||
if ( 'equation' === $format ) {
|
||||
$equation = get_post_meta( $column->ID, 'sp_equation', true );
|
||||
$precision = get_post_meta( $column->ID, 'sp_precision', true );
|
||||
|
||||
if ( empty( $equation ) ) $equation = 0;
|
||||
if ( empty( $precision ) ) $precision = 0;
|
||||
|
||||
$equations[ $column->post_name ] = array(
|
||||
'equation' => $equation,
|
||||
'precision' => $precision,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( $is_individual ) {
|
||||
@@ -123,7 +109,6 @@ if ( is_array( $teams ) ):
|
||||
'caption' => __( 'Box Score', 'sportspress' ),
|
||||
'labels' => $labels,
|
||||
'formats' => $formats,
|
||||
'equations' => $equations,
|
||||
'mode' => $mode,
|
||||
'data' => $data,
|
||||
'event' => $event,
|
||||
@@ -234,7 +219,6 @@ if ( is_array( $teams ) ):
|
||||
'caption' => 0 == $s && $team_id ? sp_get_team_name( $team_id, $abbreviate_teams ) : null,
|
||||
'labels' => $labels[ $section_id ],
|
||||
'formats' => $formats,
|
||||
'equations' => $equations,
|
||||
'mode' => $mode,
|
||||
'data' => $data[ $section_id ],
|
||||
'event' => $event,
|
||||
@@ -271,7 +255,6 @@ if ( is_array( $teams ) ):
|
||||
'caption' => $team_id ? sp_get_team_name( $team_id, $abbreviate_teams ) : null,
|
||||
'labels' => $labels,
|
||||
'formats' => $formats,
|
||||
'equations' => $equations,
|
||||
'mode' => $mode,
|
||||
'data' => $data,
|
||||
'event' => $event,
|
||||
|
||||
Reference in New Issue
Block a user