Test Failed
Push — master ( a0f007...5e22d4 )
by Stiofan
15:04
created
geodirectory-functions/location_functions.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -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,18 +294,18 @@  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);// . "&key=" . geodir_get_map_api_key(); // if we add a key here it will not work if limited to a domain as this is done via curl.
297
+    $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($lat).','.trim($lng); // . "&key=" . geodir_get_map_api_key(); // if we add a key here it will not work if limited to a domain as this is done via curl.
298 298
 
299 299
     $response = wp_remote_get($url);
300
-    if ( is_wp_error( $response ) ) {
300
+    if (is_wp_error($response)) {
301 301
         return false;
302 302
     }
303 303
 
304
-    $result = json_decode( wp_remote_retrieve_body( $response ) );
304
+    $result = json_decode(wp_remote_retrieve_body($response));
305 305
 
306
-    if(isset($result->results[0]->address_components)){
306
+    if (isset($result->results[0]->address_components)) {
307 307
         return $result->results[0]->address_components;
308
-    }else{
308
+    } else {
309 309
         return false;
310 310
     }
311 311
 }
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
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
-	$location_array = apply_filters( 'geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type );
389
+	$location_array = apply_filters('geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type);
390 390
 
391 391
     return $location_array;
392 392
 
@@ -431,20 +431,20 @@  discard block
 block discarded – undo
431 431
  * @return array|bool Returns address on success.
432 432
  */
433 433
 function geodir_get_osm_address_by_lat_lan($lat, $lng) {
434
-    $url = 'https://nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email');
434
+    $url = 'https://nominatim.openstreetmap.org/reverse?format=json&lat='.trim($lat).'&lon='.trim($lng).'&zoom=16&addressdetails=1&email='.get_option('admin_email');
435 435
 
436 436
     $response = wp_remote_get($url);
437
-    if ( is_wp_error( $response ) ) {
437
+    if (is_wp_error($response)) {
438 438
         return false;
439 439
     }
440 440
 
441
-    $result = json_decode( wp_remote_retrieve_body( $response ) );
441
+    $result = json_decode(wp_remote_retrieve_body($response));
442 442
 
443
-    if(!empty($result->address)){
443
+    if (!empty($result->address)) {
444 444
         $address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb');
445
-        $formatted_address = (array)$result->address;
445
+        $formatted_address = (array) $result->address;
446 446
 
447
-        foreach ( $result->address as $key => $value ) {
447
+        foreach ($result->address as $key => $value) {
448 448
             if (!in_array($key, $address_fields)) {
449 449
                 unset($formatted_address[$key]);
450 450
             }
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
         $result->formatted_address = !empty($formatted_address) ? implode(', ', $formatted_address) : '';
453 453
 
454 454
         return $result;
455
-    }else{
455
+    } else {
456 456
         return false;
457 457
     }
458 458
 }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
     }
475 475
     
476 476
     if (defined('POST_LOCATION_TABLE')) {
477
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
477
+        $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM ".POST_LOCATION_TABLE." WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
478 478
         if (!empty($rows)) {
479 479
             foreach ($rows as $row) {
480 480
                 $translated = __($row->country, 'geodirectory');
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
             }
485 485
         }
486 486
         
487
-        $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 ) );
487
+        $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));
488 488
         if (!empty($rows)) {
489 489
             foreach ($rows as $row) {
490 490
                 $translated = __($row->country, 'geodirectory');
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
         }
496 496
     }
497 497
     
498
-    if ( $default === '0' ) {
498
+    if ($default === '0') {
499 499
         return NULL;
500 500
     }
501 501
     
@@ -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,9 +673,9 @@  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
-    if ( empty( $full_location ) ) {
678
+    if (empty($full_location)) {
679 679
         /**
680 680
          * Filter the text in meta description in full location is empty.
681 681
          *
@@ -686,10 +686,10 @@  discard block
 block discarded – undo
686 686
          * @param string $gd_page       The page being filtered.
687 687
          * @param string $sep           The separator.
688 688
          */
689
-         $full_location = apply_filters( 'geodir_meta_description_location_empty_text', '', $location_array, $gd_page, $sep );
689
+         $full_location = apply_filters('geodir_meta_description_location_empty_text', '', $location_array, $gd_page, $sep);
690 690
     }
691 691
     
692
-    if ( empty( $location_single ) ) {
692
+    if (empty($location_single)) {
693 693
         /**
694 694
          * Filter the text in meta description in single location is empty.
695 695
          *
@@ -700,21 +700,21 @@  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
-         $location_single = apply_filters( 'geodir_meta_description_single_location_empty_text', '', $location_array, $gd_page, $sep );
703
+         $location_single = apply_filters('geodir_meta_description_single_location_empty_text', '', $location_array, $gd_page, $sep);
704 704
     }
705 705
 
706 706
     $location_replace_vars = array();
707 707
     $location_replace_vars['%%location_sep%%'] = $sep !== NULL ? $sep : '|';
708 708
     $location_replace_vars['%%location%%'] = $full_location;
709
-    $location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $full_location ) : '';
709
+    $location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf(_x('in %s', 'in location', 'geodirectory'), $full_location) : '';
710 710
     $location_replace_vars['%%location_single%%'] = $location_single;
711
-    $location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $location_single ) : '';
711
+    $location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf(_x('in %s', 'in location', 'geodirectory'), $location_single) : '';
712 712
 
713 713
     foreach ($location_names as $type => $name) {
714 714
         $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
715 715
 
716
-        $location_replace_vars['%%location_' . $location_type . '%%'] = $name;
717
-        $location_replace_vars['%%in_location_' . $location_type . '%%'] = !empty($name) ? sprintf( _x('in %s','in location', 'geodirectory'), $name ) : '';
716
+        $location_replace_vars['%%location_'.$location_type.'%%'] = $name;
717
+        $location_replace_vars['%%in_location_'.$location_type.'%%'] = !empty($name) ? sprintf(_x('in %s', 'in location', 'geodirectory'), $name) : '';
718 718
     }
719 719
 
720 720
     /**
@@ -728,5 +728,5 @@  discard block
 block discarded – undo
728 728
      * @param string $gd_page       The page being filtered.
729 729
      * @param string $sep           The separator.
730 730
      */
731
-    return apply_filters( 'geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep );
731
+    return apply_filters('geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep);
732 732
 }
733 733
\ No newline at end of file
Please login to merge, or discard this patch.