Function Reference: geodir_event_count_reviews_by_location_term_sql
Summary
Filter reviews sql query fro upcoming events for current location.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
- $plugin_prefix
- (string) (required) Geodirectory plugin table prefix.
- Default: None
Parameters
- $sql
- (string) (required) Database sql query.
- Default: None
- $term_id
- (int) (required) The term ID.
- Default: None
- $taxonomy
- (int) (required) The taxonomy Id.
- Default: None
- $post_type
- (string) (required) The post type.
- Default: None
- $location_type
- (string) (required) Location type.
- Default: None
- $loc
- (array) (required) Current location terms.
- Default: None
- $count_type
- (string) (required) The term count type.
- Default: None
Return Values
- (string)
- Database sql query.
Change Log
Since: 1.2.4
Source File
geodir_event_count_reviews_by_location_term_sql() is located in geodir_event_manager/gdevents_functions.php [Line: 2068]
Source Code
function geodir_event_count_reviews_by_location_term_sql($sql, $term_id, $taxonomy, $post_type, $location_type, $loc, $count_type) { if ($term_id > 0 && $post_type == 'gd_event') { global $wpdb, $plugin_prefix; if ($count_type == 'review_count') { $listing_table = $plugin_prefix . $post_type . '_detail'; $current_date = date_i18n( 'Y-m-d', current_time( 'timestamp' ) ); if (!$loc) { $loc = geodir_get_current_location_terms(); } $country = isset($loc['gd_country']) && $loc['gd_country'] != '' ? $loc['gd_country'] : ''; $region = isset($loc['gd_region']) && $loc['gd_region'] != '' ? $loc['gd_region'] : ''; $city = isset($loc['gd_city']) && $loc['gd_city'] != '' ? $loc['gd_city'] : ''; $where = ''; if ( $country!= '') { $where .= " AND ed.post_locations LIKE '%,[".$country."]' "; } if ( $region != '' && $location_type!='gd_country' ) { $where .= " AND ed.post_locations LIKE '%,[".$region."],%' "; } if ( $city != '' && $location_type!='gd_country' && $location_type!='gd_region' ) { $where .= " AND ed.post_locations LIKE '[".$city."],%' "; } $sql = "SELECT COALESCE(SUM(ed.rating_count),0) FROM `" . $listing_table . "` AS ed INNER JOIN " . EVENT_SCHEDULE . " AS es ON (es.event_id = ed.post_id) WHERE ed.post_status = 'publish' " . $where . " AND ed.rating_count > 0 AND FIND_IN_SET(" . $term_id . ", ed." . $taxonomy . ")"; $sql .= " AND (es.event_date >= '" . $current_date . "' OR (es.event_date <= '" . $current_date . "' AND es.event_enddate >= '" . $current_date . "'))"; } } return $sql; }