/** * Register the Google Maps Script * Only Enqueue when needed */ protected function addGoogleMaps() { if (!$this->settings_repo->outputGMaps()) { return; } $maps_url = 'https://maps.google.com/maps/api/js?'; $maps_url .= get_option('wpsl_google_api_key') ? 'key=' . get_option('wpsl_google_api_key') . '&' : ''; $maps_url .= '&libraries=places'; $maps_url .= '&sensor=false'; wp_register_script('google-maps', $maps_url); }
/** * Save map field coordinates to the selected latitude/longitude fields * @param int $post_id * @see https://wordpress.org/support/topic/possible-to-search-distance-between-posts-user */ public function saveMapFieldCoordinates($post_id) { if (empty($_POST['acf'])) { return; } $option = get_option('wpsl_acf_map_field'); if (!$option) { return; } if (!isset($_POST['acf'][$option])) { return; } $map_field = $_POST['acf'][$option]; if (isset($map_field['lat']) && isset($map_field['lng'])) { update_post_meta($post_id, $this->settings_repo->getGeoField('lat'), $map_field['lat']); update_post_meta($post_id, $this->settings_repo->getGeoField('lng'), $map_field['lng']); } }
/** * Set the SQL Limit */ private function sqlLimit() { if ($this->data['limit']) { $limit = "LIMIT "; if ($this->data['offset']) { $limit .= $this->data['offset'] . ','; } $limit .= $this->data['limit'] + 1; return $limit; } $limit = $this->settings_repo->resultsLimit(); if ($limit == -1) { return; } if (is_numeric(intval($limit))) { return "LIMIT " . intval($limit); } }