From 461b4f394c3a6c6e6fdaab448adc0d643703dc27 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Fri, 28 Mar 2014 16:33:09 +1100 Subject: [PATCH] Fix event list widget error --- includes/sp-core-functions.php | 108 +++++++++++++++++---------------- 1 file changed, 57 insertions(+), 51 deletions(-) diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index d411e2a5..1f6619b2 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -1638,62 +1638,68 @@ if ( !function_exists( 'sp_get_calendar_data' ) ) { ), ); - if ( $pagenow != 'post-new.php' && $post_id ): - $leagues = get_the_terms( $post_id, 'sp_league' ); - $seasons = get_the_terms( $post_id, 'sp_season' ); - $venues = get_the_terms( $post_id, 'sp_venue' ); - $team = get_post_meta( $post_id, 'sp_team', true ); - $usecolumns = get_post_meta( $post_id, 'sp_columns', true ); + if ( $pagenow != 'post-new.php' ): + if ( $post_id ): + $leagues = get_the_terms( $post_id, 'sp_league' ); + $seasons = get_the_terms( $post_id, 'sp_season' ); + $venues = get_the_terms( $post_id, 'sp_venue' ); + $team = get_post_meta( $post_id, 'sp_team', true ); + $usecolumns = get_post_meta( $post_id, 'sp_columns', true ); - if ( $leagues ): - $league_ids = array(); - foreach( $leagues as $league ): - $league_ids[] = $league->term_id; - endforeach; - $args['tax_query'][] = array( - 'taxonomy' => 'sp_league', - 'field' => 'id', - 'terms' => $league_ids - ); + if ( $leagues ): + $league_ids = array(); + foreach( $leagues as $league ): + $league_ids[] = $league->term_id; + endforeach; + $args['tax_query'][] = array( + 'taxonomy' => 'sp_league', + 'field' => 'id', + 'terms' => $league_ids + ); + endif; + + if ( $seasons ): + $season_ids = array(); + foreach( $seasons as $season ): + $season_ids[] = $season->term_id; + endforeach; + $args['tax_query'][] = array( + 'taxonomy' => 'sp_season', + 'field' => 'id', + 'terms' => $season_ids + ); + endif; + + if ( $venues ): + $venue_ids = array(); + foreach( $venues as $venue ): + $venue_ids[] = $venue->term_id; + endforeach; + $args['tax_query'][] = array( + 'taxonomy' => 'sp_venue', + 'field' => 'id', + 'terms' => $venue_ids + ); + endif; + + if ( $team ): + $args['meta_query'] = array( + array( + 'key' => 'sp_team', + 'value' => $team, + ), + ); + endif; + + else: + $usecolumns = null; endif; - - if ( $seasons ): - $season_ids = array(); - foreach( $seasons as $season ): - $season_ids[] = $season->term_id; - endforeach; - $args['tax_query'][] = array( - 'taxonomy' => 'sp_season', - 'field' => 'id', - 'terms' => $season_ids - ); - endif; - - if ( $venues ): - $venue_ids = array(); - foreach( $venues as $venue ): - $venue_ids[] = $venue->term_id; - endforeach; - $args['tax_query'][] = array( - 'taxonomy' => 'sp_venue', - 'field' => 'id', - 'terms' => $venue_ids - ); - endif; - - if ( $team ): - $args['meta_query'] = array( - array( - 'key' => 'sp_team', - 'value' => $team, - ), - ); - endif; - + $events = get_posts( $args ); + else: $usecolumns = null; - $events = null; + $events = array(); endif; if ( $admin ):