|
@@ -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 ) THEN 1 ELSE 0 END AS gd_content", array($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 ) THEN 1 ELSE 0 END AS gd_content", array($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,31 +522,31 @@ 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
|
|
- $orderby = " " . $table . "." . $sort_by . " " . $order . ", " . $table . ".rating_count " . $order . ", ";
|
|
|
542
|
+ $orderby = " ".$table.".".$sort_by." ".$order.", ".$table.".rating_count ".$order.", ";
|
|
543
|
543
|
|
|
544
|
544
|
break;
|
|
545
|
545
|
|
|
546
|
546
|
|
|
547
|
547
|
default:
|
|
548
|
548
|
if (geodir_column_exist($table, $sort_by)) {
|
|
549
|
|
- $orderby = $table . "." . $sort_by . " " . $order . ", ";
|
|
|
549
|
+ $orderby = $table.".".$sort_by." ".$order.", ";
|
|
550
|
550
|
}
|
|
551
|
551
|
break;
|
|
552
|
552
|
|
|
@@ -594,7 +594,7 @@ discard block |
|
|
block discarded – undo |
|
594
|
594
|
}
|
|
595
|
595
|
|
|
596
|
596
|
//if (!geodir_is_page('detail'))
|
|
597
|
|
- add_filter('posts_where', 'geodir_default_where', 1);/**/
|
|
|
597
|
+ add_filter('posts_where', 'geodir_default_where', 1); /**/
|
|
598
|
598
|
|
|
599
|
599
|
//add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts
|
|
600
|
600
|
|
|
@@ -665,7 +665,7 @@ discard block |
|
|
block discarded – undo |
|
665
|
665
|
$q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : '';
|
|
666
|
666
|
//echo '##########'.$q_post_type;
|
|
667
|
667
|
if ($lang_code && $q_post_type && geodir_wpml_is_post_type_translated($q_post_type)) {
|
|
668
|
|
- $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_" . $q_post_type . "') ";
|
|
|
668
|
+ $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_".$q_post_type."') ";
|
|
669
|
669
|
//$where .= " AND icl_t.language_code = '$lang_code' ";
|
|
670
|
670
|
}
|
|
671
|
671
|
|
|
@@ -732,8 +732,8 @@ discard block |
|
|
block discarded – undo |
|
732
|
732
|
}
|
|
733
|
733
|
|
|
734
|
734
|
$s = trim($s);
|
|
735
|
|
- $s = wp_specialchars_decode($s ,ENT_QUOTES);
|
|
736
|
|
- $s_A = wp_specialchars_decode($s_A ,ENT_QUOTES);
|
|
|
735
|
+ $s = wp_specialchars_decode($s, ENT_QUOTES);
|
|
|
736
|
+ $s_A = wp_specialchars_decode($s_A, ENT_QUOTES);
|
|
737
|
737
|
|
|
738
|
738
|
$where = '';
|
|
739
|
739
|
$better_search_terms = '';
|
|
@@ -744,9 +744,9 @@ discard block |
|
|
block discarded – undo |
|
744
|
744
|
|
|
745
|
745
|
if ($s != '') {
|
|
746
|
746
|
$keywords = explode(" ", $s);
|
|
747
|
|
- if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
748
|
|
- foreach($keywords as $kkey=>$kword){
|
|
749
|
|
- if(geodir_utf8_strlen($kword)<=$klimit){
|
|
|
747
|
+ if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
|
|
|
748
|
+ foreach ($keywords as $kkey=>$kword) {
|
|
|
749
|
+ if (geodir_utf8_strlen($kword) <= $klimit) {
|
|
750
|
750
|
unset($keywords[$kkey]);
|
|
751
|
751
|
}
|
|
752
|
752
|
}
|
|
@@ -755,7 +755,7 @@ discard block |
|
|
block discarded – undo |
|
755
|
755
|
if (!empty($keywords)) {
|
|
756
|
756
|
foreach ($keywords as $keyword) {
|
|
757
|
757
|
$keyword = trim($keyword);
|
|
758
|
|
- $keyword = wp_specialchars_decode($keyword ,ENT_QUOTES);
|
|
|
758
|
+ $keyword = wp_specialchars_decode($keyword, ENT_QUOTES);
|
|
759
|
759
|
if ($keyword != '') {
|
|
760
|
760
|
/**
|
|
761
|
761
|
* Filter the search query keywords SQL.
|
|
@@ -766,7 +766,7 @@ discard block |
|
|
block discarded – undo |
|
766
|
766
|
* @param array $keywords The array of keywords for the query.
|
|
767
|
767
|
* @param string $keyword The single keyword being searched.
|
|
768
|
768
|
*/
|
|
769
|
|
- $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);
|
|
|
769
|
+ $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);
|
|
770
|
770
|
}
|
|
771
|
771
|
}
|
|
772
|
772
|
}
|
|
@@ -774,10 +774,10 @@ discard block |
|
|
block discarded – undo |
|
774
|
774
|
|
|
775
|
775
|
/* get taxonomy */
|
|
776
|
776
|
$taxonomies = geodir_get_taxonomies($post_types, true);
|
|
777
|
|
- if($taxonomies) {
|
|
|
777
|
+ if ($taxonomies) {
|
|
778
|
778
|
$taxonomies = implode("','", $taxonomies);
|
|
779
|
|
- $taxonomies = "'" . $taxonomies . "'";
|
|
780
|
|
- }else{$taxonomies='';}
|
|
|
779
|
+ $taxonomies = "'".$taxonomies."'";
|
|
|
780
|
+ } else {$taxonomies = ''; }
|
|
781
|
781
|
|
|
782
|
782
|
$content_where = $terms_where = '';
|
|
783
|
783
|
if ($s != '') {
|
|
@@ -788,7 +788,7 @@ discard block |
|
|
block discarded – undo |
|
788
|
788
|
* @package GeoDirectory
|
|
789
|
789
|
* @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%\") ") "`.
|
|
790
|
790
|
*/
|
|
791
|
|
- $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%\") ");
|
|
|
791
|
+ $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%\") ");
|
|
792
|
792
|
/**
|
|
793
|
793
|
* Filter the search query term values.
|
|
794
|
794
|
*
|
|
@@ -796,7 +796,7 @@ discard block |
|
|
block discarded – undo |
|
796
|
796
|
* @package GeoDirectory
|
|
797
|
797
|
* @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)) "`.
|
|
798
|
798
|
*/
|
|
799
|
|
- $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)) ");
|
|
|
799
|
+ $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)) ");
|
|
800
|
800
|
}
|
|
801
|
801
|
|
|
802
|
802
|
|
|
@@ -813,16 +813,16 @@ discard block |
|
|
block discarded – undo |
|
813
|
813
|
$term_ids = array();
|
|
814
|
814
|
$terms_sql = '';
|
|
815
|
815
|
|
|
816
|
|
- if(!empty($term_results)){
|
|
817
|
|
- foreach($term_results as $term_id){
|
|
|
816
|
+ if (!empty($term_results)) {
|
|
|
817
|
+ foreach ($term_results as $term_id) {
|
|
818
|
818
|
$term_ids[] = $term_id;
|
|
819
|
819
|
}
|
|
820
|
820
|
if (!empty($term_ids)) {
|
|
821
|
|
- foreach($term_ids as $term){
|
|
|
821
|
+ foreach ($term_ids as $term) {
|
|
822
|
822
|
if ($term->taxonomy == $post_types.'_tags') {
|
|
823
|
|
- $terms_sql .= $wpdb->prepare(" OR FIND_IN_SET(%s , " . $table . ".post_tags) ", $term->name);
|
|
|
823
|
+ $terms_sql .= $wpdb->prepare(" OR FIND_IN_SET(%s , ".$table.".post_tags) ", $term->name);
|
|
824
|
824
|
} else {
|
|
825
|
|
- $terms_sql .= " OR FIND_IN_SET($term->term_id , " . $table . "." . $post_types . "category) ";
|
|
|
825
|
+ $terms_sql .= " OR FIND_IN_SET($term->term_id , ".$table.".".$post_types."category) ";
|
|
826
|
826
|
}
|
|
827
|
827
|
}
|
|
828
|
828
|
}
|
|
@@ -853,12 +853,12 @@ discard block |
|
|
block discarded – undo |
|
853
|
853
|
)
|
|
854
|
854
|
AND $wpdb->posts.post_type in ('{$post_types}')
|
|
855
|
855
|
AND ($wpdb->posts.post_status = 'publish')
|
|
856
|
|
- AND ( " . $table . ".post_latitude between $rlat1 and $rlat2 )
|
|
857
|
|
- AND ( " . $table . ".post_longitude between $rlon1 and $rlon2 ) ";
|
|
|
856
|
+ AND ( ".$table.".post_latitude between $rlat1 and $rlat2 )
|
|
|
857
|
+ AND ( ".$table.".post_longitude between $rlon1 and $rlon2 ) ";
|
|
858
|
858
|
|
|
859
|
859
|
if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
|
|
860
|
860
|
$DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
861
|
|
- $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;
|
|
|
861
|
+ $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;
|
|
862
|
862
|
}
|
|
863
|
863
|
|
|
864
|
864
|
} else {
|
|
@@ -875,11 +875,11 @@ discard block |
|
|
block discarded – undo |
|
875
|
875
|
}
|
|
876
|
876
|
|
|
877
|
877
|
########### WPML ###########
|
|
878
|
|
- if ( geodir_wpml_is_post_type_translated( $post_types ) ) {
|
|
|
878
|
+ if (geodir_wpml_is_post_type_translated($post_types)) {
|
|
879
|
879
|
$lang_code = ICL_LANGUAGE_CODE;
|
|
880
|
880
|
|
|
881
|
881
|
if ($lang_code && $post_types) {
|
|
882
|
|
- $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
|
|
|
882
|
+ $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_".$post_types."') ";
|
|
883
|
883
|
}
|
|
884
|
884
|
}
|
|
885
|
885
|
########### WPML ###########
|
|
@@ -902,10 +902,10 @@ discard block |
|
|
block discarded – undo |
|
902
|
902
|
global $wpdb, $geodir_post_type, $table, $curr;
|
|
903
|
903
|
|
|
904
|
904
|
$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
|
|
905
|
|
- $user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0;
|
|
|
905
|
+ $user_id = !empty($curauth->ID) ? (int) $curauth->ID : 0;
|
|
906
|
906
|
|
|
907
|
907
|
if (isset($_REQUEST['stype'])) {
|
|
908
|
|
- $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
|
|
|
908
|
+ $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ", $_REQUEST['stype']);
|
|
909
|
909
|
} else {
|
|
910
|
910
|
$where = " AND $wpdb->posts.post_type IN ('gd_place') ";
|
|
911
|
911
|
}
|
|
@@ -918,7 +918,7 @@ discard block |
|
|
block discarded – undo |
|
918
|
918
|
} else
|
|
919
|
919
|
$where .= " AND $wpdb->posts.post_author = $user_id";
|
|
920
|
920
|
|
|
921
|
|
- if ($user_id == (int)get_current_user_id()) {
|
|
|
921
|
+ if ($user_id == (int) get_current_user_id()) {
|
|
922
|
922
|
$where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
|
|
923
|
923
|
} else {
|
|
924
|
924
|
$where .= " AND $wpdb->posts.post_status = 'publish' ";
|
|
@@ -931,7 +931,7 @@ discard block |
|
|
block discarded – undo |
|
931
|
931
|
if (geodir_wpml_is_post_type_translated(sanitize_text_field($_REQUEST['stype']))) {
|
|
932
|
932
|
$lang_code = ICL_LANGUAGE_CODE;
|
|
933
|
933
|
if ($lang_code) {
|
|
934
|
|
- $where .= " AND icl_t.language_code='" . $lang_code . "' ";
|
|
|
934
|
+ $where .= " AND icl_t.language_code='".$lang_code."' ";
|
|
935
|
935
|
}
|
|
936
|
936
|
|
|
937
|
937
|
}
|
|
@@ -954,7 +954,7 @@ discard block |
|
|
block discarded – undo |
|
954
|
954
|
{
|
|
955
|
955
|
global $wp_query, $table;
|
|
956
|
956
|
if (!empty($wp_query->query['with_pics_only'])) {
|
|
957
|
|
- $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
|
|
|
957
|
+ $join .= " LEFT JOIN ".GEODIR_ATTACHMENT_TABLE." ON ( ".GEODIR_ATTACHMENT_TABLE.".post_id=".$table.".post_id AND ".GEODIR_ATTACHMENT_TABLE.".mime_type LIKE '%image%' )";
|
|
958
|
958
|
}
|
|
959
|
959
|
return $join;
|
|
960
|
960
|
}
|
|
@@ -973,16 +973,16 @@ discard block |
|
|
block discarded – undo |
|
973
|
973
|
{
|
|
974
|
974
|
global $wp_query, $table;
|
|
975
|
975
|
if (!empty($wp_query->query['show_featured_only'])) {
|
|
976
|
|
- $where .= " AND " . $table . ".is_featured = '1'";
|
|
|
976
|
+ $where .= " AND ".$table.".is_featured = '1'";
|
|
977
|
977
|
}
|
|
978
|
978
|
if (!empty($wp_query->query['show_special_only'])) {
|
|
979
|
|
- $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
|
|
|
979
|
+ $where .= " AND ( ".$table.".geodir_special_offers != '' AND ".$table.".geodir_special_offers IS NOT NULL )";
|
|
980
|
980
|
}
|
|
981
|
981
|
if (!empty($wp_query->query['with_pics_only'])) {
|
|
982
|
|
- $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id";
|
|
|
982
|
+ $where .= " AND ".GEODIR_ATTACHMENT_TABLE.".ID IS NOT NULL GROUP BY ".$table.".post_id";
|
|
983
|
983
|
}
|
|
984
|
984
|
if (!empty($wp_query->query['with_videos_only'])) {
|
|
985
|
|
- $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
|
|
|
985
|
+ $where .= " AND ( ".$table.".geodir_video != '' AND ".$table.".geodir_video IS NOT NULL )";
|
|
986
|
986
|
}
|
|
987
|
987
|
return $where;
|
|
988
|
988
|
}
|
|
@@ -991,18 +991,18 @@ discard block |
|
|
block discarded – undo |
|
991
|
991
|
function geodir_related_posts_fields($fields) {
|
|
992
|
992
|
global $wp_query, $wpdb, $table, $post;
|
|
993
|
993
|
|
|
994
|
|
- $fields .= ", " . $table . ".* ";
|
|
|
994
|
+ $fields .= ", ".$table.".* ";
|
|
995
|
995
|
|
|
996
|
996
|
$DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
997
|
997
|
|
|
998
|
998
|
$mylat = $post->post_latitude;
|
|
999
|
999
|
$mylon = $post->post_longitude;
|
|
1000
|
1000
|
|
|
1001
|
|
- $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 ";
|
|
|
1001
|
+ $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 ";
|
|
1002
|
1002
|
return $fields;
|
|
1003
|
1003
|
}
|
|
1004
|
1004
|
function geodir_related_posts_fields_filter($query) {
|
|
1005
|
|
- if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']
|
|
|
1005
|
+ if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']
|
|
1006
|
1006
|
&& isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest'
|
|
1007
|
1007
|
&& isset($query->query_vars['related_listings']) && $query->query_vars['related_listings']
|
|
1008
|
1008
|
) {
|
|
@@ -1021,25 +1021,25 @@ discard block |
|
|
block discarded – undo |
|
1021
|
1021
|
* @param string $table Listing table name.
|
|
1022
|
1022
|
* @return string|null If field exists in table returns order by clause else returns empty.
|
|
1023
|
1023
|
*/
|
|
1024
|
|
-function geodir_prepare_custom_sorting( $sorting, $table ) {
|
|
|
1024
|
+function geodir_prepare_custom_sorting($sorting, $table) {
|
|
1025
|
1025
|
$orderby = '';
|
|
1026
|
1026
|
|
|
1027
|
|
- if ( empty( $sorting ) || empty( $table ) ) {
|
|
|
1027
|
+ if (empty($sorting) || empty($table)) {
|
|
1028
|
1028
|
return $orderby;
|
|
1029
|
1029
|
}
|
|
1030
|
1030
|
|
|
1031
|
|
- if ( strpos( strtoupper( $sorting ), '_ASC' ) !== false || strpos( strtoupper( $sorting ), '_DESC') !== false ) {
|
|
1032
|
|
- $sorting_array = explode( '_', $sorting );
|
|
|
1031
|
+ if (strpos(strtoupper($sorting), '_ASC') !== false || strpos(strtoupper($sorting), '_DESC') !== false) {
|
|
|
1032
|
+ $sorting_array = explode('_', $sorting);
|
|
1033
|
1033
|
|
|
1034
|
|
- if ( ( $count = count( $sorting_array ) ) > 1 ) {
|
|
1035
|
|
- $order = !empty( $sorting_array[$count - 1] ) ? strtoupper( $sorting_array[$count - 1] ) : '';
|
|
1036
|
|
- array_pop( $sorting_array );
|
|
|
1034
|
+ if (($count = count($sorting_array)) > 1) {
|
|
|
1035
|
+ $order = !empty($sorting_array[$count - 1]) ? strtoupper($sorting_array[$count - 1]) : '';
|
|
|
1036
|
+ array_pop($sorting_array);
|
|
1037
|
1037
|
|
|
1038
|
|
- if ( !empty( $sorting_array ) && ( $order == 'ASC' || $order == 'DESC' ) ) {
|
|
1039
|
|
- $sort_by = implode( '_', $sorting_array );
|
|
|
1038
|
+ if (!empty($sorting_array) && ($order == 'ASC' || $order == 'DESC')) {
|
|
|
1039
|
+ $sort_by = implode('_', $sorting_array);
|
|
1040
|
1040
|
|
|
1041
|
|
- if ( geodir_column_exist( $table, $sort_by ) ) {
|
|
1042
|
|
- $orderby = $table . "." . $sort_by . " " . $order;
|
|
|
1041
|
+ if (geodir_column_exist($table, $sort_by)) {
|
|
|
1042
|
+ $orderby = $table.".".$sort_by." ".$order;
|
|
1043
|
1043
|
}
|
|
1044
|
1044
|
}
|
|
1045
|
1045
|
}
|
|
@@ -1064,18 +1064,18 @@ discard block |
|
|
block discarded – undo |
|
1064
|
1064
|
*
|
|
1065
|
1065
|
* @return string Modified fields SQL.
|
|
1066
|
1066
|
*/
|
|
1067
|
|
-function geodir_search_widget_location_filter_fields( $fields, $table, $post_type ) {
|
|
|
1067
|
+function geodir_search_widget_location_filter_fields($fields, $table, $post_type) {
|
|
1068
|
1068
|
global $wpdb, $gd_query_args_widgets, $snear, $gd_session;
|
|
1069
|
1069
|
|
|
1070
|
|
- if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
|
|
1071
|
|
- $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
|
|
|
1070
|
+ if (!empty($gd_query_args_widgets['gd_location']) && geodir_is_page('search') && !empty($_REQUEST['sgeo_lat']) && !empty($_REQUEST['sgeo_lon'])) {
|
|
|
1071
|
+ $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
|
|
1072
|
1072
|
|
|
1073
|
|
- if ( $location_allowed && strpos( strtolower( $fields ), ' as distance ' ) === false && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
|
|
1074
|
|
- $latitude = sanitize_text_field( $_REQUEST['sgeo_lat'] );
|
|
1075
|
|
- $longitude = sanitize_text_field( $_REQUEST['sgeo_lon'] );
|
|
1076
|
|
- $radius = geodir_getDistanceRadius( get_option( 'geodir_search_dist_1' ) );
|
|
|
1073
|
+ if ($location_allowed && strpos(strtolower($fields), ' as distance ') === false && ($snear != '' || $gd_session->get('all_near_me'))) {
|
|
|
1074
|
+ $latitude = sanitize_text_field($_REQUEST['sgeo_lat']);
|
|
|
1075
|
+ $longitude = sanitize_text_field($_REQUEST['sgeo_lon']);
|
|
|
1076
|
+ $radius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
1077
|
1077
|
|
|
1078
|
|
- $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 );
|
|
|
1078
|
+ $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);
|
|
1079
|
1079
|
}
|
|
1080
|
1080
|
}
|
|
1081
|
1081
|
|
|
@@ -1097,14 +1097,14 @@ discard block |
|
|
block discarded – undo |
|
1097
|
1097
|
*
|
|
1098
|
1098
|
* @return string Modified fields SQL.
|
|
1099
|
1099
|
*/
|
|
1100
|
|
-function geodir_search_widget_location_filter_orderby( $orderby, $table, $post_type ) {
|
|
|
1100
|
+function geodir_search_widget_location_filter_orderby($orderby, $table, $post_type) {
|
|
1101
|
1101
|
global $gd_query_args_widgets, $snear, $gd_session;
|
|
1102
|
1102
|
|
|
1103
|
|
- if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
|
|
1104
|
|
- $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
|
|
|
1103
|
+ if (!empty($gd_query_args_widgets['gd_location']) && geodir_is_page('search') && !empty($_REQUEST['sgeo_lat']) && !empty($_REQUEST['sgeo_lon'])) {
|
|
|
1104
|
+ $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
|
|
1105
|
1105
|
|
|
1106
|
|
- if ( $location_allowed && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
|
|
1107
|
|
- $orderby = "distance ASC, " . $orderby;
|
|
|
1106
|
+ if ($location_allowed && ($snear != '' || $gd_session->get('all_near_me'))) {
|
|
|
1107
|
+ $orderby = "distance ASC, ".$orderby;
|
|
1108
|
1108
|
}
|
|
1109
|
1109
|
}
|
|
1110
|
1110
|
|