Test Failed
Push — master ( 9f04c3...c51f70 )
by Stiofan
01:08
created
geodirectory-functions/listing_filters.php 1 patch
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
  * @global string $s_A Extra parameters.
66 66
  * @global string $s_SA Extra parameters.
67 67
  */
68
-function set_listing_request($query )
68
+function set_listing_request($query)
69 69
 {
70 70
     global $wp_query, $wpdb, $geodir_post_type, $table, $dist, $mylat, $mylon, $s, $snear, $s, $s_A, $s_SA;
71 71
 
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
         } //  Distance
100 100
 
101 101
         if (isset($_REQUEST['sgeo_lat'])) {
102
-            $mylat = (float)esc_attr($_REQUEST['sgeo_lat']);
102
+            $mylat = (float) esc_attr($_REQUEST['sgeo_lat']);
103 103
         } else {
104
-            $mylat = (float)geodir_get_current_city_lat();
104
+            $mylat = (float) geodir_get_current_city_lat();
105 105
         } //  Latitude
106 106
 
107 107
         if (isset($_REQUEST['sgeo_lon'])) {
108
-            $mylon = (float)esc_attr($_REQUEST['sgeo_lon']);
108
+            $mylon = (float) esc_attr($_REQUEST['sgeo_lon']);
109 109
         } else {
110
-            $mylon = (float)geodir_get_current_city_lng();
110
+            $mylon = (float) geodir_get_current_city_lng();
111 111
         } //  Distance
112 112
 
113 113
         if (isset($_REQUEST['snear'])) {
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
         if ($snear == 'NEAR ME') {
122 122
             $ip = $_SERVER['REMOTE_ADDR'];
123
-            $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
123
+            $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip));
124 124
             $mylat = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_latitude]));
125 125
             $mylon = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_longitude]));
126 126
         }
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
             $s_AA = str_replace(" ", "", $s);
131 131
             $s_A = explode(",", $s_AA);
132 132
             $s_A = implode('","', $s_A);
133
-            $s_A = '"' . $s_A . '"';
133
+            $s_A = '"'.$s_A.'"';
134 134
         } else {
135
-            $s_A = '"' . $s . '"';
135
+            $s_A = '"'.$s.'"';
136 136
         }
137 137
 
138 138
         if (strstr($s, ' ')) {
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     }
194 194
     if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
195 195
 
196
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
196
+        $table = $plugin_prefix.$geodir_post_type.'_detail';
197 197
 
198 198
         add_filter('posts_fields', 'geodir_posts_fields', 1);
199 199
         add_filter('posts_join', 'geodir_posts_join', 1);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     global $wp_query, $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $snear, $gd_session;
234 234
 
235 235
     // Filter-Location-Manager to add location table.
236
-    $fields .= ", " . $table . ".* ";
236
+    $fields .= ", ".$table.".* ";
237 237
 
238 238
 	if ($snear != '' || $gd_session->get('all_near_me')) {
239 239
         $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
@@ -243,16 +243,16 @@  discard block
 block discarded – undo
243 243
             $mylon = $gd_session->get('user_lon');
244 244
         }
245 245
 
246
-        $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
246
+        $fields .= " , (".$DistanceRadius." * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(".$table.".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(".$table.".post_latitude) * pi()/180) *POWER(SIN(($mylon - ".$table.".post_longitude) * pi()/180 / 2), 2) )))as distance ";
247 247
     }
248 248
 
249 249
     global $s;
250 250
     if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
251 251
         $keywords = explode(" ", $s);
252 252
 
253
-        if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
254
-            foreach($keywords as $kkey=>$kword){
255
-                if(geodir_utf8_strlen($kword)<=$klimit){
253
+        if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
254
+            foreach ($keywords as $kkey=>$kword) {
255
+                if (geodir_utf8_strlen($kword) <= $klimit) {
256 256
                     unset($keywords[$kkey]);
257 257
                 }
258 258
             }
@@ -270,24 +270,24 @@  discard block
 block discarded – undo
270 270
                 $count = 0;
271 271
                 foreach ($keywords as $keyword) {
272 272
                     $keyword = trim($keyword);
273
-                    $keyword  = wp_specialchars_decode($keyword ,ENT_QUOTES);
273
+                    $keyword = wp_specialchars_decode($keyword, ENT_QUOTES);
274 274
 					$count++;
275 275
                     if ($count < count($keywords)) {
276 276
                        // $gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' " . $key . " ";
277
-						$gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) " . $key . " ";
277
+						$gd_titlematch_part .= "( ".$wpdb->posts.".post_title LIKE '".$keyword."' OR ".$wpdb->posts.".post_title LIKE '".$keyword."%%' OR ".$wpdb->posts.".post_title LIKE '%% ".$keyword."%%' ) ".$key." ";
278 278
                     } else {
279 279
                         //$gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' ";
280
-						$gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) ";
280
+						$gd_titlematch_part .= "( ".$wpdb->posts.".post_title LIKE '".$keyword."' OR ".$wpdb->posts.".post_title LIKE '".$keyword."%%' OR ".$wpdb->posts.".post_title LIKE '%% ".$keyword."%%' ) ";
281 281
                     }
282 282
                 }
283
-                $gd_titlematch_part .= "THEN 1 ELSE 0 END AS " . $part . ",";
283
+                $gd_titlematch_part .= "THEN 1 ELSE 0 END AS ".$part.",";
284 284
             }
285 285
         } else {
286 286
             $gd_titlematch_part = "";
287 287
         }
288
-        $s = stripslashes_deep( $s );
289
-        $s = wp_specialchars_decode($s,ENT_QUOTES);
290
-		$fields .= $wpdb->prepare(", CASE WHEN " . $table . ".is_featured='1' THEN 1 ELSE 0 END AS gd_featured, CASE WHEN " . $wpdb->posts . ".post_title LIKE %s THEN 1 ELSE 0 END AS gd_exacttitle," . $gd_titlematch_part . " CASE WHEN ( " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s ) THEN 1 ELSE 0 END AS gd_titlematch, CASE WHEN ( " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s ) THEN 1 ELSE 0 END AS gd_content", array($s, $s, $s . '%', '% ' . $s . '%', $s, $s . ' %', '% ' . $s . ' %', '% ' . $s,'%>' . $s . '%','% ' . $s . ','));
288
+        $s = stripslashes_deep($s);
289
+        $s = wp_specialchars_decode($s, ENT_QUOTES);
290
+		$fields .= $wpdb->prepare(", CASE WHEN ".$table.".is_featured='1' THEN 1 ELSE 0 END AS gd_featured, CASE WHEN ".$wpdb->posts.".post_title LIKE %s THEN 1 ELSE 0 END AS gd_exacttitle,".$gd_titlematch_part." CASE WHEN ( ".$wpdb->posts.".post_title LIKE %s OR ".$wpdb->posts.".post_title LIKE %s OR ".$wpdb->posts.".post_title LIKE %s ) THEN 1 ELSE 0 END AS gd_titlematch, CASE WHEN ( ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s ) THEN 1 ELSE 0 END AS gd_content", array($s, $s, $s.'%', '% '.$s.'%', $s, $s.' %', '% '.$s.' %', '% '.$s, '%>'.$s.'%', '% '.$s.','));
291 291
     }
292 292
 
293 293
     return $fields;
@@ -311,18 +311,18 @@  discard block
 block discarded – undo
311 311
 
312 312
     ########### WPML ###########
313 313
 
314
-    if ( geodir_wpml_is_post_type_translated( $geodir_post_type ) ) {
314
+    if (geodir_wpml_is_post_type_translated($geodir_post_type)) {
315 315
         global $sitepress;
316 316
         $lang_code = ICL_LANGUAGE_CODE;
317 317
         $default_lang_code = $sitepress->get_default_language();
318 318
         if ($lang_code) {
319
-            $join .= "JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
319
+            $join .= "JOIN ".$table_prefix."icl_translations icl_t ON icl_t.element_id = ".$table_prefix."posts.ID";
320 320
         }
321 321
 
322 322
     }
323 323
     ########### WPML ###########
324 324
 
325
-    $join .= " INNER JOIN " . $table . " ON (" . $table . ".post_id = $wpdb->posts.ID)  ";
325
+    $join .= " INNER JOIN ".$table." ON (".$table.".post_id = $wpdb->posts.ID)  ";
326 326
     //===old code start
327 327
     //$join .= " INNER JOIN ".POST_LOCATION_TABLE." ON (".$table.".post_location_id = ".POST_LOCATION_TABLE.".location_id)  " ;//===old code end
328 328
 
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
             $sort_by = 'az';
392 392
         }
393 393
 
394
-        if ($snear != '' &&  $sort_by!='farthest') {
394
+        if ($snear != '' && $sort_by != 'farthest') {
395 395
             $sort_by = 'nearest';
396 396
         }
397 397
     }
@@ -405,20 +405,20 @@  discard block
 block discarded – undo
405 405
             break;
406 406
         case 'low_review':
407 407
         case 'rating_count_asc':
408
-            $orderby = $table . ".rating_count ASC, " . $table . ".overall_rating ASC, ";
408
+            $orderby = $table.".rating_count ASC, ".$table.".overall_rating ASC, ";
409 409
             break;
410 410
         case 'high_review':
411 411
         case 'rating_count_desc':
412
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
412
+            $orderby = $table.".rating_count DESC, ".$table.".overall_rating DESC, ";
413 413
             break;
414 414
         case 'low_rating':
415
-            $orderby = "( " . $table . ".overall_rating  ) ASC, " . $table . ".rating_count ASC,  ";
415
+            $orderby = "( ".$table.".overall_rating  ) ASC, ".$table.".rating_count ASC,  ";
416 416
             break;
417 417
         case 'high_rating':
418
-            $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
418
+            $orderby = " ".$table.".overall_rating DESC, ".$table.".rating_count DESC, ";
419 419
             break;
420 420
         case 'featured':
421
-            $orderby = $table . ".is_featured asc, ";
421
+            $orderby = $table.".is_featured asc, ";
422 422
             break;
423 423
         case 'nearest':
424 424
             $orderby = " distance asc, ";
@@ -434,10 +434,10 @@  discard block
 block discarded – undo
434 434
             break;
435 435
         // sort by rating
436 436
         case 'overall_rating_desc':
437
-            $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
437
+            $orderby = " ".$table.".overall_rating DESC, ".$table.".rating_count DESC, ";
438 438
             break;
439 439
         case 'overall_rating_asc':
440
-            $orderby = " " . $table . ".overall_rating ASC, " . $table . ".rating_count ASC, ";
440
+            $orderby = " ".$table.".overall_rating ASC, ".$table.".rating_count ASC, ";
441 441
             break;
442 442
         default:
443 443
 
@@ -458,24 +458,24 @@  discard block
 block discarded – undo
458 458
 
459 459
     if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
460 460
         $keywords = explode(" ", $s);
461
-        if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
462
-            foreach($keywords as $kkey=>$kword){
463
-                if(geodir_utf8_strlen($kword)<=$klimit){
461
+        if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
462
+            foreach ($keywords as $kkey=>$kword) {
463
+                if (geodir_utf8_strlen($kword) <= $klimit) {
464 464
                     unset($keywords[$kkey]);
465 465
                 }
466 466
             }
467 467
         }
468 468
         if ($sort_by == 'nearest' || $sort_by == 'farthest') {
469 469
             if (count($keywords) > 1) {
470
-                $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ";
470
+                $orderby = $orderby." ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ";
471 471
             } else {
472
-                $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ";
472
+                $orderby = $orderby." ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ";
473 473
             }
474 474
         } else {
475 475
             if (count($keywords) > 1) {
476
-                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, " . $orderby;
476
+                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ".$orderby;
477 477
             } else {
478
-                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, " . $orderby;
478
+                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ".$orderby;
479 479
             }
480 480
         }
481 481
     }
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
      */
491 491
     $orderby = apply_filters('geodir_posts_order_by_sort', $orderby, $sort_by, $table);
492 492
 
493
-    $orderby .= $table . ".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title ";
493
+    $orderby .= $table.".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title ";
494 494
 
495 495
     return $orderby;
496 496
 }
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 
513 513
     global $wpdb;
514 514
 
515
-    if ($sort_by != '' && (!is_search() || ( isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear']=='' && ( $_REQUEST['s']=='' ||  $_REQUEST['s']==' ') ) )) {
515
+    if ($sort_by != '' && (!is_search() || (isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear'] == '' && ($_REQUEST['s'] == '' || $_REQUEST['s'] == ' ')))) {
516 516
 
517 517
         $sort_array = explode('_', $sort_by);
518 518
 
@@ -522,48 +522,48 @@  discard block
 block discarded – undo
522 522
 
523 523
         if ($sort_by_count > 1 && ($order == 'asc' || $order == 'desc')) {
524 524
 
525
-            $sort_by = str_replace('_' . $order, '', $sort_by);
525
+            $sort_by = str_replace('_'.$order, '', $sort_by);
526 526
 
527 527
             switch ($sort_by):
528 528
 
529 529
                 case 'post_date':
530 530
                 case 'comment_count':
531 531
 
532
-                    $orderby = "$wpdb->posts." . $sort_by . " " . $order . ", ".$table . ".overall_rating " . $order . ", ";
532
+                    $orderby = "$wpdb->posts.".$sort_by." ".$order.", ".$table.".overall_rating ".$order.", ";
533 533
                     break;
534 534
 
535 535
                 case 'distance':
536
-                    $orderby = $sort_by . " " . $order . ", ";
536
+                    $orderby = $sort_by." ".$order.", ";
537 537
                     break;
538 538
 
539 539
 
540 540
                 // sort by rating
541 541
                 case 'overall_rating':
542 542
 
543
-                    $use_bayesian = apply_filters('gd_use_bayesian',true,$table);
543
+                    $use_bayesian = apply_filters('gd_use_bayesian', true, $table);
544 544
                     $avg_rating = 0;
545
-                    if($use_bayesian){
546
-                        $avg_num_votes = get_transient( 'gd_avg_num_votes_'.$table );
547
-                        if(!$avg_num_votes){
545
+                    if ($use_bayesian) {
546
+                        $avg_num_votes = get_transient('gd_avg_num_votes_'.$table);
547
+                        if (!$avg_num_votes) {
548 548
                             $avg_num_votes = $wpdb->get_var("SELECT SUM(rating_count) FROM $table");
549
-                            if($avg_num_votes){
549
+                            if ($avg_num_votes) {
550 550
 
551
-                                $avg_rating = get_transient( 'gd_avg_rating_'.$table );
552
-                                if(!$avg_rating){
553
-                                    $avg_rating = $wpdb->get_var("SELECT SUM(overall_rating) FROM $table")/$avg_num_votes;
551
+                                $avg_rating = get_transient('gd_avg_rating_'.$table);
552
+                                if (!$avg_rating) {
553
+                                    $avg_rating = $wpdb->get_var("SELECT SUM(overall_rating) FROM $table") / $avg_num_votes;
554 554
                                 }
555
-                                set_transient( 'gd_avg_num_votes_'.$table, $avg_num_votes, 12 * HOUR_IN_SECONDS );
556
-                                set_transient( 'gd_avg_rating_'.$table, $avg_rating , 12 * HOUR_IN_SECONDS );
555
+                                set_transient('gd_avg_num_votes_'.$table, $avg_num_votes, 12 * HOUR_IN_SECONDS);
556
+                                set_transient('gd_avg_rating_'.$table, $avg_rating, 12 * HOUR_IN_SECONDS);
557 557
                             }
558 558
                         }
559 559
 
560
-                        if(!$avg_num_votes){ $avg_num_votes = 0;}
560
+                        if (!$avg_num_votes) { $avg_num_votes = 0; }
561 561
 
562
-                        $orderby = " (( $avg_num_votes * $avg_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating ))  / ( $avg_num_votes + " . $table . ".rating_count )  $order , ";
562
+                        $orderby = " (( $avg_num_votes * $avg_rating ) + (".$table.".rating_count * ".$table.".overall_rating ))  / ( $avg_num_votes + ".$table.".rating_count )  $order , ";
563 563
 
564 564
                         //$orderby = " ( " . $table . ".rating_count * " . $table . ".overall_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating )   / ( " . $table . ".rating_count + " . $table . ".rating_count )  $order , "; // seems to work mostly with no extra overheads
565
-                    }else{
566
-                        $orderby = " " . $table . "." . $sort_by . "  " . $order . ", " . $table . ".rating_count " . $order . ", ";
565
+                    } else {
566
+                        $orderby = " ".$table.".".$sort_by."  ".$order.", ".$table.".rating_count ".$order.", ";
567 567
                     }
568 568
 
569 569
                     break;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 
572 572
                 default:
573 573
                     if (geodir_column_exist($table, $sort_by)) {
574
-						$orderby = $table . "." . $sort_by . " " . $order . ", ";
574
+						$orderby = $table.".".$sort_by." ".$order.", ";
575 575
 					}
576 576
                     break;
577 577
 
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
                 add_filter('posts_where', 'searching_filter_where', 1);
612 612
 
613 613
             add_filter('posts_orderby', 'geodir_posts_orderby', 1);
614
-			add_filter( 'posts_clauses', 'geodir_posts_having', 99999, 2 );
614
+			add_filter('posts_clauses', 'geodir_posts_having', 99999, 2);
615 615
 
616 616
         } elseif (geodir_is_page('author')) {
617 617
 
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
         }
621 621
 
622 622
         //if (!geodir_is_page('detail'))
623
-            add_filter('posts_where', 'geodir_default_where', 1);/**/
623
+            add_filter('posts_where', 'geodir_default_where', 1); /**/
624 624
 
625 625
         //add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts
626 626
 
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
         $q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : '';
692 692
         //echo '##########'.$q_post_type;
693 693
         if ($lang_code && $q_post_type && geodir_wpml_is_post_type_translated($q_post_type)) {
694
-            $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_" . $q_post_type . "') ";
694
+            $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_".$q_post_type."') ";
695 695
             //$where .= " AND icl_t.language_code = '$lang_code' ";
696 696
         }
697 697
 
@@ -758,8 +758,8 @@  discard block
 block discarded – undo
758 758
 	}
759 759
 
760 760
 	$s = trim($s);
761
-    $s  = wp_specialchars_decode($s ,ENT_QUOTES);
762
-    $s_A = wp_specialchars_decode($s_A ,ENT_QUOTES);
761
+    $s = wp_specialchars_decode($s, ENT_QUOTES);
762
+    $s_A = wp_specialchars_decode($s_A, ENT_QUOTES);
763 763
 
764 764
     $where = '';
765 765
     $better_search_terms = '';
@@ -770,9 +770,9 @@  discard block
 block discarded – undo
770 770
 
771 771
     if ($s != '') {
772 772
         $keywords = explode(" ", $s);
773
-        if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
774
-            foreach($keywords as $kkey=>$kword){
775
-                if(geodir_utf8_strlen($kword)<=$klimit){
773
+        if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
774
+            foreach ($keywords as $kkey=>$kword) {
775
+                if (geodir_utf8_strlen($kword) <= $klimit) {
776 776
                     unset($keywords[$kkey]);
777 777
                 }
778 778
             }
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
         if (!empty($keywords)) {
782 782
             foreach ($keywords as $keyword) {
783 783
                 $keyword = trim($keyword);
784
-                $keyword  = wp_specialchars_decode($keyword ,ENT_QUOTES);
784
+                $keyword = wp_specialchars_decode($keyword, ENT_QUOTES);
785 785
                 if ($keyword != '') {
786 786
                     /**
787 787
                      * Filter the search query keywords SQL.
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
                      * @param array $keywords The array of keywords for the query.
793 793
                      * @param string $keyword The single keyword being searched.
794 794
                      */
795
-					$better_search_terms .= apply_filters("geodir_search_better_search_terms",' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )',$keywords,$keyword);
795
+					$better_search_terms .= apply_filters("geodir_search_better_search_terms", ' OR ( '.$wpdb->posts.'.post_title LIKE "'.$keyword.'" OR '.$wpdb->posts.'.post_title LIKE "'.$keyword.'%" OR '.$wpdb->posts.'.post_title LIKE "% '.$keyword.'%" )', $keywords, $keyword);
796 796
                 }
797 797
             }
798 798
         }
@@ -800,13 +800,13 @@  discard block
 block discarded – undo
800 800
 
801 801
     /* get taxonomy */
802 802
     $taxonomies = geodir_get_taxonomies($post_types, true);
803
-    if($taxonomies) {
803
+    if ($taxonomies) {
804 804
         $taxonomies = implode("','", $taxonomies);
805
-        $taxonomies = "'" . $taxonomies . "'";
806
-    }else{$taxonomies='';}
805
+        $taxonomies = "'".$taxonomies."'";
806
+    } else {$taxonomies = ''; }
807 807
 
808 808
     $content_where = $terms_where = '';
809
-    $terms_sql    = '';
809
+    $terms_sql = '';
810 810
 	if ($s != '') {
811 811
         /**
812 812
          * Filter the search query content where values.
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
          *
817 817
          * @param string $content_where The query values, default: `" OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ") "`.
818 818
          */
819
-        $content_where = apply_filters( "geodir_search_content_where", " OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") " );
819
+        $content_where = apply_filters("geodir_search_content_where", " OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ");
820 820
         /**
821 821
          * Filter the search query term values.
822 822
          *
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
          *
826 826
          * @param string $terms_where The separator, default: `" AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) "`.
827 827
          */
828
-        $terms_where = apply_filters( "geodir_search_terms_where", " AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) " );
828
+        $terms_where = apply_filters("geodir_search_terms_where", " AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) ");
829 829
 
830 830
 
831 831
         // get term sql
@@ -837,20 +837,20 @@  discard block
 block discarded – undo
837 837
                     $terms_where
838 838
                     GROUP BY $wpdb->term_taxonomy.term_id";
839 839
 
840
-        $term_results = $wpdb->get_results( $term_sql );
840
+        $term_results = $wpdb->get_results($term_sql);
841 841
         $term_ids     = array();
842 842
         $terms_sql    = '';
843 843
 
844
-        if ( ! empty( $term_results ) ) {
845
-            foreach ( $term_results as $term_id ) {
844
+        if (!empty($term_results)) {
845
+            foreach ($term_results as $term_id) {
846 846
                 $term_ids[] = $term_id;
847 847
             }
848
-            if ( ! empty( $term_ids ) ) {
849
-                foreach ( $term_ids as $term ) {
850
-                    if ( $term->taxonomy == $post_types . '_tags' ) {
851
-                        $terms_sql .= $wpdb->prepare( " OR FIND_IN_SET(%s , " . $table . ".post_tags) ", $term->name );
848
+            if (!empty($term_ids)) {
849
+                foreach ($term_ids as $term) {
850
+                    if ($term->taxonomy == $post_types.'_tags') {
851
+                        $terms_sql .= $wpdb->prepare(" OR FIND_IN_SET(%s , ".$table.".post_tags) ", $term->name);
852 852
                     } else {
853
-                        $terms_sql .= " OR FIND_IN_SET($term->term_id , " . $table . "." . $post_types . "category) ";
853
+                        $terms_sql .= " OR FIND_IN_SET($term->term_id , ".$table.".".$post_types."category) ";
854 854
                     }
855 855
                 }
856 856
             }
@@ -882,12 +882,12 @@  discard block
 block discarded – undo
882 882
 							)
883 883
 						AND $wpdb->posts.post_type in ('{$post_types}')
884 884
 						AND ($wpdb->posts.post_status = 'publish')
885
-						AND ( " . $table . ".post_latitude between $rlat1 and $rlat2 )
886
-						AND ( " . $table . ".post_longitude between $rlon1 and $rlon2 ) ";
885
+						AND ( ".$table.".post_latitude between $rlat1 and $rlat2 )
886
+						AND ( ".$table.".post_longitude between $rlon1 and $rlon2 ) ";
887 887
 
888 888
         if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
889 889
             $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
890
-            $where .= " AND CONVERT((" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= " . $dist;
890
+            $where .= " AND CONVERT((".$DistanceRadius." * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(".$table.".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(".$table.".post_latitude) * pi()/180) *POWER(SIN(($mylon - ".$table.".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= ".$dist;
891 891
         }
892 892
 
893 893
     } else {
@@ -904,11 +904,11 @@  discard block
 block discarded – undo
904 904
     }
905 905
 
906 906
 	########### WPML ###########
907
-    if ( geodir_wpml_is_post_type_translated( $post_types ) ) {
907
+    if (geodir_wpml_is_post_type_translated($post_types)) {
908 908
 		$lang_code = ICL_LANGUAGE_CODE;
909 909
 
910 910
 		if ($lang_code && $post_types) {
911
-            $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
911
+            $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_".$post_types."') ";
912 912
         }
913 913
     }
914 914
     ########### WPML ###########
@@ -931,10 +931,10 @@  discard block
 block discarded – undo
931 931
     global $wpdb, $geodir_post_type, $table, $curr;
932 932
 
933 933
     $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
934
-    $user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0;
934
+    $user_id = !empty($curauth->ID) ? (int) $curauth->ID : 0;
935 935
 
936 936
     if (isset($_REQUEST['stype'])) {
937
-        $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
937
+        $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ", $_REQUEST['stype']);
938 938
     } else {
939 939
         $where = " AND $wpdb->posts.post_type IN ('gd_place') ";
940 940
     }
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
         } else
948 948
             $where .= " AND $wpdb->posts.post_author = $user_id";
949 949
 
950
-        if ($user_id == (int)get_current_user_id()) {
950
+        if ($user_id == (int) get_current_user_id()) {
951 951
             $where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
952 952
         } else {
953 953
             $where .= " AND $wpdb->posts.post_status = 'publish' ";
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
     if (geodir_wpml_is_post_type_translated(sanitize_text_field($_REQUEST['stype']))) {
961 961
         $lang_code = ICL_LANGUAGE_CODE;
962 962
         if ($lang_code) {
963
-            $where .= " AND icl_t.language_code='" . $lang_code . "' ";
963
+            $where .= " AND icl_t.language_code='".$lang_code."' ";
964 964
         }
965 965
 
966 966
     }
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 {
984 984
     global $wp_query, $table;
985 985
     if (!empty($wp_query->query['with_pics_only'])) {
986
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
986
+        $join .= " LEFT JOIN ".GEODIR_ATTACHMENT_TABLE." ON ( ".GEODIR_ATTACHMENT_TABLE.".post_id=".$table.".post_id AND ".GEODIR_ATTACHMENT_TABLE.".mime_type LIKE '%image%' )";
987 987
     }
988 988
     return $join;
989 989
 }
@@ -1002,16 +1002,16 @@  discard block
 block discarded – undo
1002 1002
 {
1003 1003
     global $wp_query, $table;
1004 1004
     if (!empty($wp_query->query['show_featured_only'])) {
1005
-        $where .= " AND " . $table . ".is_featured = '1'";
1005
+        $where .= " AND ".$table.".is_featured = '1'";
1006 1006
     }
1007 1007
     if (!empty($wp_query->query['show_special_only'])) {
1008
-        $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
1008
+        $where .= " AND ( ".$table.".geodir_special_offers != '' AND ".$table.".geodir_special_offers IS NOT NULL )";
1009 1009
     }
1010 1010
     if (!empty($wp_query->query['with_pics_only'])) {
1011
-        $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id";
1011
+        $where .= " AND ".GEODIR_ATTACHMENT_TABLE.".ID IS NOT NULL GROUP BY ".$table.".post_id";
1012 1012
     }
1013 1013
     if (!empty($wp_query->query['with_videos_only'])) {
1014
-        $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
1014
+        $where .= " AND ( ".$table.".geodir_video != '' AND ".$table.".geodir_video IS NOT NULL )";
1015 1015
     }
1016 1016
     return $where;
1017 1017
 }
@@ -1020,18 +1020,18 @@  discard block
 block discarded – undo
1020 1020
 function geodir_related_posts_fields($fields) {
1021 1021
     global $wp_query, $wpdb, $table, $post;
1022 1022
 
1023
-    $fields .= ", " . $table . ".* ";
1023
+    $fields .= ", ".$table.".* ";
1024 1024
 
1025 1025
     $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
1026 1026
 
1027 1027
     $mylat = $post->post_latitude;
1028 1028
     $mylon = $post->post_longitude;
1029 1029
 
1030
-    $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
1030
+    $fields .= " , (".$DistanceRadius." * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(".$table.".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(".$table.".post_latitude) * pi()/180) *POWER(SIN(($mylon - ".$table.".post_longitude) * pi()/180 / 2), 2) )))as distance ";
1031 1031
     return $fields;
1032 1032
 }
1033 1033
 function geodir_related_posts_fields_filter($query) {
1034
-    if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']
1034
+    if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']
1035 1035
         && isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest'
1036 1036
         && isset($query->query_vars['related_listings']) && $query->query_vars['related_listings']
1037 1037
     ) {
@@ -1050,25 +1050,25 @@  discard block
 block discarded – undo
1050 1050
  * @param string $table Listing table name.
1051 1051
  * @return string|null If field exists in table returns order by clause else returns empty.
1052 1052
  */
1053
-function geodir_prepare_custom_sorting( $sorting, $table ) {
1053
+function geodir_prepare_custom_sorting($sorting, $table) {
1054 1054
     $orderby = '';
1055 1055
     
1056
-    if ( empty( $sorting ) || empty( $table ) ) {
1056
+    if (empty($sorting) || empty($table)) {
1057 1057
         return $orderby;
1058 1058
     }
1059 1059
     
1060
-    if ( strpos( strtoupper( $sorting ), '_ASC' ) !== false || strpos( strtoupper( $sorting ), '_DESC') !== false ) {
1061
-        $sorting_array = explode( '_', $sorting );
1060
+    if (strpos(strtoupper($sorting), '_ASC') !== false || strpos(strtoupper($sorting), '_DESC') !== false) {
1061
+        $sorting_array = explode('_', $sorting);
1062 1062
         
1063
-        if ( ( $count = count( $sorting_array ) ) > 1 ) {
1064
-            $order = !empty( $sorting_array[$count - 1] ) ? strtoupper( $sorting_array[$count - 1] ) : '';
1065
-            array_pop( $sorting_array );
1063
+        if (($count = count($sorting_array)) > 1) {
1064
+            $order = !empty($sorting_array[$count - 1]) ? strtoupper($sorting_array[$count - 1]) : '';
1065
+            array_pop($sorting_array);
1066 1066
             
1067
-            if ( !empty( $sorting_array ) && ( $order == 'ASC' || $order == 'DESC' ) ) {
1068
-                $sort_by = implode( '_', $sorting_array );
1067
+            if (!empty($sorting_array) && ($order == 'ASC' || $order == 'DESC')) {
1068
+                $sort_by = implode('_', $sorting_array);
1069 1069
                 
1070
-                if ( geodir_column_exist( $table, $sort_by ) ) {
1071
-                    $orderby = $table . "." . $sort_by . " " . $order;
1070
+                if (geodir_column_exist($table, $sort_by)) {
1071
+                    $orderby = $table.".".$sort_by." ".$order;
1072 1072
                 }
1073 1073
             }
1074 1074
         }
@@ -1093,18 +1093,18 @@  discard block
 block discarded – undo
1093 1093
  *
1094 1094
  * @return string Modified fields SQL.
1095 1095
  */
1096
-function geodir_search_widget_location_filter_fields( $fields, $table, $post_type ) {
1096
+function geodir_search_widget_location_filter_fields($fields, $table, $post_type) {
1097 1097
     global $wpdb, $gd_query_args_widgets, $snear, $gd_session;
1098 1098
 
1099
-    if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1100
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1099
+    if (!empty($gd_query_args_widgets['gd_location']) && geodir_is_page('search') && !empty($_REQUEST['sgeo_lat']) && !empty($_REQUEST['sgeo_lon'])) {
1100
+        $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
1101 1101
 
1102
-        if ( $location_allowed && strpos( strtolower( $fields ), ' as distance ' ) === false && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1103
-            $latitude = sanitize_text_field( $_REQUEST['sgeo_lat'] );
1104
-            $longitude = sanitize_text_field( $_REQUEST['sgeo_lon'] );
1105
-            $radius = geodir_getDistanceRadius( get_option( 'geodir_search_dist_1' ) );
1102
+        if ($location_allowed && strpos(strtolower($fields), ' as distance ') === false && ($snear != '' || $gd_session->get('all_near_me'))) {
1103
+            $latitude = sanitize_text_field($_REQUEST['sgeo_lat']);
1104
+            $longitude = sanitize_text_field($_REQUEST['sgeo_lon']);
1105
+            $radius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
1106 1106
 
1107
-            $fields .= $wpdb->prepare( ", (" . $radius . " * 2 * ASIN(SQRT(POWER(SIN((ABS(%s) - ABS(" . $table . ".post_latitude)) * PI() / 180 / 2), 2) + COS(ABS(%s) * PI() / 180) * COS(ABS(" . $table . ".post_latitude) * PI() / 180) * POWER(SIN((%s - " . $table . ".post_longitude) * PI() / 180 / 2), 2)))) AS distance ", $latitude, $latitude, $longitude );
1107
+            $fields .= $wpdb->prepare(", (".$radius." * 2 * ASIN(SQRT(POWER(SIN((ABS(%s) - ABS(".$table.".post_latitude)) * PI() / 180 / 2), 2) + COS(ABS(%s) * PI() / 180) * COS(ABS(".$table.".post_latitude) * PI() / 180) * POWER(SIN((%s - ".$table.".post_longitude) * PI() / 180 / 2), 2)))) AS distance ", $latitude, $latitude, $longitude);
1108 1108
         }
1109 1109
     }
1110 1110
 
@@ -1126,14 +1126,14 @@  discard block
 block discarded – undo
1126 1126
  *
1127 1127
  * @return string Modified fields SQL.
1128 1128
  */
1129
-function geodir_search_widget_location_filter_orderby( $orderby, $table, $post_type ) {
1129
+function geodir_search_widget_location_filter_orderby($orderby, $table, $post_type) {
1130 1130
     global $gd_query_args_widgets, $snear, $gd_session;
1131 1131
 
1132
-    if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1133
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1132
+    if (!empty($gd_query_args_widgets['gd_location']) && geodir_is_page('search') && !empty($_REQUEST['sgeo_lat']) && !empty($_REQUEST['sgeo_lon'])) {
1133
+        $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
1134 1134
 
1135
-        if ( $location_allowed && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1136
-            $orderby = "distance ASC, " . $orderby;
1135
+        if ($location_allowed && ($snear != '' || $gd_session->get('all_near_me'))) {
1136
+            $orderby = "distance ASC, ".$orderby;
1137 1137
         }
1138 1138
     }
1139 1139
 
@@ -1148,23 +1148,23 @@  discard block
 block discarded – undo
1148 1148
  * @return string Filtered url.
1149 1149
  */
1150 1150
 function geodir_search_page_base_url() {
1151
-    if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1152
-        remove_filter( 'home_url', 'geodir_location_geo_home_link', 100000 );
1151
+    if (function_exists('geodir_location_geo_home_link')) {
1152
+        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1153 1153
     }
1154 1154
 
1155
-    if ( defined( 'DOING_AJAX' ) && DOING_AJAX && geodir_is_wpml() ) {
1155
+    if (defined('DOING_AJAX') && DOING_AJAX && geodir_is_wpml()) {
1156 1156
         $url = icl_get_home_url();
1157 1157
     } else {
1158 1158
         $url = get_home_url();
1159 1159
     }
1160 1160
 
1161
-    $url = trailingslashit( $url );
1161
+    $url = trailingslashit($url);
1162 1162
 
1163
-    if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1164
-        add_filter( 'home_url', 'geodir_location_geo_home_link', 100000, 2 );
1163
+    if (function_exists('geodir_location_geo_home_link')) {
1164
+        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1165 1165
     }
1166 1166
 
1167
-    return apply_filters( 'geodir_search_page_base_url', $url );
1167
+    return apply_filters('geodir_search_page_base_url', $url);
1168 1168
 }
1169 1169
 
1170 1170
 /**
@@ -1172,24 +1172,24 @@  discard block
 block discarded – undo
1172 1172
  *
1173 1173
  * @since 1.6.31
1174 1174
  */
1175
-function geodir_jetpack_fix_post_types_search(){
1176
-	if ( defined( 'JETPACK__VERSION' ) && ! empty( $_REQUEST['geodir_search'] ) ) {
1177
-		add_filter( 'jetpack_search_should_handle_query', '__return_false', 999, 1 );
1175
+function geodir_jetpack_fix_post_types_search() {
1176
+	if (defined('JETPACK__VERSION') && !empty($_REQUEST['geodir_search'])) {
1177
+		add_filter('jetpack_search_should_handle_query', '__return_false', 999, 1);
1178 1178
     }
1179 1179
 }
1180
-add_action( 'plugins_loaded','geodir_jetpack_fix_post_types_search', 10 );
1180
+add_action('plugins_loaded', 'geodir_jetpack_fix_post_types_search', 10);
1181 1181
 
1182
-function geodir_posts_having( $clauses, $query = array() ) {
1182
+function geodir_posts_having($clauses, $query = array()) {
1183 1183
 	global $wpdb, $gd_session, $geodir_post_type, $dist, $mylat, $mylon, $snear;
1184 1184
 
1185
-	if ( geodir_is_gd_main_query( $query ) ) {
1186
-		$support_location = $geodir_post_type && function_exists( 'geodir_cpt_no_location' ) && ! geodir_cpt_no_location( $geodir_post_type );
1185
+	if (geodir_is_gd_main_query($query)) {
1186
+		$support_location = $geodir_post_type && function_exists('geodir_cpt_no_location') && !geodir_cpt_no_location($geodir_post_type);
1187 1187
 
1188
-		if ( $support_location && $dist && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1189
-			if ( $gd_session->get( 'near_me_range' ) && ! isset( $_REQUEST['sdist'] ) ) {
1190
-				$dist = $gd_session->get( 'near_me_range' );
1188
+		if ($support_location && $dist && ($snear != '' || $gd_session->get('all_near_me'))) {
1189
+			if ($gd_session->get('near_me_range') && !isset($_REQUEST['sdist'])) {
1190
+				$dist = $gd_session->get('near_me_range');
1191 1191
 
1192
-				if ( get_option( 'geodir_search_dist_1' ) == 'km' ) {
1192
+				if (get_option('geodir_search_dist_1') == 'km') {
1193 1193
 					$dist = $dist * 1.6093440001;
1194 1194
 				}
1195 1195
 			}
@@ -1198,9 +1198,9 @@  discard block
 block discarded – undo
1198 1198
 			 * The HAVING clause is often used with the GROUP BY clause to filter groups based on a specified condition. 
1199 1199
 			 * If the GROUP BY clause is omitted, the HAVING clause behaves like the WHERE clause.
1200 1200
 			 */
1201
-			if ( strpos( $clauses['where'], ' HAVING ') === false && strpos( $clauses['groupby'], ' HAVING ') === false ) {
1202
-				$having = $wpdb->prepare( " HAVING distance <= %f ", $dist );
1203
-				if ( trim( $clauses['groupby'] ) != '' ) {
1201
+			if (strpos($clauses['where'], ' HAVING ') === false && strpos($clauses['groupby'], ' HAVING ') === false) {
1202
+				$having = $wpdb->prepare(" HAVING distance <= %f ", $dist);
1203
+				if (trim($clauses['groupby']) != '') {
1204 1204
 					$clauses['groupby'] .= $having;
1205 1205
 				} else {
1206 1206
 					$clauses['where'] .= $having;
@@ -1212,12 +1212,12 @@  discard block
 block discarded – undo
1212 1212
 	return $clauses;
1213 1213
 }
1214 1214
 
1215
-function geodir_is_gd_main_query( $query ){
1215
+function geodir_is_gd_main_query($query) {
1216 1216
 	$is_main_query = false;
1217 1217
 
1218
-	if(isset($query->query->gd_is_geodir_page) && $query->query->gd_is_geodir_page) {
1218
+	if (isset($query->query->gd_is_geodir_page) && $query->query->gd_is_geodir_page) {
1219 1219
 		$is_main_query = true;
1220
-	}elseif(isset($query->query['gd_is_geodir_page']) && $query->query['gd_is_geodir_page']) {
1220
+	}elseif (isset($query->query['gd_is_geodir_page']) && $query->query['gd_is_geodir_page']) {
1221 1221
 		$is_main_query = true;
1222 1222
 	}
1223 1223
 
Please login to merge, or discard this patch.