Created
July 25, 2012 16:55
-
-
Save cyberhobo/3177241 to your computer and use it in GitHub Desktop.
Filter expired The Events Calendar events from a Geo Mashup map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Exclude expired events from Geo Mashup queries | |
*/ | |
function calant_filter_geo_mashup_locations_fields( $fields ) { | |
global $spEvents; | |
if ( isset( $spEvents ) ) | |
$fields .= ', eventEnd.meta_value as EventEndDate '; | |
return $fields; | |
} | |
add_filter('geo_mashup_locations_fields', 'calant_filter_geo_mashup_locations_fields'); | |
function calant_filter_geo_mashup_locations_join( $join ) { | |
global $wpdb, $spEvents; | |
if ( isset( $spEvents ) ) | |
$join .= " LEFT JOIN {$wpdb->postmeta} as eventEnd ON( o.ID = eventEnd.post_id ) "; | |
return $join; | |
} | |
add_filter('geo_mashup_locations_join', 'calant_filter_geo_mashup_locations_join' ); | |
function calant_filter_geo_mashup_locations_where( $where ) { | |
global $spEvents; | |
if ( isset( $spEvents ) ) { | |
$today = date_i18n( The_Events_Calendar::DBDATETIMEFORMAT ); | |
$where .= ' AND eventEnd.meta_key = "_EventEndDate" AND eventEnd.meta_value > "' . $today . '" '; | |
} | |
return $where; | |
} | |
add_filter('geo_mashup_locations_where', 'calant_filter_geo_mashup_locations_where' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment