|
@@ -124,7 +124,7 @@ discard block |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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,
|
|
@@ -294,7 +294,7 @@ discard block |
|
|
block discarded – undo |
|
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) ;
|
|
|
297
|
+ $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($lat).','.trim($lng);
|
|
298
|
298
|
|
|
299
|
299
|
$ch = curl_init();
|
|
300
|
300
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
@@ -388,7 +388,7 @@ discard block |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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
|
|
|
@@ -595,7 +595,7 @@ discard block |
|
|
block discarded – undo |
|
595
|
595
|
add_filter('geodir_replace_location_variables', 'geodir_replace_location_variables');
|
|
596
|
596
|
|
|
597
|
597
|
|
|
598
|
|
-function geodir_location_replace_vars($location_array = array(), $sep = NULL, $gd_page = ''){
|
|
|
598
|
+function geodir_location_replace_vars($location_array = array(), $sep = NULL, $gd_page = '') {
|
|
599
|
599
|
|
|
600
|
600
|
global $wp;
|
|
601
|
601
|
|
|
@@ -620,8 +620,8 @@ discard block |
|
|
block discarded – undo |
|
620
|
620
|
$location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
|
|
621
|
621
|
$location_name = get_actual_location_name($location_type, $location, true);
|
|
622
|
622
|
} else {
|
|
623
|
|
- $location_name = preg_replace( '/-(\d+)$/', '', $location_name);
|
|
624
|
|
- $location_name = preg_replace( '/[_-]/', ' ', $location_name );
|
|
|
623
|
+ $location_name = preg_replace('/-(\d+)$/', '', $location_name);
|
|
|
624
|
+ $location_name = preg_replace('/[_-]/', ' ', $location_name);
|
|
625
|
625
|
$location_name = __(geodir_ucwords($location_name), 'geodirectory');
|
|
626
|
626
|
}
|
|
627
|
627
|
}
|
|
@@ -639,8 +639,8 @@ discard block |
|
|
block discarded – undo |
|
639
|
639
|
$location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
|
|
640
|
640
|
$location_single = get_actual_location_name($location_type, $location, true);
|
|
641
|
641
|
} else {
|
|
642
|
|
- $location_name = preg_replace( '/-(\d+)$/', '', $location);
|
|
643
|
|
- $location_name = preg_replace( '/[_-]/', ' ', $location_name );
|
|
|
642
|
+ $location_name = preg_replace('/-(\d+)$/', '', $location);
|
|
|
643
|
+ $location_name = preg_replace('/[_-]/', ' ', $location_name);
|
|
644
|
644
|
$location_single = __(geodir_ucwords($location_name), 'geodirectory');
|
|
645
|
645
|
}
|
|
646
|
646
|
}
|
|
@@ -660,8 +660,8 @@ discard block |
|
|
block discarded – undo |
|
660
|
660
|
$location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
|
|
661
|
661
|
$location_name = get_actual_location_name($location_type, $location, true);
|
|
662
|
662
|
} else {
|
|
663
|
|
- $location_name = preg_replace( '/-(\d+)$/', '', $location);
|
|
664
|
|
- $location_name = preg_replace( '/[_-]/', ' ', $location_name );
|
|
|
663
|
+ $location_name = preg_replace('/-(\d+)$/', '', $location);
|
|
|
664
|
+ $location_name = preg_replace('/[_-]/', ' ', $location_name);
|
|
665
|
665
|
$location_name = __(geodir_ucwords($location_name), 'geodirectory');
|
|
666
|
666
|
}
|
|
667
|
667
|
}
|
|
@@ -673,20 +673,20 @@ discard block |
|
|
block discarded – undo |
|
673
|
673
|
$full_location = array_unique($full_location);
|
|
674
|
674
|
}
|
|
675
|
675
|
}
|
|
676
|
|
- $full_location = !empty($full_location) ? implode(', ', $full_location): '';
|
|
|
676
|
+ $full_location = !empty($full_location) ? implode(', ', $full_location) : '';
|
|
677
|
677
|
|
|
678
|
678
|
$location_replace_vars = array();
|
|
679
|
679
|
$location_replace_vars['%%location_sep%%'] = $sep !== NULL ? $sep : '|';
|
|
680
|
680
|
$location_replace_vars['%%location%%'] = $full_location;
|
|
681
|
|
- $location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $full_location ) : '';
|
|
|
681
|
+ $location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf(_x('in %s', 'in location', 'geodirectory'), $full_location) : '';
|
|
682
|
682
|
$location_replace_vars['%%location_single%%'] = $location_single;
|
|
683
|
|
- $location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $location_single ) : '';
|
|
|
683
|
+ $location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf(_x('in %s', 'in location', 'geodirectory'), $location_single) : '';
|
|
684
|
684
|
|
|
685
|
685
|
foreach ($location_names as $type => $name) {
|
|
686
|
686
|
$location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
|
|
687
|
687
|
|
|
688
|
|
- $location_replace_vars['%%location_' . $location_type . '%%'] = $name;
|
|
689
|
|
- $location_replace_vars['%%in_location_' . $location_type . '%%'] = !empty($name) ? sprintf( _x('in %s','in location', 'geodirectory'), $name ) : '';
|
|
|
688
|
+ $location_replace_vars['%%location_'.$location_type.'%%'] = $name;
|
|
|
689
|
+ $location_replace_vars['%%in_location_'.$location_type.'%%'] = !empty($name) ? sprintf(_x('in %s', 'in location', 'geodirectory'), $name) : '';
|
|
690
|
690
|
}
|
|
691
|
691
|
|
|
692
|
692
|
/**
|
|
@@ -700,5 +700,5 @@ discard block |
|
|
block discarded – undo |
|
700
|
700
|
* @param string $gd_page The page being filtered.
|
|
701
|
701
|
* @param string $sep The separator.
|
|
702
|
702
|
*/
|
|
703
|
|
- return apply_filters( 'geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep );
|
|
|
703
|
+ return apply_filters('geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep);
|
|
704
|
704
|
} |
|
705
|
705
|
\ No newline at end of file |