@@ -9,10 +9,10 @@ discard block |
||
9 | 9 | */ |
10 | 10 | function geodir_get_current_city_lat() |
11 | 11 | { |
12 | - $location = geodir_get_default_location(); |
|
13 | - $lat = isset($location_result->city_latitude) ? $location_result->city_latitude : '39.952484'; |
|
12 | + $location = geodir_get_default_location(); |
|
13 | + $lat = isset($location_result->city_latitude) ? $location_result->city_latitude : '39.952484'; |
|
14 | 14 | |
15 | - return $lat; |
|
15 | + return $lat; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function geodir_get_current_city_lng() |
27 | 27 | { |
28 | - $location = geodir_get_default_location(); |
|
29 | - $lng = isset($location_result->city_longitude) ? $location_result->city_longitude : '-75.163786'; |
|
30 | - return $lng; |
|
28 | + $location = geodir_get_default_location(); |
|
29 | + $lng = isset($location_result->city_longitude) ? $location_result->city_longitude : '-75.163786'; |
|
30 | + return $lng; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function geodir_get_default_location() |
42 | 42 | { |
43 | - /** |
|
44 | - * Filter the default location. |
|
45 | - * |
|
46 | - * @since 1.0.0 |
|
47 | - * @package GeoDirectory |
|
48 | - * |
|
49 | - * @param string $location_result The default location object. |
|
50 | - */ |
|
51 | - return $location_result = apply_filters('geodir_get_default_location', get_option('geodir_default_location')); |
|
43 | + /** |
|
44 | + * Filter the default location. |
|
45 | + * |
|
46 | + * @since 1.0.0 |
|
47 | + * @package GeoDirectory |
|
48 | + * |
|
49 | + * @param string $location_result The default location object. |
|
50 | + */ |
|
51 | + return $location_result = apply_filters('geodir_get_default_location', get_option('geodir_default_location')); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | */ |
61 | 61 | function geodir_is_default_location_set() |
62 | 62 | { |
63 | - $default_location = geodir_get_default_location(); |
|
64 | - if (!empty($default_location)) |
|
65 | - return true; |
|
66 | - else |
|
67 | - return false; |
|
63 | + $default_location = geodir_get_default_location(); |
|
64 | + if (!empty($default_location)) |
|
65 | + return true; |
|
66 | + else |
|
67 | + return false; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | function create_location_slug($location_string) |
79 | 79 | { |
80 | 80 | |
81 | - /** |
|
82 | - * Filter the location slug. |
|
83 | - * |
|
84 | - * @since 1.0.0 |
|
85 | - * @package GeoDirectory |
|
86 | - * |
|
87 | - * @param string $location_string Sanitized location string. |
|
88 | - */ |
|
89 | - return urldecode(apply_filters('geodir_location_slug_check', sanitize_title($location_string))); |
|
81 | + /** |
|
82 | + * Filter the location slug. |
|
83 | + * |
|
84 | + * @since 1.0.0 |
|
85 | + * @package GeoDirectory |
|
86 | + * |
|
87 | + * @param string $location_string Sanitized location string. |
|
88 | + */ |
|
89 | + return urldecode(apply_filters('geodir_location_slug_check', sanitize_title($location_string))); |
|
90 | 90 | |
91 | 91 | } |
92 | 92 | |
@@ -100,15 +100,15 @@ discard block |
||
100 | 100 | */ |
101 | 101 | function geodir_get_location($id = '') |
102 | 102 | { |
103 | - /** |
|
104 | - * Filter the location information. |
|
105 | - * |
|
106 | - * @since 1.0.0 |
|
107 | - * @package GeoDirectory |
|
108 | - * |
|
109 | - * @param string $id The location ID. |
|
110 | - */ |
|
111 | - return $location_result = apply_filters('geodir_get_location_by_id', get_option('geodir_default_location'), $id); |
|
103 | + /** |
|
104 | + * Filter the location information. |
|
105 | + * |
|
106 | + * @since 1.0.0 |
|
107 | + * @package GeoDirectory |
|
108 | + * |
|
109 | + * @param string $id The location ID. |
|
110 | + */ |
|
111 | + return $location_result = apply_filters('geodir_get_location_by_id', get_option('geodir_default_location'), $id); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -122,28 +122,28 @@ discard block |
||
122 | 122 | */ |
123 | 123 | function geodir_get_country_dl($post_country = '', $prefix = '') |
124 | 124 | { |
125 | - global $wpdb; |
|
125 | + global $wpdb; |
|
126 | 126 | |
127 | - $rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC"); |
|
127 | + $rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC"); |
|
128 | 128 | |
129 | - $ISO2 = array(); |
|
130 | - $countries = array(); |
|
129 | + $ISO2 = array(); |
|
130 | + $countries = array(); |
|
131 | 131 | |
132 | - foreach ($rows as $row) { |
|
133 | - $ISO2[$row->Country] = $row->ISO2; |
|
134 | - $countries[$row->Country] = __($row->Country, 'geodirectory'); |
|
135 | - } |
|
132 | + foreach ($rows as $row) { |
|
133 | + $ISO2[$row->Country] = $row->ISO2; |
|
134 | + $countries[$row->Country] = __($row->Country, 'geodirectory'); |
|
135 | + } |
|
136 | 136 | |
137 | - asort($countries); |
|
137 | + asort($countries); |
|
138 | 138 | |
139 | - $out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>'; |
|
140 | - foreach ($countries as $country => $name) { |
|
141 | - $ccode = $ISO2[$country]; |
|
139 | + $out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>'; |
|
140 | + foreach ($countries as $country => $name) { |
|
141 | + $ccode = $ISO2[$country]; |
|
142 | 142 | |
143 | - $out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>'; |
|
144 | - } |
|
143 | + $out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>'; |
|
144 | + } |
|
145 | 145 | |
146 | - echo $out_put; |
|
146 | + echo $out_put; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -158,40 +158,40 @@ discard block |
||
158 | 158 | function geodir_location_form_submit() |
159 | 159 | { |
160 | 160 | |
161 | - global $wpdb, $plugin_prefix; |
|
162 | - if (isset($_REQUEST['add_location'])) { |
|
161 | + global $wpdb, $plugin_prefix; |
|
162 | + if (isset($_REQUEST['add_location'])) { |
|
163 | 163 | |
164 | - $location_info = array( |
|
165 | - 'city' => $_REQUEST['city'], |
|
166 | - 'region' => $_REQUEST['region'], |
|
167 | - 'country' => $_REQUEST['country'], |
|
168 | - 'geo_lat' => $_REQUEST['latitude'], |
|
169 | - 'geo_lng' => $_REQUEST['longitude'], |
|
170 | - 'is_default' => $_REQUEST['is_default'], |
|
171 | - 'update_city' => $_REQUEST['update_city'] |
|
172 | - ); |
|
164 | + $location_info = array( |
|
165 | + 'city' => $_REQUEST['city'], |
|
166 | + 'region' => $_REQUEST['region'], |
|
167 | + 'country' => $_REQUEST['country'], |
|
168 | + 'geo_lat' => $_REQUEST['latitude'], |
|
169 | + 'geo_lng' => $_REQUEST['longitude'], |
|
170 | + 'is_default' => $_REQUEST['is_default'], |
|
171 | + 'update_city' => $_REQUEST['update_city'] |
|
172 | + ); |
|
173 | 173 | |
174 | - $old_location = geodir_get_default_location(); |
|
174 | + $old_location = geodir_get_default_location(); |
|
175 | 175 | |
176 | - $locationid = geodir_add_new_location($location_info); |
|
176 | + $locationid = geodir_add_new_location($location_info); |
|
177 | 177 | |
178 | - $default_location = geodir_get_location($locationid); |
|
178 | + $default_location = geodir_get_location($locationid); |
|
179 | 179 | |
180 | - //UPDATE AND DELETE LISTING |
|
181 | - $posttype = geodir_get_posttypes(); |
|
182 | - if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') { |
|
180 | + //UPDATE AND DELETE LISTING |
|
181 | + $posttype = geodir_get_posttypes(); |
|
182 | + if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') { |
|
183 | 183 | |
184 | - foreach ($posttype as $posttypeobj) { |
|
185 | - $post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location |
|
184 | + foreach ($posttype as $posttypeobj) { |
|
185 | + $post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location |
|
186 | 186 | |
187 | - $sql = $wpdb->prepare( |
|
188 | - "UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)", |
|
189 | - array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations) |
|
190 | - ); |
|
191 | - $wpdb->query($sql); |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
187 | + $sql = $wpdb->prepare( |
|
188 | + "UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)", |
|
189 | + array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations) |
|
190 | + ); |
|
191 | + $wpdb->query($sql); |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -214,39 +214,39 @@ discard block |
||
214 | 214 | */ |
215 | 215 | function geodir_add_new_location($location_info = array()) |
216 | 216 | { |
217 | - global $wpdb; |
|
218 | - |
|
219 | - if (!empty($location_info)) { |
|
220 | - |
|
221 | - $location_city = ($location_info['city'] != '') ? $location_info['city'] : 'all'; |
|
222 | - $location_region = ($location_info['region'] != '') ? $location_info['region'] : 'all'; |
|
223 | - $location_country = ($location_info['country'] != '') ? $location_info['country'] : 'all'; |
|
224 | - $location_lat = ($location_info['geo_lat'] != '') ? $location_info['geo_lat'] : ''; |
|
225 | - $location_lng = ($location_info['geo_lng'] != '') ? $location_info['geo_lng'] : ''; |
|
226 | - $is_default = isset($location_info['is_default']) ? $location_info['is_default'] : ''; |
|
227 | - $country_slug = create_location_slug(__($location_country, 'geodirectory')); |
|
228 | - $region_slug = create_location_slug($location_region); |
|
229 | - $city_slug = create_location_slug($location_city); |
|
230 | - |
|
231 | - /** |
|
232 | - * Filter add new location data. |
|
233 | - * |
|
234 | - * @since 1.0.0 |
|
235 | - */ |
|
236 | - $geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0, |
|
237 | - 'country' => $location_country, |
|
238 | - 'region' => $location_region, |
|
239 | - 'city' => $location_city, |
|
240 | - 'country_slug' => $country_slug, |
|
241 | - 'region_slug' => $region_slug, |
|
242 | - 'city_slug' => $city_slug, |
|
243 | - 'city_latitude' => $location_lat, |
|
244 | - 'city_longitude' => $location_lng, |
|
245 | - 'is_default' => $is_default |
|
246 | - )); |
|
247 | - |
|
248 | - |
|
249 | - /* // Not allowed to create country in DB : 2016-12-09 |
|
217 | + global $wpdb; |
|
218 | + |
|
219 | + if (!empty($location_info)) { |
|
220 | + |
|
221 | + $location_city = ($location_info['city'] != '') ? $location_info['city'] : 'all'; |
|
222 | + $location_region = ($location_info['region'] != '') ? $location_info['region'] : 'all'; |
|
223 | + $location_country = ($location_info['country'] != '') ? $location_info['country'] : 'all'; |
|
224 | + $location_lat = ($location_info['geo_lat'] != '') ? $location_info['geo_lat'] : ''; |
|
225 | + $location_lng = ($location_info['geo_lng'] != '') ? $location_info['geo_lng'] : ''; |
|
226 | + $is_default = isset($location_info['is_default']) ? $location_info['is_default'] : ''; |
|
227 | + $country_slug = create_location_slug(__($location_country, 'geodirectory')); |
|
228 | + $region_slug = create_location_slug($location_region); |
|
229 | + $city_slug = create_location_slug($location_city); |
|
230 | + |
|
231 | + /** |
|
232 | + * Filter add new location data. |
|
233 | + * |
|
234 | + * @since 1.0.0 |
|
235 | + */ |
|
236 | + $geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0, |
|
237 | + 'country' => $location_country, |
|
238 | + 'region' => $location_region, |
|
239 | + 'city' => $location_city, |
|
240 | + 'country_slug' => $country_slug, |
|
241 | + 'region_slug' => $region_slug, |
|
242 | + 'city_slug' => $city_slug, |
|
243 | + 'city_latitude' => $location_lat, |
|
244 | + 'city_longitude' => $location_lng, |
|
245 | + 'is_default' => $is_default |
|
246 | + )); |
|
247 | + |
|
248 | + |
|
249 | + /* // Not allowed to create country in DB : 2016-12-09 |
|
250 | 250 | if ($geodir_location->country) { |
251 | 251 | |
252 | 252 | $get_country = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country=%s", array($geodir_location->country))); |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | } |
261 | 261 | */ |
262 | 262 | |
263 | - if ($geodir_location->is_default) |
|
264 | - update_option('geodir_default_location', $geodir_location); |
|
263 | + if ($geodir_location->is_default) |
|
264 | + update_option('geodir_default_location', $geodir_location); |
|
265 | 265 | |
266 | - return $geodir_location->location_id; |
|
266 | + return $geodir_location->location_id; |
|
267 | 267 | |
268 | - } else { |
|
269 | - return false; |
|
270 | - } |
|
268 | + } else { |
|
269 | + return false; |
|
270 | + } |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | */ |
282 | 282 | function geodir_random_float($min = 0, $max = 1) |
283 | 283 | { |
284 | - return $min + mt_rand() / mt_getrandmax() * ($max - $min); |
|
284 | + return $min + mt_rand() / mt_getrandmax() * ($max - $min); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -295,22 +295,22 @@ discard block |
||
295 | 295 | */ |
296 | 296 | function geodir_get_address_by_lat_lan($lat, $lng) |
297 | 297 | { |
298 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) ; |
|
299 | - |
|
300 | - $ch = curl_init(); |
|
301 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
302 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
303 | - curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
304 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
305 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
306 | - $response = curl_exec($ch); |
|
307 | - curl_close($ch); |
|
308 | - $data = json_decode($response); |
|
309 | - $status = $data->status; |
|
310 | - if ($status == "OK") { |
|
311 | - return $data->results[0]->address_components; |
|
312 | - } else |
|
313 | - return false; |
|
298 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) ; |
|
299 | + |
|
300 | + $ch = curl_init(); |
|
301 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
302 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
303 | + curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
304 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
305 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
306 | + $response = curl_exec($ch); |
|
307 | + curl_close($ch); |
|
308 | + $data = json_decode($response); |
|
309 | + $status = $data->status; |
|
310 | + if ($status == "OK") { |
|
311 | + return $data->results[0]->address_components; |
|
312 | + } else |
|
313 | + return false; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -327,70 +327,70 @@ discard block |
||
327 | 327 | */ |
328 | 328 | function geodir_get_current_location_terms($location_array_from = 'session', $gd_post_type = '') |
329 | 329 | { |
330 | - global $wp, $gd_session; |
|
331 | - $location_array = array(); |
|
332 | - if ($location_array_from == 'session') { |
|
333 | - if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') { |
|
334 | - return $location_array; |
|
335 | - } |
|
330 | + global $wp, $gd_session; |
|
331 | + $location_array = array(); |
|
332 | + if ($location_array_from == 'session') { |
|
333 | + if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') { |
|
334 | + return $location_array; |
|
335 | + } |
|
336 | 336 | |
337 | - $country = $gd_session->get('gd_country'); |
|
338 | - if ($country != '' && $country) |
|
339 | - $location_array['gd_country'] = urldecode($country); |
|
337 | + $country = $gd_session->get('gd_country'); |
|
338 | + if ($country != '' && $country) |
|
339 | + $location_array['gd_country'] = urldecode($country); |
|
340 | 340 | |
341 | - $region = $gd_session->get('gd_region'); |
|
342 | - if ($region != '' && $region) |
|
343 | - $location_array['gd_region'] = urldecode($region); |
|
341 | + $region = $gd_session->get('gd_region'); |
|
342 | + if ($region != '' && $region) |
|
343 | + $location_array['gd_region'] = urldecode($region); |
|
344 | 344 | |
345 | - $city = $gd_session->get('gd_city'); |
|
346 | - if ($city != '' && $city) |
|
347 | - $location_array['gd_city'] = urldecode($city); |
|
348 | - } else { |
|
349 | - if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) { |
|
350 | - return $location_array; |
|
351 | - } |
|
345 | + $city = $gd_session->get('gd_city'); |
|
346 | + if ($city != '' && $city) |
|
347 | + $location_array['gd_city'] = urldecode($city); |
|
348 | + } else { |
|
349 | + if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) { |
|
350 | + return $location_array; |
|
351 | + } |
|
352 | 352 | |
353 | - $country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
353 | + $country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
354 | 354 | |
355 | - $region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
355 | + $region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
356 | 356 | |
357 | - $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
357 | + $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
358 | 358 | |
359 | - if ($country != '') |
|
360 | - $location_array['gd_country'] = urldecode($country); |
|
359 | + if ($country != '') |
|
360 | + $location_array['gd_country'] = urldecode($country); |
|
361 | 361 | |
362 | - if ($region != '') |
|
363 | - $location_array['gd_region'] = urldecode($region); |
|
362 | + if ($region != '') |
|
363 | + $location_array['gd_region'] = urldecode($region); |
|
364 | 364 | |
365 | - if ($city != '') |
|
366 | - $location_array['gd_city'] = urldecode($city); |
|
365 | + if ($city != '') |
|
366 | + $location_array['gd_city'] = urldecode($city); |
|
367 | 367 | |
368 | 368 | // Fix category link in ajax popular category widget on change post type |
369 | 369 | if (empty($location_array) && defined('DOING_AJAX') && DOING_AJAX) { |
370 | 370 | $location_array = geodir_get_current_location_terms('session'); |
371 | 371 | } |
372 | - } |
|
372 | + } |
|
373 | 373 | |
374 | 374 | /** |
375 | 375 | * Filter the location terms. |
376 | 376 | * |
377 | 377 | * @since 1.4.6 |
378 | - * @package GeoDirectory |
|
378 | + * @package GeoDirectory |
|
379 | + * |
|
380 | + * @param array $location_array { |
|
381 | + * Attributes of the location_array. |
|
382 | + * |
|
383 | + * @type string $gd_country The country slug. |
|
384 | + * @type string $gd_region The region slug. |
|
385 | + * @type string $gd_city The city slug. |
|
379 | 386 | * |
380 | - * @param array $location_array { |
|
381 | - * Attributes of the location_array. |
|
382 | - * |
|
383 | - * @type string $gd_country The country slug. |
|
384 | - * @type string $gd_region The region slug. |
|
385 | - * @type string $gd_city The city slug. |
|
386 | - * |
|
387 | - * } |
|
387 | + * } |
|
388 | 388 | * @param string $location_array_from Source type of location terms. Default session. |
389 | 389 | * @param string $gd_post_type WP post type. |
390 | 390 | */ |
391 | 391 | $location_array = apply_filters( 'geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type ); |
392 | 392 | |
393 | - return $location_array; |
|
393 | + return $location_array; |
|
394 | 394 | |
395 | 395 | } |
396 | 396 | |
@@ -403,24 +403,24 @@ discard block |
||
403 | 403 | * @return bool|string |
404 | 404 | */ |
405 | 405 | function geodir_get_location_link($which_location = 'current') { |
406 | - $location_link = get_permalink(geodir_location_page_id()); |
|
407 | - |
|
408 | - if ($which_location == 'base') { |
|
409 | - return $location_link; |
|
410 | - } else { |
|
411 | - $location_terms = geodir_get_current_location_terms(); |
|
412 | - |
|
413 | - if (!empty($location_terms)) { |
|
414 | - if (get_option('permalink_structure') != '') { |
|
415 | - $location_terms = implode("/", $location_terms); |
|
416 | - $location_terms = rtrim($location_terms, '/'); |
|
417 | - $location_link .= $location_terms; |
|
418 | - } else { |
|
419 | - $location_link = geodir_getlink($location_link, $location_terms); |
|
420 | - } |
|
421 | - } |
|
422 | - } |
|
423 | - return $location_link; |
|
406 | + $location_link = get_permalink(geodir_location_page_id()); |
|
407 | + |
|
408 | + if ($which_location == 'base') { |
|
409 | + return $location_link; |
|
410 | + } else { |
|
411 | + $location_terms = geodir_get_current_location_terms(); |
|
412 | + |
|
413 | + if (!empty($location_terms)) { |
|
414 | + if (get_option('permalink_structure') != '') { |
|
415 | + $location_terms = implode("/", $location_terms); |
|
416 | + $location_terms = rtrim($location_terms, '/'); |
|
417 | + $location_link .= $location_terms; |
|
418 | + } else { |
|
419 | + $location_link = geodir_getlink($location_link, $location_terms); |
|
420 | + } |
|
421 | + } |
|
422 | + } |
|
423 | + return $location_link; |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -433,32 +433,32 @@ discard block |
||
433 | 433 | * @return array|bool Returns address on success. |
434 | 434 | */ |
435 | 435 | function geodir_get_osm_address_by_lat_lan($lat, $lng) { |
436 | - $url = is_ssl() ? 'https:' : 'http:'; |
|
437 | - $url .= '//nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email'); |
|
438 | - |
|
439 | - $ch = curl_init(); |
|
440 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
441 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
442 | - curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
443 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
444 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
445 | - $response = curl_exec($ch); |
|
446 | - curl_close($ch); |
|
447 | - $data = json_decode($response); |
|
436 | + $url = is_ssl() ? 'https:' : 'http:'; |
|
437 | + $url .= '//nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email'); |
|
438 | + |
|
439 | + $ch = curl_init(); |
|
440 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
441 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
442 | + curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
443 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
444 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
445 | + $response = curl_exec($ch); |
|
446 | + curl_close($ch); |
|
447 | + $data = json_decode($response); |
|
448 | 448 | |
449 | - if (!empty($data) && !empty($data->address)) { |
|
450 | - $address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb'); |
|
451 | - $formatted_address = (array)$data->address; |
|
449 | + if (!empty($data) && !empty($data->address)) { |
|
450 | + $address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb'); |
|
451 | + $formatted_address = (array)$data->address; |
|
452 | 452 | |
453 | - foreach ( $data->address as $key => $value ) { |
|
454 | - if (!in_array($key, $address_fields)) { |
|
455 | - unset($formatted_address[$key]); |
|
456 | - } |
|
457 | - } |
|
458 | - $data->formatted_address = !empty($formatted_address) ? implode(', ', $formatted_address) : ''; |
|
453 | + foreach ( $data->address as $key => $value ) { |
|
454 | + if (!in_array($key, $address_fields)) { |
|
455 | + unset($formatted_address[$key]); |
|
456 | + } |
|
457 | + } |
|
458 | + $data->formatted_address = !empty($formatted_address) ? implode(', ', $formatted_address) : ''; |
|
459 | 459 | |
460 | - return $data; |
|
461 | - } else { |
|
462 | - return false; |
|
463 | - } |
|
460 | + return $data; |
|
461 | + } else { |
|
462 | + return false; |
|
463 | + } |
|
464 | 464 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | { |
125 | 125 | global $wpdb; |
126 | 126 | |
127 | - $rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC"); |
|
127 | + $rows = $wpdb->get_results("SELECT Country,ISO2 FROM ".GEODIR_COUNTRIES_TABLE." ORDER BY Country ASC"); |
|
128 | 128 | |
129 | 129 | $ISO2 = array(); |
130 | 130 | $countries = array(); |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | |
137 | 137 | asort($countries); |
138 | 138 | |
139 | - $out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>'; |
|
139 | + $out_put = '<option '.selected('', $post_country, false).' value="">'.__('Select Country', 'geodirectory').'</option>'; |
|
140 | 140 | foreach ($countries as $country => $name) { |
141 | 141 | $ccode = $ISO2[$country]; |
142 | 142 | |
143 | - $out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>'; |
|
143 | + $out_put .= '<option '.selected($post_country, $country, false).' value="'.esc_attr($country).'" data-country_code="'.$ccode.'">'.$name.'</option>'; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | echo $out_put; |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') { |
183 | 183 | |
184 | 184 | foreach ($posttype as $posttypeobj) { |
185 | - $post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location |
|
185 | + $post_locations = '['.$default_location->city_slug.'],['.$default_location->region_slug.'],['.$default_location->country_slug.']'; // set all overall post location |
|
186 | 186 | |
187 | 187 | $sql = $wpdb->prepare( |
188 | - "UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)", |
|
188 | + "UPDATE ".$plugin_prefix.$posttypeobj."_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)", |
|
189 | 189 | array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations) |
190 | 190 | ); |
191 | 191 | $wpdb->query($sql); |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @since 1.0.0 |
235 | 235 | */ |
236 | - $geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0, |
|
236 | + $geodir_location = (object) apply_filters('geodir_add_new_location', array('location_id' => 0, |
|
237 | 237 | 'country' => $location_country, |
238 | 238 | 'region' => $location_region, |
239 | 239 | 'city' => $location_city, |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | */ |
296 | 296 | function geodir_get_address_by_lat_lan($lat, $lng) |
297 | 297 | { |
298 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) ; |
|
298 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($lat).','.trim($lng); |
|
299 | 299 | |
300 | 300 | $ch = curl_init(); |
301 | 301 | curl_setopt($ch, CURLOPT_URL, $url); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @param string $location_array_from Source type of location terms. Default session. |
389 | 389 | * @param string $gd_post_type WP post type. |
390 | 390 | */ |
391 | - $location_array = apply_filters( 'geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type ); |
|
391 | + $location_array = apply_filters('geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type); |
|
392 | 392 | |
393 | 393 | return $location_array; |
394 | 394 | |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | */ |
435 | 435 | function geodir_get_osm_address_by_lat_lan($lat, $lng) { |
436 | 436 | $url = is_ssl() ? 'https:' : 'http:'; |
437 | - $url .= '//nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email'); |
|
437 | + $url .= '//nominatim.openstreetmap.org/reverse?format=json&lat='.trim($lat).'&lon='.trim($lng).'&zoom=16&addressdetails=1&email='.get_option('admin_email'); |
|
438 | 438 | |
439 | 439 | $ch = curl_init(); |
440 | 440 | curl_setopt($ch, CURLOPT_URL, $url); |
@@ -448,9 +448,9 @@ discard block |
||
448 | 448 | |
449 | 449 | if (!empty($data) && !empty($data->address)) { |
450 | 450 | $address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb'); |
451 | - $formatted_address = (array)$data->address; |
|
451 | + $formatted_address = (array) $data->address; |
|
452 | 452 | |
453 | - foreach ( $data->address as $key => $value ) { |
|
453 | + foreach ($data->address as $key => $value) { |
|
454 | 454 | if (!in_array($key, $address_fields)) { |
455 | 455 | unset($formatted_address[$key]); |
456 | 456 | } |