Fix event list widget error

This commit is contained in:
Brian Miyaji
2014-03-28 16:33:09 +11:00
parent 4b93f57768
commit 461b4f394c

View File

@@ -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 ):