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