Add @Venue subset and tweak @Home and @Away to reflect team order
This commit is contained in:
@@ -46,7 +46,7 @@ class SP_Meta_Box_Equation {
|
||||
$options[ 'Presets' ] = array( '$gamesback' => __( 'Games Back', 'sportspress' ), '$homerecord' => __( 'Home Record', 'sportspress' ), '$awayrecord' => __( 'Away Record', 'sportspress' ), '$streak' => __( 'Streak', 'sportspress' ), '$last5' => __( 'Last 5', 'sportspress' ), '$last10' => __( 'Last 10', 'sportspress' ) );
|
||||
break;
|
||||
case 'subset':
|
||||
$options[ 'Subsets' ] = array( '_home' => '@' . __( 'Home', 'sportspress' ), '_away' => '@' . __( 'Away', 'sportspress' ) );
|
||||
$options[ 'Subsets' ] = array( '_home' => '@' . __( 'Home', 'sportspress' ), '_away' => '@' . __( 'Away', 'sportspress' ), '_venue' => '@' . __( 'Venue', 'sportspress' ) );
|
||||
break;
|
||||
case 'performance':
|
||||
$options[ 'Performance' ] = self::optgroup( 'sp_performance' );
|
||||
|
||||
@@ -136,27 +136,33 @@ class SP_League_Table extends SP_Custom_Post{
|
||||
'eventsplayed' => 0,
|
||||
'eventsplayed_home' => 0,
|
||||
'eventsplayed_away' => 0,
|
||||
'eventsplayed_venue' => 0,
|
||||
'eventminutes' => 0,
|
||||
'eventminutes_home' => 0,
|
||||
'eventminutes_away' => 0,
|
||||
'eventminutes_venue' => 0,
|
||||
'streak' => 0,
|
||||
'streak_home' => 0,
|
||||
'streak_away' => 0,
|
||||
'streak_venue' => 0,
|
||||
);
|
||||
|
||||
foreach ( $result_labels as $key => $value ):
|
||||
$totals[ $team_id ][ $key . 'for' ] = 0;
|
||||
$totals[ $team_id ][ $key . 'for_home' ] = 0;
|
||||
$totals[ $team_id ][ $key . 'for_away' ] = 0;
|
||||
$totals[ $team_id ][ $key . 'for_venue' ] = 0;
|
||||
$totals[ $team_id ][ $key . 'against' ] = 0;
|
||||
$totals[ $team_id ][ $key . 'against_home' ] = 0;
|
||||
$totals[ $team_id ][ $key . 'against_away' ] = 0;
|
||||
$totals[ $team_id ][ $key . 'against_venue' ] = 0;
|
||||
endforeach;
|
||||
|
||||
foreach ( $outcome_labels as $key => $value ):
|
||||
$totals[ $team_id ][ $key ] = 0;
|
||||
$totals[ $team_id ][ $key . '_home' ] = 0;
|
||||
$totals[ $team_id ][ $key . '_away' ] = 0;
|
||||
$totals[ $team_id ][ $key . '_venue' ] = 0;
|
||||
endforeach;
|
||||
|
||||
// Get static stats
|
||||
@@ -244,7 +250,8 @@ class SP_League_Table extends SP_Custom_Post{
|
||||
$totals[ $team_id ]['eventminutes'] += $minutes;
|
||||
$totals[ $team_id ][ $outcome ] ++;
|
||||
|
||||
if ( sp_is_home_venue( $team_id, $event->ID ) ):
|
||||
// Add to home or away stats
|
||||
if ( 0 === $i ):
|
||||
$totals[ $team_id ]['eventsplayed_home'] ++;
|
||||
$totals[ $team_id ]['eventminutes_home'] += $minutes;
|
||||
$totals[ $team_id ][ $outcome . '_home' ] ++;
|
||||
@@ -253,6 +260,13 @@ class SP_League_Table extends SP_Custom_Post{
|
||||
$totals[ $team_id ]['eventminutes_away'] += $minutes;
|
||||
$totals[ $team_id ][ $outcome . '_away' ] ++;
|
||||
endif;
|
||||
|
||||
// Add to venue stats
|
||||
if ( sp_is_home_venue( $team_id, $event->ID ) ):
|
||||
$totals[ $team_id ]['eventsplayed_venue'] ++;
|
||||
$totals[ $team_id ]['eventminutes_venue'] += $minutes;
|
||||
$totals[ $team_id ][ $outcome . '_venue' ] ++;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( $outcome && $outcome != '-1' ):
|
||||
@@ -295,22 +309,34 @@ class SP_League_Table extends SP_Custom_Post{
|
||||
$totals[ $team_id ][ $key . 'for' ] += $value;
|
||||
$totals[ $team_id ][ $key . 'for' . ( $e + 1 ) ] = $value;
|
||||
|
||||
if ( sp_is_home_venue( $team_id, $event->ID ) ):
|
||||
// Add to home or away stats
|
||||
if ( 0 === $i ):
|
||||
$totals[ $team_id ][ $key . 'for_home' ] += $value;
|
||||
else:
|
||||
$totals[ $team_id ][ $key . 'for_away' ] += $value;
|
||||
endif;
|
||||
|
||||
// Add to venue stats
|
||||
if ( sp_is_home_venue( $team_id, $event->ID ) ):
|
||||
$totals[ $team_id ][ $key . 'for_venue' ] += $value;
|
||||
endif;
|
||||
|
||||
foreach( $results as $other_team_id => $other_result ):
|
||||
if ( $other_team_id != $team_id && array_key_exists( $key . 'against', $totals[ $team_id ] ) ):
|
||||
$totals[ $team_id ][ $key . 'against' ] += sp_array_value( $other_result, $key, 0 );
|
||||
$totals[ $team_id ][ $key . 'against' . ( $e + 1 ) ] = sp_array_value( $other_result, $key, 0 );
|
||||
|
||||
if ( sp_is_home_venue( $team_id, $event->ID ) ):
|
||||
// Add to home or away stats
|
||||
if ( 0 === $i ):
|
||||
$totals[ $team_id ][ $key . 'against_home' ] += sp_array_value( $other_result, $key, 0 );
|
||||
else:
|
||||
$totals[ $team_id ][ $key . 'against_away' ] += sp_array_value( $other_result, $key, 0 );
|
||||
endif;
|
||||
|
||||
// Add to venue stats
|
||||
if ( sp_is_home_venue( $team_id, $event->ID ) ):
|
||||
$totals[ $team_id ][ $key . 'against_venue' ] += sp_array_value( $other_result, $key, 0 );
|
||||
endif;
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
@@ -81,12 +81,15 @@ class SP_Team extends SP_Custom_Post {
|
||||
'eventsplayed' => 0,
|
||||
'eventsplayed_home' => 0,
|
||||
'eventsplayed_away' => 0,
|
||||
'eventsplayed_venue' => 0,
|
||||
'eventminutes' => 0,
|
||||
'eventminutes_home' => 0,
|
||||
'eventminutes_away' => 0,
|
||||
'eventminutes_venue' => 0,
|
||||
'streak' => 0,
|
||||
'streak_home' => 0,
|
||||
'streak_away' => 0,
|
||||
'streak_venue' => 0,
|
||||
'last5' => null,
|
||||
'last10' => null,
|
||||
'homerecord' => null,
|
||||
@@ -97,15 +100,18 @@ class SP_Team extends SP_Custom_Post {
|
||||
$totals[ $key . 'for' ] = 0;
|
||||
$totals[ $key . 'for_home' ] = 0;
|
||||
$totals[ $key . 'for_away' ] = 0;
|
||||
$totals[ $key . 'for_venue' ] = 0;
|
||||
$totals[ $key . 'against' ] = 0;
|
||||
$totals[ $key . 'against_home' ] = 0;
|
||||
$totals[ $key . 'against_away' ] = 0;
|
||||
$totals[ $key . 'against_venue' ] = 0;
|
||||
endforeach;
|
||||
|
||||
foreach ( $outcome_labels as $key => $value ):
|
||||
$totals[ $key ] = 0;
|
||||
$totals[ $key . '_home' ] = 0;
|
||||
$totals[ $key . '_away' ] = 0;
|
||||
$totals[ $key . '_venue' ] = 0;
|
||||
endforeach;
|
||||
|
||||
// Initialize streaks counter
|
||||
@@ -198,7 +204,8 @@ class SP_Team extends SP_Custom_Post {
|
||||
$totals['eventminutes'] += $minutes;
|
||||
$totals[ $outcome ] ++;
|
||||
|
||||
if ( sp_is_home_venue( $team_id, $event->ID ) ):
|
||||
// Add to home or away stats
|
||||
if ( 0 === $i ):
|
||||
$totals['eventsplayed_home'] ++;
|
||||
$totals['eventminutes_home'] += $minutes;
|
||||
$totals[ $outcome . '_home' ] ++;
|
||||
@@ -207,6 +214,13 @@ class SP_Team extends SP_Custom_Post {
|
||||
$totals['eventminutes_away'] += $minutes;
|
||||
$totals[ $outcome . '_away' ] ++;
|
||||
endif;
|
||||
|
||||
// Add to venue stats
|
||||
if ( sp_is_home_venue( $team_id, $event->ID ) ):
|
||||
$totals['eventsplayed_venue'] ++;
|
||||
$totals['eventminutes_venue'] += $minutes;
|
||||
$totals[ $outcome . '_venue' ] ++;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( $outcome && $outcome != '-1' ):
|
||||
@@ -249,11 +263,17 @@ class SP_Team extends SP_Custom_Post {
|
||||
$totals[ $key . 'for' ] += $value;
|
||||
$totals[ $key . 'for' . ( $e + 1 ) ] = $value;
|
||||
|
||||
if ( sp_is_home_venue( $team_id, $event->ID ) ):
|
||||
// Add to home or away stats
|
||||
if ( 0 === $i ):
|
||||
$totals[ $key . 'for_home' ] += $value;
|
||||
else:
|
||||
$totals[ $key . 'for_away' ] += $value;
|
||||
endif;
|
||||
|
||||
// Add to venue stats
|
||||
if ( sp_is_home_venue( $team_id, $event->ID ) ):
|
||||
$totals[ $key . 'for_venue' ] += $value;
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
else:
|
||||
@@ -262,11 +282,17 @@ class SP_Team extends SP_Custom_Post {
|
||||
$totals[ $key . 'against' ] += $value;
|
||||
$totals[ $key . 'against' . ( $e + 1 ) ] = $value;
|
||||
|
||||
if ( sp_is_home_venue( $team_id, $event->ID ) ):
|
||||
// Add to home or away stats
|
||||
if ( 0 === $i ):
|
||||
$totals[ $key . 'against_home' ] += $value;
|
||||
else:
|
||||
$totals[ $key . 'against_away' ] += $value;
|
||||
endif;
|
||||
|
||||
// Add to venue stats
|
||||
if ( sp_is_home_venue( $team_id, $event->ID ) ):
|
||||
$totals[ $key . 'against_venue' ] += $value;
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
Reference in New Issue
Block a user