Check if team ID's in event results match up with team ID's of that event.

This commit is contained in:
Brian Miyaji
2017-02-04 01:37:04 +11:00
parent 11ef450d7e
commit c5dd816048

View File

@@ -67,6 +67,7 @@ class SP_League_Table extends SP_Custom_Post{
'tax_query' => array( 'tax_query' => array(
'relation' => 'AND', 'relation' => 'AND',
), ),
'fields' => 'ids',
); );
if ( $league_ids ): if ( $league_ids ):
@@ -85,13 +86,7 @@ class SP_League_Table extends SP_Custom_Post{
); );
endif; endif;
$teams = get_posts( $args ); $team_ids = get_posts( $args );
if ( $teams && is_array( $teams ) ) {
foreach ( $teams as $team ) {
$team_ids[] = $team->ID;
}
}
} else { } else {
$team_ids = (array)get_post_meta( $this->ID, 'sp_team', false ); $team_ids = (array)get_post_meta( $this->ID, 'sp_team', false );
} }
@@ -260,6 +255,7 @@ class SP_League_Table extends SP_Custom_Post{
// Event loop // Event loop
foreach ( $events as $event ): foreach ( $events as $event ):
$teams = (array)get_post_meta( $event->ID, 'sp_team', false );
$results = (array)get_post_meta( $event->ID, 'sp_results', true ); $results = (array)get_post_meta( $event->ID, 'sp_results', true );
$minutes = get_post_meta( $event->ID, 'sp_minutes', true ); $minutes = get_post_meta( $event->ID, 'sp_minutes', true );
if ( $minutes === '' ) $minutes = get_option( 'sportspress_event_minutes', 90 ); if ( $minutes === '' ) $minutes = get_option( 'sportspress_event_minutes', 90 );
@@ -268,6 +264,8 @@ class SP_League_Table extends SP_Custom_Post{
foreach ( $results as $team_id => $team_result ): foreach ( $results as $team_id => $team_result ):
if ( ! in_array( $team_id, $teams ) ) continue;
if ( ! in_array( $team_id, $team_ids ) ) { if ( ! in_array( $team_id, $team_ids ) ) {
$i++; $i++;
continue; continue;