@@ -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 | } |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | if (defined('POST_LOCATION_TABLE')) {
|
| 481 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
|
|
| 481 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM ".POST_LOCATION_TABLE." WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
|
|
| 482 | 482 | if (!empty($rows)) {
|
| 483 | 483 | foreach ($rows as $row) {
|
| 484 | 484 | $translated = __($row->country, 'geodirectory'); |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | - $rows = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country ) ); |
|
| 491 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM ".POST_LOCATION_TABLE." WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country));
|
|
| 492 | 492 | if (!empty($rows)) {
|
| 493 | 493 | foreach ($rows as $row) {
|
| 494 | 494 | $translated = __($row->country, 'geodirectory'); |
@@ -526,10 +526,10 @@ discard block |
||
| 526 | 526 | function geodir_get_country_iso2($country) {
|
| 527 | 527 | global $wpdb; |
| 528 | 528 | |
| 529 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
|
|
| 529 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM ".GEODIR_COUNTRIES_TABLE." WHERE Country LIKE %s", $country))) {
|
|
| 530 | 530 | return $result; |
| 531 | 531 | } |
| 532 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", geodir_get_normal_country($country)))) {
|
|
| 532 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM ".GEODIR_COUNTRIES_TABLE." WHERE Country LIKE %s", geodir_get_normal_country($country)))) {
|
|
| 533 | 533 | return $result; |
| 534 | 534 | } |
| 535 | 535 | |
@@ -548,10 +548,10 @@ discard block |
||
| 548 | 548 | function geodir_get_country_by_name($country, $iso2 = false) {
|
| 549 | 549 | global $wpdb; |
| 550 | 550 | |
| 551 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
|
|
| 551 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM ".GEODIR_COUNTRIES_TABLE." WHERE Country LIKE %s", $country))) {
|
|
| 552 | 552 | return $result; |
| 553 | 553 | } |
| 554 | - if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE ISO2 LIKE %s", $country))) {
|
|
| 554 | + if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM ".GEODIR_COUNTRIES_TABLE." WHERE ISO2 LIKE %s", $country))) {
|
|
| 555 | 555 | return $result; |
| 556 | 556 | } |
| 557 | 557 | |
@@ -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 | /** |
@@ -215,37 +215,37 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | function geodir_add_new_location($location_info = array()) |
| 217 | 217 | {
|
| 218 | - global $wpdb; |
|
| 219 | - |
|
| 220 | - if (!empty($location_info)) {
|
|
| 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'] != '') ? geodir_get_normal_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); |
|
| 218 | + global $wpdb; |
|
| 219 | + |
|
| 220 | + if (!empty($location_info)) {
|
|
| 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'] != '') ? geodir_get_normal_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 | - )); |
|
| 247 | - |
|
| 248 | - /* // Not allowed to create country in DB : 2016-12-09 |
|
| 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 | + /* // Not allowed to create country in DB : 2016-12-09 |
|
| 249 | 249 | if ($geodir_location->country) {
|
| 250 | 250 | |
| 251 | 251 | $get_country = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country=%s", array($geodir_location->country)));
|
@@ -259,14 +259,14 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | */ |
| 261 | 261 | |
| 262 | - if ($geodir_location->is_default) |
|
| 263 | - update_option('geodir_default_location', $geodir_location);
|
|
| 262 | + if ($geodir_location->is_default) |
|
| 263 | + update_option('geodir_default_location', $geodir_location);
|
|
| 264 | 264 | |
| 265 | - return $geodir_location->location_id; |
|
| 265 | + return $geodir_location->location_id; |
|
| 266 | 266 | |
| 267 | - } else {
|
|
| 268 | - return false; |
|
| 269 | - } |
|
| 267 | + } else {
|
|
| 268 | + return false; |
|
| 269 | + } |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | */ |
| 281 | 281 | function geodir_random_float($min = 0, $max = 1) |
| 282 | 282 | {
|
| 283 | - return $min + mt_rand() / mt_getrandmax() * ($max - $min); |
|
| 283 | + return $min + mt_rand() / mt_getrandmax() * ($max - $min); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -294,22 +294,22 @@ discard block |
||
| 294 | 294 | */ |
| 295 | 295 | function geodir_get_address_by_lat_lan($lat, $lng) |
| 296 | 296 | {
|
| 297 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) ; |
|
| 298 | - |
|
| 299 | - $ch = curl_init(); |
|
| 300 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
| 301 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 302 | - curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
| 303 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
| 304 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
| 305 | - $response = curl_exec($ch); |
|
| 306 | - curl_close($ch); |
|
| 307 | - $data = json_decode($response); |
|
| 308 | - $status = $data->status; |
|
| 309 | - if ($status == "OK") {
|
|
| 310 | - return $data->results[0]->address_components; |
|
| 311 | - } else |
|
| 312 | - return false; |
|
| 297 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) ; |
|
| 298 | + |
|
| 299 | + $ch = curl_init(); |
|
| 300 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 301 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 302 | + curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
| 303 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
| 304 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
| 305 | + $response = curl_exec($ch); |
|
| 306 | + curl_close($ch); |
|
| 307 | + $data = json_decode($response); |
|
| 308 | + $status = $data->status; |
|
| 309 | + if ($status == "OK") {
|
|
| 310 | + return $data->results[0]->address_components; |
|
| 311 | + } else |
|
| 312 | + return false; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
@@ -326,70 +326,70 @@ discard block |
||
| 326 | 326 | */ |
| 327 | 327 | function geodir_get_current_location_terms($location_array_from = 'session', $gd_post_type = '') |
| 328 | 328 | {
|
| 329 | - global $wp, $gd_session; |
|
| 330 | - $location_array = array(); |
|
| 331 | - if ($location_array_from == 'session') {
|
|
| 332 | - if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') {
|
|
| 333 | - return $location_array; |
|
| 334 | - } |
|
| 329 | + global $wp, $gd_session; |
|
| 330 | + $location_array = array(); |
|
| 331 | + if ($location_array_from == 'session') {
|
|
| 332 | + if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') {
|
|
| 333 | + return $location_array; |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | - $country = $gd_session->get('gd_country');
|
|
| 337 | - if ($country != '' && $country) |
|
| 338 | - $location_array['gd_country'] = urldecode($country); |
|
| 336 | + $country = $gd_session->get('gd_country');
|
|
| 337 | + if ($country != '' && $country) |
|
| 338 | + $location_array['gd_country'] = urldecode($country); |
|
| 339 | 339 | |
| 340 | - $region = $gd_session->get('gd_region');
|
|
| 341 | - if ($region != '' && $region) |
|
| 342 | - $location_array['gd_region'] = urldecode($region); |
|
| 340 | + $region = $gd_session->get('gd_region');
|
|
| 341 | + if ($region != '' && $region) |
|
| 342 | + $location_array['gd_region'] = urldecode($region); |
|
| 343 | 343 | |
| 344 | - $city = $gd_session->get('gd_city');
|
|
| 345 | - if ($city != '' && $city) |
|
| 346 | - $location_array['gd_city'] = urldecode($city); |
|
| 347 | - } else {
|
|
| 348 | - 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')) {
|
|
| 349 | - return $location_array; |
|
| 350 | - } |
|
| 344 | + $city = $gd_session->get('gd_city');
|
|
| 345 | + if ($city != '' && $city) |
|
| 346 | + $location_array['gd_city'] = urldecode($city); |
|
| 347 | + } else {
|
|
| 348 | + 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')) {
|
|
| 349 | + return $location_array; |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | - $country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 352 | + $country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 353 | 353 | |
| 354 | - $region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 354 | + $region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 355 | 355 | |
| 356 | - $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 356 | + $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 357 | 357 | |
| 358 | - if ($country != '') |
|
| 359 | - $location_array['gd_country'] = urldecode($country); |
|
| 358 | + if ($country != '') |
|
| 359 | + $location_array['gd_country'] = urldecode($country); |
|
| 360 | 360 | |
| 361 | - if ($region != '') |
|
| 362 | - $location_array['gd_region'] = urldecode($region); |
|
| 361 | + if ($region != '') |
|
| 362 | + $location_array['gd_region'] = urldecode($region); |
|
| 363 | 363 | |
| 364 | - if ($city != '') |
|
| 365 | - $location_array['gd_city'] = urldecode($city); |
|
| 364 | + if ($city != '') |
|
| 365 | + $location_array['gd_city'] = urldecode($city); |
|
| 366 | 366 | |
| 367 | 367 | // Fix category link in ajax popular category widget on change post type |
| 368 | 368 | if (empty($location_array) && defined('DOING_AJAX') && DOING_AJAX) {
|
| 369 | 369 | $location_array = geodir_get_current_location_terms('session');
|
| 370 | 370 | } |
| 371 | - } |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | 373 | /** |
| 374 | 374 | * Filter the location terms. |
| 375 | 375 | * |
| 376 | 376 | * @since 1.4.6 |
| 377 | - * @package GeoDirectory |
|
| 377 | + * @package GeoDirectory |
|
| 378 | + * |
|
| 379 | + * @param array $location_array {
|
|
| 380 | + * Attributes of the location_array. |
|
| 381 | + * |
|
| 382 | + * @type string $gd_country The country slug. |
|
| 383 | + * @type string $gd_region The region slug. |
|
| 384 | + * @type string $gd_city The city slug. |
|
| 378 | 385 | * |
| 379 | - * @param array $location_array {
|
|
| 380 | - * Attributes of the location_array. |
|
| 381 | - * |
|
| 382 | - * @type string $gd_country The country slug. |
|
| 383 | - * @type string $gd_region The region slug. |
|
| 384 | - * @type string $gd_city The city slug. |
|
| 385 | - * |
|
| 386 | - * } |
|
| 386 | + * } |
|
| 387 | 387 | * @param string $location_array_from Source type of location terms. Default session. |
| 388 | 388 | * @param string $gd_post_type WP post type. |
| 389 | 389 | */ |
| 390 | 390 | $location_array = apply_filters( 'geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type ); |
| 391 | 391 | |
| 392 | - return $location_array; |
|
| 392 | + return $location_array; |
|
| 393 | 393 | |
| 394 | 394 | } |
| 395 | 395 | |
@@ -402,24 +402,24 @@ discard block |
||
| 402 | 402 | * @return bool|string |
| 403 | 403 | */ |
| 404 | 404 | function geodir_get_location_link($which_location = 'current') {
|
| 405 | - $location_link = get_permalink(geodir_location_page_id()); |
|
| 406 | - |
|
| 407 | - if ($which_location == 'base') {
|
|
| 408 | - return $location_link; |
|
| 409 | - } else {
|
|
| 410 | - $location_terms = geodir_get_current_location_terms(); |
|
| 411 | - |
|
| 412 | - if (!empty($location_terms)) {
|
|
| 413 | - if (get_option('permalink_structure') != '') {
|
|
| 414 | - $location_terms = implode("/", $location_terms);
|
|
| 415 | - $location_terms = rtrim($location_terms, '/'); |
|
| 416 | - $location_link .= $location_terms; |
|
| 417 | - } else {
|
|
| 418 | - $location_link = geodir_getlink($location_link, $location_terms); |
|
| 419 | - } |
|
| 420 | - } |
|
| 421 | - } |
|
| 422 | - return $location_link; |
|
| 405 | + $location_link = get_permalink(geodir_location_page_id()); |
|
| 406 | + |
|
| 407 | + if ($which_location == 'base') {
|
|
| 408 | + return $location_link; |
|
| 409 | + } else {
|
|
| 410 | + $location_terms = geodir_get_current_location_terms(); |
|
| 411 | + |
|
| 412 | + if (!empty($location_terms)) {
|
|
| 413 | + if (get_option('permalink_structure') != '') {
|
|
| 414 | + $location_terms = implode("/", $location_terms);
|
|
| 415 | + $location_terms = rtrim($location_terms, '/'); |
|
| 416 | + $location_link .= $location_terms; |
|
| 417 | + } else {
|
|
| 418 | + $location_link = geodir_getlink($location_link, $location_terms); |
|
| 419 | + } |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | + return $location_link; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | /** |
@@ -432,34 +432,34 @@ discard block |
||
| 432 | 432 | * @return array|bool Returns address on success. |
| 433 | 433 | */ |
| 434 | 434 | function geodir_get_osm_address_by_lat_lan($lat, $lng) {
|
| 435 | - $url = is_ssl() ? 'https:' : 'http:'; |
|
| 436 | - $url .= '//nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email');
|
|
| 437 | - |
|
| 438 | - $ch = curl_init(); |
|
| 439 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
| 440 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 441 | - curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
| 442 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
| 443 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
| 444 | - $response = curl_exec($ch); |
|
| 445 | - curl_close($ch); |
|
| 446 | - $data = json_decode($response); |
|
| 435 | + $url = is_ssl() ? 'https:' : 'http:'; |
|
| 436 | + $url .= '//nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email');
|
|
| 437 | + |
|
| 438 | + $ch = curl_init(); |
|
| 439 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 440 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 441 | + curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
| 442 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
| 443 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
| 444 | + $response = curl_exec($ch); |
|
| 445 | + curl_close($ch); |
|
| 446 | + $data = json_decode($response); |
|
| 447 | 447 | |
| 448 | - if (!empty($data) && !empty($data->address)) {
|
|
| 449 | - $address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb');
|
|
| 450 | - $formatted_address = (array)$data->address; |
|
| 448 | + if (!empty($data) && !empty($data->address)) {
|
|
| 449 | + $address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb');
|
|
| 450 | + $formatted_address = (array)$data->address; |
|
| 451 | 451 | |
| 452 | - foreach ( $data->address as $key => $value ) {
|
|
| 453 | - if (!in_array($key, $address_fields)) {
|
|
| 454 | - unset($formatted_address[$key]); |
|
| 455 | - } |
|
| 456 | - } |
|
| 457 | - $data->formatted_address = !empty($formatted_address) ? implode(', ', $formatted_address) : '';
|
|
| 452 | + foreach ( $data->address as $key => $value ) {
|
|
| 453 | + if (!in_array($key, $address_fields)) {
|
|
| 454 | + unset($formatted_address[$key]); |
|
| 455 | + } |
|
| 456 | + } |
|
| 457 | + $data->formatted_address = !empty($formatted_address) ? implode(', ', $formatted_address) : '';
|
|
| 458 | 458 | |
| 459 | - return $data; |
|
| 460 | - } else {
|
|
| 461 | - return false; |
|
| 462 | - } |
|
| 459 | + return $data; |
|
| 460 | + } else {
|
|
| 461 | + return false; |
|
| 462 | + } |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | /** |
@@ -471,47 +471,47 @@ discard block |
||
| 471 | 471 | * @return string Returns the country. |
| 472 | 472 | */ |
| 473 | 473 | function geodir_get_normal_country($country) {
|
| 474 | - global $wpdb; |
|
| 475 | - if ($result = geodir_get_country_by_name($country)) {
|
|
| 476 | - return $result; |
|
| 477 | - } |
|
| 474 | + global $wpdb; |
|
| 475 | + if ($result = geodir_get_country_by_name($country)) {
|
|
| 476 | + return $result; |
|
| 477 | + } |
|
| 478 | 478 | |
| 479 | - if (defined('POST_LOCATION_TABLE')) {
|
|
| 480 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
|
|
| 481 | - if (!empty($rows)) {
|
|
| 482 | - foreach ($rows as $row) {
|
|
| 483 | - $translated = __($row->country, 'geodirectory'); |
|
| 484 | - if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) {
|
|
| 485 | - return $result; |
|
| 486 | - } |
|
| 487 | - } |
|
| 488 | - } |
|
| 479 | + if (defined('POST_LOCATION_TABLE')) {
|
|
| 480 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
|
|
| 481 | + if (!empty($rows)) {
|
|
| 482 | + foreach ($rows as $row) {
|
|
| 483 | + $translated = __($row->country, 'geodirectory'); |
|
| 484 | + if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) {
|
|
| 485 | + return $result; |
|
| 486 | + } |
|
| 487 | + } |
|
| 488 | + } |
|
| 489 | 489 | |
| 490 | - $rows = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country ) ); |
|
| 491 | - if (!empty($rows)) {
|
|
| 492 | - foreach ($rows as $row) {
|
|
| 493 | - $translated = __($row->country, 'geodirectory'); |
|
| 494 | - if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) {
|
|
| 495 | - return $result; |
|
| 496 | - } |
|
| 497 | - } |
|
| 498 | - } |
|
| 499 | - } |
|
| 490 | + $rows = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country ) ); |
|
| 491 | + if (!empty($rows)) {
|
|
| 492 | + foreach ($rows as $row) {
|
|
| 493 | + $translated = __($row->country, 'geodirectory'); |
|
| 494 | + if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) {
|
|
| 495 | + return $result; |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | + } |
|
| 499 | + } |
|
| 500 | 500 | |
| 501 | - $default_location = geodir_get_default_location(); |
|
| 502 | - if (!empty($default_location->country) && $result = geodir_get_country_by_name($default_location->country)) {
|
|
| 503 | - return $result; |
|
| 504 | - } |
|
| 501 | + $default_location = geodir_get_default_location(); |
|
| 502 | + if (!empty($default_location->country) && $result = geodir_get_country_by_name($default_location->country)) {
|
|
| 503 | + return $result; |
|
| 504 | + } |
|
| 505 | 505 | |
| 506 | - if (!empty($default_location->country_slug) && $result = geodir_get_country_by_name($default_location->country_slug)) {
|
|
| 507 | - return $result; |
|
| 508 | - } |
|
| 506 | + if (!empty($default_location->country_slug) && $result = geodir_get_country_by_name($default_location->country_slug)) {
|
|
| 507 | + return $result; |
|
| 508 | + } |
|
| 509 | 509 | |
| 510 | - if (!empty($default_location->country_ISO2) && $result = geodir_get_country_by_name($default_location->country_ISO2, true)) {
|
|
| 511 | - return $result; |
|
| 512 | - } |
|
| 510 | + if (!empty($default_location->country_ISO2) && $result = geodir_get_country_by_name($default_location->country_ISO2, true)) {
|
|
| 511 | + return $result; |
|
| 512 | + } |
|
| 513 | 513 | |
| 514 | - return $country; |
|
| 514 | + return $country; |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | /** |
@@ -523,16 +523,16 @@ discard block |
||
| 523 | 523 | * @return string Country ISO2 code. |
| 524 | 524 | */ |
| 525 | 525 | function geodir_get_country_iso2($country) {
|
| 526 | - global $wpdb; |
|
| 526 | + global $wpdb; |
|
| 527 | 527 | |
| 528 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
|
|
| 529 | - return $result; |
|
| 530 | - } |
|
| 531 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", geodir_get_normal_country($country)))) {
|
|
| 532 | - return $result; |
|
| 533 | - } |
|
| 528 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
|
|
| 529 | + return $result; |
|
| 530 | + } |
|
| 531 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", geodir_get_normal_country($country)))) {
|
|
| 532 | + return $result; |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | - return $country; |
|
| 535 | + return $country; |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
@@ -545,14 +545,14 @@ discard block |
||
| 545 | 545 | * @return string|null Country ISO2 code. |
| 546 | 546 | */ |
| 547 | 547 | function geodir_get_country_by_name($country, $iso2 = false) {
|
| 548 | - global $wpdb; |
|
| 548 | + global $wpdb; |
|
| 549 | 549 | |
| 550 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
|
|
| 551 | - return $result; |
|
| 552 | - } |
|
| 553 | - if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE ISO2 LIKE %s", $country))) {
|
|
| 554 | - return $result; |
|
| 555 | - } |
|
| 550 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
|
|
| 551 | + return $result; |
|
| 552 | + } |
|
| 553 | + if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE ISO2 LIKE %s", $country))) {
|
|
| 554 | + return $result; |
|
| 555 | + } |
|
| 556 | 556 | |
| 557 | - return NULL; |
|
| 557 | + return NULL; |
|
| 558 | 558 | } |
| 559 | 559 | \ No newline at end of file |