@@ -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,58 +214,58 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | function geodir_add_new_location($location_info = array()) |
| 216 | 216 | {
|
| 217 | - global $wpdb; |
|
| 217 | + global $wpdb; |
|
| 218 | 218 | |
| 219 | - if (!empty($location_info)) {
|
|
| 219 | + if (!empty($location_info)) {
|
|
| 220 | 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); |
|
| 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 | 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 | - )); |
|
| 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 | 247 | |
| 248 | 248 | |
| 249 | - if ($geodir_location->country) {
|
|
| 249 | + if ($geodir_location->country) {
|
|
| 250 | 250 | |
| 251 | - $get_country = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country=%s", array($geodir_location->country)));
|
|
| 251 | + $get_country = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country=%s", array($geodir_location->country)));
|
|
| 252 | 252 | |
| 253 | - if (empty($get_country)) {
|
|
| 253 | + if (empty($get_country)) {
|
|
| 254 | 254 | |
| 255 | - $wpdb->query($wpdb->prepare("INSERT INTO " . GEODIR_COUNTRIES_TABLE . " (Country, Title) VALUES (%s,%s)", array($geodir_location->country, $geodir_location->country)));
|
|
| 255 | + $wpdb->query($wpdb->prepare("INSERT INTO " . GEODIR_COUNTRIES_TABLE . " (Country, Title) VALUES (%s,%s)", array($geodir_location->country, $geodir_location->country)));
|
|
| 256 | 256 | |
| 257 | - } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - } |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - if ($geodir_location->is_default) |
|
| 262 | - update_option('geodir_default_location', $geodir_location);
|
|
| 261 | + if ($geodir_location->is_default) |
|
| 262 | + update_option('geodir_default_location', $geodir_location);
|
|
| 263 | 263 | |
| 264 | - return $geodir_location->location_id; |
|
| 264 | + return $geodir_location->location_id; |
|
| 265 | 265 | |
| 266 | - } else {
|
|
| 267 | - return false; |
|
| 268 | - } |
|
| 266 | + } else {
|
|
| 267 | + return false; |
|
| 268 | + } |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | function geodir_random_float($min = 0, $max = 1) |
| 281 | 281 | {
|
| 282 | - return $min + mt_rand() / mt_getrandmax() * ($max - $min); |
|
| 282 | + return $min + mt_rand() / mt_getrandmax() * ($max - $min); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -293,22 +293,22 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | function geodir_get_address_by_lat_lan($lat, $lng) |
| 295 | 295 | {
|
| 296 | - $url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) ; |
|
| 297 | - |
|
| 298 | - $ch = curl_init(); |
|
| 299 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
| 300 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 301 | - curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
| 302 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
| 303 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
| 304 | - $response = curl_exec($ch); |
|
| 305 | - curl_close($ch); |
|
| 306 | - $data = json_decode($response); |
|
| 307 | - $status = $data->status; |
|
| 308 | - if ($status == "OK") {
|
|
| 309 | - return $data->results[0]->address_components; |
|
| 310 | - } else |
|
| 311 | - return false; |
|
| 296 | + $url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) ; |
|
| 297 | + |
|
| 298 | + $ch = curl_init(); |
|
| 299 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 300 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 301 | + curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
| 302 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
| 303 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
| 304 | + $response = curl_exec($ch); |
|
| 305 | + curl_close($ch); |
|
| 306 | + $data = json_decode($response); |
|
| 307 | + $status = $data->status; |
|
| 308 | + if ($status == "OK") {
|
|
| 309 | + return $data->results[0]->address_components; |
|
| 310 | + } else |
|
| 311 | + return false; |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | /** |
@@ -325,70 +325,70 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | function geodir_get_current_location_terms($location_array_from = 'session', $gd_post_type = '') |
| 327 | 327 | {
|
| 328 | - global $wp, $gd_session; |
|
| 329 | - $location_array = array(); |
|
| 330 | - if ($location_array_from == 'session') {
|
|
| 331 | - if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') {
|
|
| 332 | - return $location_array; |
|
| 333 | - } |
|
| 328 | + global $wp, $gd_session; |
|
| 329 | + $location_array = array(); |
|
| 330 | + if ($location_array_from == 'session') {
|
|
| 331 | + if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') {
|
|
| 332 | + return $location_array; |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - $country = $gd_session->get('gd_country');
|
|
| 336 | - if ($country != '' && $country) |
|
| 337 | - $location_array['gd_country'] = urldecode($country); |
|
| 335 | + $country = $gd_session->get('gd_country');
|
|
| 336 | + if ($country != '' && $country) |
|
| 337 | + $location_array['gd_country'] = urldecode($country); |
|
| 338 | 338 | |
| 339 | - $region = $gd_session->get('gd_region');
|
|
| 340 | - if ($region != '' && $region) |
|
| 341 | - $location_array['gd_region'] = urldecode($region); |
|
| 339 | + $region = $gd_session->get('gd_region');
|
|
| 340 | + if ($region != '' && $region) |
|
| 341 | + $location_array['gd_region'] = urldecode($region); |
|
| 342 | 342 | |
| 343 | - $city = $gd_session->get('gd_city');
|
|
| 344 | - if ($city != '' && $city) |
|
| 345 | - $location_array['gd_city'] = urldecode($city); |
|
| 346 | - } else {
|
|
| 347 | - 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')) {
|
|
| 348 | - return $location_array; |
|
| 349 | - } |
|
| 343 | + $city = $gd_session->get('gd_city');
|
|
| 344 | + if ($city != '' && $city) |
|
| 345 | + $location_array['gd_city'] = urldecode($city); |
|
| 346 | + } else {
|
|
| 347 | + 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')) {
|
|
| 348 | + return $location_array; |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | - $country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 351 | + $country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 352 | 352 | |
| 353 | - $region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 353 | + $region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 354 | 354 | |
| 355 | - $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 355 | + $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 356 | 356 | |
| 357 | - if ($country != '') |
|
| 358 | - $location_array['gd_country'] = urldecode($country); |
|
| 357 | + if ($country != '') |
|
| 358 | + $location_array['gd_country'] = urldecode($country); |
|
| 359 | 359 | |
| 360 | - if ($region != '') |
|
| 361 | - $location_array['gd_region'] = urldecode($region); |
|
| 360 | + if ($region != '') |
|
| 361 | + $location_array['gd_region'] = urldecode($region); |
|
| 362 | 362 | |
| 363 | - if ($city != '') |
|
| 364 | - $location_array['gd_city'] = urldecode($city); |
|
| 363 | + if ($city != '') |
|
| 364 | + $location_array['gd_city'] = urldecode($city); |
|
| 365 | 365 | |
| 366 | 366 | // Fix category link in ajax popular category widget on change post type |
| 367 | 367 | if (empty($location_array) && defined('DOING_AJAX') && DOING_AJAX) {
|
| 368 | 368 | $location_array = geodir_get_current_location_terms('session');
|
| 369 | 369 | } |
| 370 | - } |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | 372 | /** |
| 373 | 373 | * Filter the location terms. |
| 374 | 374 | * |
| 375 | 375 | * @since 1.4.6 |
| 376 | - * @package GeoDirectory |
|
| 376 | + * @package GeoDirectory |
|
| 377 | + * |
|
| 378 | + * @param array $location_array {
|
|
| 379 | + * Attributes of the location_array. |
|
| 377 | 380 | * |
| 378 | - * @param array $location_array {
|
|
| 379 | - * Attributes of the location_array. |
|
| 380 | - * |
|
| 381 | - * @type string $gd_country The country slug. |
|
| 382 | - * @type string $gd_region The region slug. |
|
| 383 | - * @type string $gd_city The city slug. |
|
| 384 | - * |
|
| 385 | - * } |
|
| 381 | + * @type string $gd_country The country slug. |
|
| 382 | + * @type string $gd_region The region slug. |
|
| 383 | + * @type string $gd_city The city slug. |
|
| 384 | + * |
|
| 385 | + * } |
|
| 386 | 386 | * @param string $location_array_from Source type of location terms. Default session. |
| 387 | 387 | * @param string $gd_post_type WP post type. |
| 388 | 388 | */ |
| 389 | 389 | $location_array = apply_filters( 'geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type ); |
| 390 | 390 | |
| 391 | - return $location_array; |
|
| 391 | + return $location_array; |
|
| 392 | 392 | |
| 393 | 393 | } |
| 394 | 394 | |
@@ -401,22 +401,22 @@ discard block |
||
| 401 | 401 | * @return bool|string |
| 402 | 402 | */ |
| 403 | 403 | function geodir_get_location_link($which_location = 'current') {
|
| 404 | - $location_link = get_permalink(geodir_location_page_id()); |
|
| 405 | - |
|
| 406 | - if ($which_location == 'base') {
|
|
| 407 | - return $location_link; |
|
| 408 | - } else {
|
|
| 409 | - $location_terms = geodir_get_current_location_terms(); |
|
| 410 | - |
|
| 411 | - if (!empty($location_terms)) {
|
|
| 412 | - if (get_option('permalink_structure') != '') {
|
|
| 413 | - $location_terms = implode("/", $location_terms);
|
|
| 414 | - $location_terms = rtrim($location_terms, '/'); |
|
| 415 | - $location_link .= $location_terms; |
|
| 416 | - } else {
|
|
| 417 | - $location_link = geodir_getlink($location_link, $location_terms); |
|
| 418 | - } |
|
| 419 | - } |
|
| 420 | - } |
|
| 421 | - return $location_link; |
|
| 404 | + $location_link = get_permalink(geodir_location_page_id()); |
|
| 405 | + |
|
| 406 | + if ($which_location == 'base') {
|
|
| 407 | + return $location_link; |
|
| 408 | + } else {
|
|
| 409 | + $location_terms = geodir_get_current_location_terms(); |
|
| 410 | + |
|
| 411 | + if (!empty($location_terms)) {
|
|
| 412 | + if (get_option('permalink_structure') != '') {
|
|
| 413 | + $location_terms = implode("/", $location_terms);
|
|
| 414 | + $location_terms = rtrim($location_terms, '/'); |
|
| 415 | + $location_link .= $location_terms; |
|
| 416 | + } else {
|
|
| 417 | + $location_link = geodir_getlink($location_link, $location_terms); |
|
| 418 | + } |
|
| 419 | + } |
|
| 420 | + } |
|
| 421 | + return $location_link; |
|
| 422 | 422 | } |