getPRO()) return; // MEC Settings $settings = $this->get_settings(); // Google Maps on single page is disabled if(!isset($settings['google_maps_status']) || !$settings['google_maps_status']) return; $event = $event[0]; $uniqueid = $uniqueid ?? $event->data->ID; // Map is disabled for this event $dont_show_map = ((isset($event->data->meta['mec_dont_show_map']) and is_numeric($event->data->meta['mec_dont_show_map'])) ? $event->data->meta['mec_dont_show_map'] : 0); if(isset($event->date) and isset($event->date['start']) and isset($event->date['start']['timestamp'])) $dont_show_map = MEC_feature_occurrences::param($event->ID, $event->date['start']['timestamp'], 'dont_show_map', $dont_show_map); if($dont_show_map) return; // Event ID $event_id = $event->ID; $location_id = $this->get_master_location_id($event); $location = ($location_id ? $this->get_location_data($location_id) : array()); // Event location geo point $latitude = $location['latitude'] ?? ''; $longitude = $location['longitude'] ?? ''; $address = $location['address'] ?? ''; // Try to get the latitude and longitude on the fly if(!trim($latitude) or !trim($longitude)) { $geo_point = $this->get_lat_lng($address); $latitude = $geo_point[0]; $longitude = $geo_point[1]; if($location_id) { update_term_meta($location_id, 'latitude', $latitude); update_term_meta($location_id, 'longitude', $longitude); } } // Still Latitude and Longitude are wrong! if(!trim($latitude) or !trim($longitude)) return; // Include Map Assets such as JS and CSS libraries if(!$this->is_ajax()) $this->load_map_assets(); // Get Direction Status $get_direction = (isset($settings['google_maps_get_direction_status']) and in_array($settings['google_maps_get_direction_status'], array(0,1,2))) ? $settings['google_maps_get_direction_status'] : 0; $additional_location_ids = get_post_meta($event_id, 'mec_additional_location_ids', true); $event_locations = array_keys((array)$event->data->locations); $map_data = new stdClass; $map_data->id = $uniqueid; $map_data->atts = array( 'location_map_zoom' => $settings['google_maps_zoomlevel'] ?? 14, 'location_center_lat' => null, 'location_center_long' => null, 'use_orig_map' => true ); $map_data->events = array($event_id => $event); $map_data->render = $render; $map_data->geolocation = '0'; $map_data->sf_status = null; $current_event = (isset($map_data->events[$event_id]) ? array($map_data->events[$event_id]) : array()); $map_data->events = apply_filters('mec_location_load_additional', $current_event, $additional_location_ids, $event_locations); $scrollwheel = apply_filters( 'mec_google_map_scroll_wheel', false ); // Initialize MEC Google Maps jQuery plugin $javascript = ''; $javascript = apply_filters('mec_map_load_script', $javascript, $map_data, $settings); if(!function_exists('is_plugin_active')) include_once(ABSPATH . 'wp-admin/includes/plugin.php'); // Include javascript code into the footer if($this->is_ajax()) echo MEC_kses::full($javascript); elseif (is_plugin_active( 'mec-single-builder/mec-single-builder.php')) echo MEC_kses::full($javascript); else $factory->params('footer', $javascript); ?>
X