Test Failed
Pull Request — master (#472)
by Kiran
16:30
created
geodirectory-functions/listing_filters.php 2 patches
Indentation   +620 added lines, -620 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
  */
17 17
 function geodir_session_start()
18 18
 {
19
-    if (!session_id()) session_start();
20
-    global $geodir_add_location_url;
19
+	if (!session_id()) session_start();
20
+	global $geodir_add_location_url;
21 21
 
22
-    $geodir_add_location_url = NULL;
22
+	$geodir_add_location_url = NULL;
23 23
 }
24 24
 
25 25
 /**
@@ -33,18 +33,18 @@  discard block
 block discarded – undo
33 33
  */
34 34
 function geodir_modified_query($query)
35 35
 {
36
-    if ($query->is_main_query() && (
37
-            (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
38
-            || geodir_is_page('listing')
39
-            || geodir_is_page('author')
40
-            || geodir_is_page('search')
41
-            || geodir_is_page('detail'))
42
-    ) {
43
-
44
-        $query->set('is_geodir_loop', true);
45
-    }
36
+	if ($query->is_main_query() && (
37
+			(geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
38
+			|| geodir_is_page('listing')
39
+			|| geodir_is_page('author')
40
+			|| geodir_is_page('search')
41
+			|| geodir_is_page('detail'))
42
+	) {
43
+
44
+		$query->set('is_geodir_loop', true);
45
+	}
46 46
 
47
-    return $query;
47
+	return $query;
48 48
 }
49 49
 
50 50
 /**
@@ -67,82 +67,82 @@  discard block
 block discarded – undo
67 67
  */
68 68
 function set_listing_request($query )
69 69
 {
70
-    global $wp_query, $wpdb, $geodir_post_type, $table, $dist, $mylat, $mylon, $s, $snear, $s, $s_A, $s_SA;
70
+	global $wp_query, $wpdb, $geodir_post_type, $table, $dist, $mylat, $mylon, $s, $snear, $s, $s_A, $s_SA;
71 71
 
72 72
 
73
-    // fix woocommerce shop products filtered by language for GD + WPML + Woocommerce
74
-    if (!geodir_is_geodir_page()) {
75
-        return;
76
-    }
73
+	// fix woocommerce shop products filtered by language for GD + WPML + Woocommerce
74
+	if (!geodir_is_geodir_page()) {
75
+		return;
76
+	}
77 77
 
78
-    /* remove all pre filters */
79
-    remove_all_filters('query');
80
-    remove_all_filters('posts_search');
81
-    remove_all_filters('posts_fields');
82
-    remove_all_filters('posts_join');
83
-    remove_all_filters('posts_orderby');
84
-    remove_all_filters('posts_where');
78
+	/* remove all pre filters */
79
+	remove_all_filters('query');
80
+	remove_all_filters('posts_search');
81
+	remove_all_filters('posts_fields');
82
+	remove_all_filters('posts_join');
83
+	remove_all_filters('posts_orderby');
84
+	remove_all_filters('posts_where');
85 85
 
86 86
 
87
-    if ((is_search() && isset($_REQUEST['geodir_search']) && $_REQUEST['geodir_search'] != '')):
87
+	if ((is_search() && isset($_REQUEST['geodir_search']) && $_REQUEST['geodir_search'] != '')):
88 88
 
89
-        if (isset($_REQUEST['scat']) && $_REQUEST['scat'] == 'all') $_REQUEST['scat'] = '';
90
-        //if(isset($_REQUEST['s']) && $_REQUEST['s'] == '+') $_REQUEST['s'] = '';
89
+		if (isset($_REQUEST['scat']) && $_REQUEST['scat'] == 'all') $_REQUEST['scat'] = '';
90
+		//if(isset($_REQUEST['s']) && $_REQUEST['s'] == '+') $_REQUEST['s'] = '';
91 91
 
92
-        if (isset($_REQUEST['sdist'])) {
93
-            ($_REQUEST['sdist'] != '0' && $_REQUEST['sdist'] != '') ? $dist = esc_attr($_REQUEST['sdist']) : $dist = 25000;
94
-        } elseif (get_option('geodir_search_dist') != '') {
95
-            $dist = get_option('geodir_search_dist');
92
+		if (isset($_REQUEST['sdist'])) {
93
+			($_REQUEST['sdist'] != '0' && $_REQUEST['sdist'] != '') ? $dist = esc_attr($_REQUEST['sdist']) : $dist = 25000;
94
+		} elseif (get_option('geodir_search_dist') != '') {
95
+			$dist = get_option('geodir_search_dist');
96 96
 
97
-        } else {
98
-            $dist = 25000;
99
-        } //  Distance
97
+		} else {
98
+			$dist = 25000;
99
+		} //  Distance
100 100
 
101
-        if (isset($_REQUEST['sgeo_lat'])) {
102
-            $mylat = (float)esc_attr($_REQUEST['sgeo_lat']);
103
-        } else {
104
-            $mylat = (float)geodir_get_current_city_lat();
105
-        } //  Latitude
101
+		if (isset($_REQUEST['sgeo_lat'])) {
102
+			$mylat = (float)esc_attr($_REQUEST['sgeo_lat']);
103
+		} else {
104
+			$mylat = (float)geodir_get_current_city_lat();
105
+		} //  Latitude
106 106
 
107
-        if (isset($_REQUEST['sgeo_lon'])) {
108
-            $mylon = (float)esc_attr($_REQUEST['sgeo_lon']);
109
-        } else {
110
-            $mylon = (float)geodir_get_current_city_lng();
111
-        } //  Distance
107
+		if (isset($_REQUEST['sgeo_lon'])) {
108
+			$mylon = (float)esc_attr($_REQUEST['sgeo_lon']);
109
+		} else {
110
+			$mylon = (float)geodir_get_current_city_lng();
111
+		} //  Distance
112 112
 
113
-        if (isset($_REQUEST['snear'])) {
114
-            $snear = trim(esc_attr($_REQUEST['snear']));
115
-        }
113
+		if (isset($_REQUEST['snear'])) {
114
+			$snear = trim(esc_attr($_REQUEST['snear']));
115
+		}
116 116
 
117
-        if (isset($_REQUEST['s'])) {
118
-            $s = trim(esc_attr(wp_strip_all_tags($_REQUEST['s'])));
119
-            $s = str_replace(array("%E2%80%99","’"),array("%27","'"),$s);
120
-        }
117
+		if (isset($_REQUEST['s'])) {
118
+			$s = trim(esc_attr(wp_strip_all_tags($_REQUEST['s'])));
119
+			$s = str_replace(array("%E2%80%99","’"),array("%27","'"),$s);
120
+		}
121 121
 
122
-        if ($snear == 'NEAR ME') {
123
-            $ip = $_SERVER['REMOTE_ADDR'];
124
-            $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
125
-            $mylat = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_latitude]));
126
-            $mylon = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_longitude]));
127
-        }
122
+		if ($snear == 'NEAR ME') {
123
+			$ip = $_SERVER['REMOTE_ADDR'];
124
+			$addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
125
+			$mylat = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_latitude]));
126
+			$mylon = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_longitude]));
127
+		}
128 128
 
129 129
 
130
-        if (strstr($s, ',')) {
131
-            $s_AA = str_replace(" ", "", $s);
132
-            $s_A = explode(",", $s_AA);
133
-            $s_A = implode('","', $s_A);
134
-            $s_A = '"' . $s_A . '"';
135
-        } else {
136
-            $s_A = '"' . $s . '"';
137
-        }
130
+		if (strstr($s, ',')) {
131
+			$s_AA = str_replace(" ", "", $s);
132
+			$s_A = explode(",", $s_AA);
133
+			$s_A = implode('","', $s_A);
134
+			$s_A = '"' . $s_A . '"';
135
+		} else {
136
+			$s_A = '"' . $s . '"';
137
+		}
138 138
 
139
-        if (strstr($s, ' ')) {
140
-            $s_SA = explode(" ", $s);
141
-        } else {
142
-            $s_SA = '';
143
-        }
139
+		if (strstr($s, ' ')) {
140
+			$s_SA = explode(" ", $s);
141
+		} else {
142
+			$s_SA = '';
143
+		}
144 144
 
145
-    endif;
145
+	endif;
146 146
 
147 147
 
148 148
 
@@ -163,56 +163,56 @@  discard block
 block discarded – undo
163 163
  */
164 164
 function geodir_listing_loop_filter($query)
165 165
 {
166
-    global $wp_query, $geodir_post_type, $table, $plugin_prefix, $table, $term;
166
+	global $wp_query, $geodir_post_type, $table, $plugin_prefix, $table, $term;
167 167
 
168
-    // fix wp_reset_query for popular post view widget
169
-    if (!geodir_is_geodir_page()) {
170
-        return;
171
-    }
168
+	// fix wp_reset_query for popular post view widget
169
+	if (!geodir_is_geodir_page()) {
170
+		return;
171
+	}
172 172
 
173
-    $geodir_post_type = geodir_get_current_posttype();
174
-
175
-    if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) {
176
-        $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy');
177
-
178
-        if (isset($wp_query->query[$taxonomies[0]])) {
179
-            $request_term = explode("/", $wp_query->query[$taxonomies[0]]);
180
-            $request_term = end($request_term);
181
-            if (!term_exists($request_term)) {
182
-                $args = array('number' => '1',);
183
-                $terms_arr = get_terms($taxonomies[0], $args);
184
-                foreach ($terms_arr as $location_term) {
185
-                    $term_arr = $location_term;
186
-                    $term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term));
187
-                }
188
-                $wp_query->queried_object_id = 1;
189
-                $wp_query->queried_object = $term_arr;
190
-                //print_r($wp_query) ;
191
-            }
192
-        }
173
+	$geodir_post_type = geodir_get_current_posttype();
174
+
175
+	if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) {
176
+		$taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy');
177
+
178
+		if (isset($wp_query->query[$taxonomies[0]])) {
179
+			$request_term = explode("/", $wp_query->query[$taxonomies[0]]);
180
+			$request_term = end($request_term);
181
+			if (!term_exists($request_term)) {
182
+				$args = array('number' => '1',);
183
+				$terms_arr = get_terms($taxonomies[0], $args);
184
+				foreach ($terms_arr as $location_term) {
185
+					$term_arr = $location_term;
186
+					$term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term));
187
+				}
188
+				$wp_query->queried_object_id = 1;
189
+				$wp_query->queried_object = $term_arr;
190
+				//print_r($wp_query) ;
191
+			}
192
+		}
193 193
 
194
-    }
195
-    if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
196
-
197
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
198
-
199
-        add_filter('posts_fields', 'geodir_posts_fields', 1);
200
-        add_filter('posts_join', 'geodir_posts_join', 1);
201
-        geodir_post_where();
202
-        if (!is_admin())
203
-            add_filter('posts_orderby', 'geodir_posts_orderby', 1);
204
-
205
-        // advanced filter for popular post view widget
206
-        global $wp_query;
207
-        if (!is_admin()) {
208
-            if (!empty($wp_query->query['with_pics_only'])) {
209
-                add_filter('posts_join', 'geodir_filter_widget_join', 1000);
210
-            }
211
-            add_filter('posts_where', 'geodir_filter_widget_where', 1000);
212
-        }
194
+	}
195
+	if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
213 196
 
214
-    }
215
-    return $query;
197
+		$table = $plugin_prefix . $geodir_post_type . '_detail';
198
+
199
+		add_filter('posts_fields', 'geodir_posts_fields', 1);
200
+		add_filter('posts_join', 'geodir_posts_join', 1);
201
+		geodir_post_where();
202
+		if (!is_admin())
203
+			add_filter('posts_orderby', 'geodir_posts_orderby', 1);
204
+
205
+		// advanced filter for popular post view widget
206
+		global $wp_query;
207
+		if (!is_admin()) {
208
+			if (!empty($wp_query->query['with_pics_only'])) {
209
+				add_filter('posts_join', 'geodir_filter_widget_join', 1000);
210
+			}
211
+			add_filter('posts_where', 'geodir_filter_widget_where', 1000);
212
+		}
213
+
214
+	}
215
+	return $query;
216 216
 }
217 217
 
218 218
 
@@ -231,67 +231,67 @@  discard block
 block discarded – undo
231 231
  * @return string Modified fields query string.
232 232
  */
233 233
 function geodir_posts_fields($fields) {
234
-    global $wp_query, $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $snear, $gd_session;
234
+	global $wp_query, $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $snear, $gd_session;
235 235
 
236
-    // Filter-Location-Manager to add location table.
237
-    $fields .= ", " . $table . ".* ";
236
+	// Filter-Location-Manager to add location table.
237
+	$fields .= ", " . $table . ".* ";
238 238
 
239 239
 	if ($snear != '' || $gd_session->get('all_near_me')) {
240
-        $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
240
+		$DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
241 241
 
242 242
 		if ($gd_session->get('all_near_me')) {
243
-            $mylat = $gd_session->get('user_lat');
244
-            $mylon = $gd_session->get('user_lon');
245
-        }
246
-
247
-        $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 ";
248
-    }
249
-
250
-    global $s;
251
-    if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
252
-        $keywords = explode(" ", $s);
253
-
254
-        if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
255
-            foreach($keywords as $kkey=>$kword){
256
-                if(geodir_utf8_strlen($kword)<=$klimit){
257
-                    unset($keywords[$kkey]);
258
-                }
259
-            }
260
-        }
243
+			$mylat = $gd_session->get('user_lat');
244
+			$mylon = $gd_session->get('user_lon');
245
+		}
261 246
 
247
+		$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 ";
248
+	}
262 249
 
263
-        if (count($keywords) > 1) {
264
-            $parts = array(
265
-                'AND' => 'gd_alltitlematch_part',
266
-                'OR' => 'gd_titlematch_part'
267
-            );
268
-            $gd_titlematch_part = "";
269
-            foreach ($parts as $key => $part) {
270
-                $gd_titlematch_part .= " CASE WHEN ";
271
-                $count = 0;
272
-                foreach ($keywords as $keyword) {
273
-                    $keyword = trim($keyword);
274
-                    $keyword  = wp_specialchars_decode($keyword ,ENT_QUOTES);
250
+	global $s;
251
+	if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
252
+		$keywords = explode(" ", $s);
253
+
254
+		if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
255
+			foreach($keywords as $kkey=>$kword){
256
+				if(geodir_utf8_strlen($kword)<=$klimit){
257
+					unset($keywords[$kkey]);
258
+				}
259
+			}
260
+		}
261
+
262
+
263
+		if (count($keywords) > 1) {
264
+			$parts = array(
265
+				'AND' => 'gd_alltitlematch_part',
266
+				'OR' => 'gd_titlematch_part'
267
+			);
268
+			$gd_titlematch_part = "";
269
+			foreach ($parts as $key => $part) {
270
+				$gd_titlematch_part .= " CASE WHEN ";
271
+				$count = 0;
272
+				foreach ($keywords as $keyword) {
273
+					$keyword = trim($keyword);
274
+					$keyword  = wp_specialchars_decode($keyword ,ENT_QUOTES);
275 275
 					$count++;
276
-                    if ($count < count($keywords)) {
277
-                       // $gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' " . $key . " ";
276
+					if ($count < count($keywords)) {
277
+					   // $gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' " . $key . " ";
278 278
 						$gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) " . $key . " ";
279
-                    } else {
280
-                        //$gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' ";
279
+					} else {
280
+						//$gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' ";
281 281
 						$gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) ";
282
-                    }
283
-                }
284
-                $gd_titlematch_part .= "THEN 1 ELSE 0 END AS " . $part . ",";
285
-            }
286
-        } else {
287
-            $gd_titlematch_part = "";
288
-        }
289
-        $s = stripslashes_deep( $s );
290
-        $s = wp_specialchars_decode($s,ENT_QUOTES);
282
+					}
283
+				}
284
+				$gd_titlematch_part .= "THEN 1 ELSE 0 END AS " . $part . ",";
285
+			}
286
+		} else {
287
+			$gd_titlematch_part = "";
288
+		}
289
+		$s = stripslashes_deep( $s );
290
+		$s = wp_specialchars_decode($s,ENT_QUOTES);
291 291
 		$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));
292
-    }
292
+	}
293 293
 
294
-    return $fields;
294
+	return $fields;
295 295
 }
296 296
 
297 297
 
@@ -308,26 +308,26 @@  discard block
 block discarded – undo
308 308
  */
309 309
 function geodir_posts_join($join)
310 310
 {
311
-    global $wpdb, $geodir_post_type, $table, $table_prefix, $plugin_prefix;
311
+	global $wpdb, $geodir_post_type, $table, $table_prefix, $plugin_prefix;
312 312
 
313
-    ########### WPML ###########
313
+	########### WPML ###########
314 314
 
315
-    if ( geodir_wpml_is_post_type_translated( $geodir_post_type ) ) {
316
-        global $sitepress;
317
-        $lang_code = ICL_LANGUAGE_CODE;
318
-        $default_lang_code = $sitepress->get_default_language();
319
-        if ($lang_code) {
320
-            $join .= "JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
321
-        }
315
+	if ( geodir_wpml_is_post_type_translated( $geodir_post_type ) ) {
316
+		global $sitepress;
317
+		$lang_code = ICL_LANGUAGE_CODE;
318
+		$default_lang_code = $sitepress->get_default_language();
319
+		if ($lang_code) {
320
+			$join .= "JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
321
+		}
322 322
 
323
-    }
324
-    ########### WPML ###########
323
+	}
324
+	########### WPML ###########
325 325
 
326
-    $join .= " INNER JOIN " . $table . " ON (" . $table . ".post_id = $wpdb->posts.ID)  ";
327
-    //===old code start
328
-    //$join .= " INNER JOIN ".POST_LOCATION_TABLE." ON (".$table.".post_location_id = ".POST_LOCATION_TABLE.".location_id)  " ;//===old code end
326
+	$join .= " INNER JOIN " . $table . " ON (" . $table . ".post_id = $wpdb->posts.ID)  ";
327
+	//===old code start
328
+	//$join .= " INNER JOIN ".POST_LOCATION_TABLE." ON (".$table.".post_location_id = ".POST_LOCATION_TABLE.".location_id)  " ;//===old code end
329 329
 
330
-    return $join;
330
+	return $join;
331 331
 }
332 332
 
333 333
 
@@ -345,15 +345,15 @@  discard block
 block discarded – undo
345 345
  */
346 346
 function geodir_posts_orderby($orderby)
347 347
 {
348
-    global $wpdb, $wp_query, $geodir_post_type, $table, $plugin_prefix, $snear, $default_sort;
348
+	global $wpdb, $wp_query, $geodir_post_type, $table, $plugin_prefix, $snear, $default_sort;
349 349
 
350
-    $sort_by = '';
351
-    $orderby = ' ';
350
+	$sort_by = '';
351
+	$orderby = ' ';
352 352
 
353
-    if (get_query_var('order_by'))
354
-        $sort_by = get_query_var('order_by');
353
+	if (get_query_var('order_by'))
354
+		$sort_by = get_query_var('order_by');
355 355
 
356
-    /*if(isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries){
356
+	/*if(isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries){
357 357
         $current_term = $wp_query->get_queried_object();
358 358
     }
359 359
 
@@ -367,133 +367,133 @@  discard block
 block discarded – undo
367 367
     }*/
368 368
 
369 369
 
370
-    if ($snear != '') {
371
-        $orderby .= " distance,";
372
-    }
370
+	if ($snear != '') {
371
+		$orderby .= " distance,";
372
+	}
373 373
 
374
-    if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] != '' && is_main_query())
375
-        $sort_by = esc_attr($_REQUEST['sort_by']);
374
+	if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] != '' && is_main_query())
375
+		$sort_by = esc_attr($_REQUEST['sort_by']);
376 376
 
377 377
 
378
-    if ($sort_by == '') {
379
-        $default_sort = geodir_get_posts_default_sort($geodir_post_type);
380
-        if (!empty($default_sort))
381
-            $sort_by = $default_sort;
382
-    }
378
+	if ($sort_by == '') {
379
+		$default_sort = geodir_get_posts_default_sort($geodir_post_type);
380
+		if (!empty($default_sort))
381
+			$sort_by = $default_sort;
382
+	}
383 383
 
384
-    /*
384
+	/*
385 385
     if search by term & no location then order always "relevance"
386 386
     if search by location then order always "nearest"
387 387
     */
388
-    if (is_main_query() && geodir_is_page('search')) {
389
-        $search_term = get_query_var('s');
388
+	if (is_main_query() && geodir_is_page('search')) {
389
+		$search_term = get_query_var('s');
390 390
 
391
-        if (trim($search_term) != '' && !isset($_REQUEST['sort_by'])) {
392
-            $sort_by = 'az';
393
-        }
391
+		if (trim($search_term) != '' && !isset($_REQUEST['sort_by'])) {
392
+			$sort_by = 'az';
393
+		}
394 394
 
395
-        if ($snear != '' &&  $sort_by!='farthest') {
396
-            $sort_by = 'nearest';
397
-        }
398
-    }
399
-
400
-    switch ($sort_by):
401
-        case 'newest':
402
-            $orderby = "$wpdb->posts.post_date desc, ";
403
-            break;
404
-        case 'oldest':
405
-            $orderby = "$wpdb->posts.post_date asc, ";
406
-            break;
407
-        case 'low_review':
408
-        case 'rating_count_asc':
409
-            $orderby = $table . ".rating_count ASC, " . $table . ".overall_rating ASC, ";
410
-            break;
411
-        case 'high_review':
412
-        case 'rating_count_desc':
413
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
414
-            break;
415
-        case 'low_rating':
416
-            $orderby = "( " . $table . ".overall_rating  ) ASC, " . $table . ".rating_count ASC,  ";
417
-            break;
418
-        case 'high_rating':
419
-            $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
420
-            break;
421
-        case 'featured':
422
-            $orderby = $table . ".is_featured asc, ";
423
-            break;
424
-        case 'nearest':
425
-            $orderby = " distance asc, ";
426
-            break;
427
-        case 'farthest':
428
-            $orderby = " distance desc, ";
429
-            break;
430
-        case 'random':
431
-            $orderby = " rand(), ";
432
-            break;
433
-        case 'az':
434
-            $orderby = "$wpdb->posts.post_title asc, ";
435
-            break;
436
-        // sort by rating
437
-        case 'overall_rating_desc':
438
-            $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
439
-            break;
440
-        case 'overall_rating_asc':
441
-            $orderby = " " . $table . ".overall_rating ASC, " . $table . ".rating_count ASC, ";
442
-            break;
443
-        default:
444
-
445
-            break;
446
-    endswitch;
447
-
448
-    if ($sort_by != '' && geodir_cpt_has_rating_disabled($geodir_post_type)) {
449
-        if (in_array($sort_by, array('high_review', 'rating_count_desc', 'high_rating', 'overall_rating_desc'))) {
450
-            $orderby = "$wpdb->posts.comment_count DESC, ";
451
-            $sort_by = 'comment_count_desc';
452
-        } else if (in_array($sort_by, array('low_review', 'rating_count_asc', 'low_rating', 'overall_rating_asc'))) {
453
-            $orderby = "$wpdb->posts.comment_count ASC, ";
454
-            $sort_by = 'comment_count_asc';
455
-        }
456
-    }
395
+		if ($snear != '' &&  $sort_by!='farthest') {
396
+			$sort_by = 'nearest';
397
+		}
398
+	}
457 399
 
458
-    global $s;
400
+	switch ($sort_by):
401
+		case 'newest':
402
+			$orderby = "$wpdb->posts.post_date desc, ";
403
+			break;
404
+		case 'oldest':
405
+			$orderby = "$wpdb->posts.post_date asc, ";
406
+			break;
407
+		case 'low_review':
408
+		case 'rating_count_asc':
409
+			$orderby = $table . ".rating_count ASC, " . $table . ".overall_rating ASC, ";
410
+			break;
411
+		case 'high_review':
412
+		case 'rating_count_desc':
413
+			$orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
414
+			break;
415
+		case 'low_rating':
416
+			$orderby = "( " . $table . ".overall_rating  ) ASC, " . $table . ".rating_count ASC,  ";
417
+			break;
418
+		case 'high_rating':
419
+			$orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
420
+			break;
421
+		case 'featured':
422
+			$orderby = $table . ".is_featured asc, ";
423
+			break;
424
+		case 'nearest':
425
+			$orderby = " distance asc, ";
426
+			break;
427
+		case 'farthest':
428
+			$orderby = " distance desc, ";
429
+			break;
430
+		case 'random':
431
+			$orderby = " rand(), ";
432
+			break;
433
+		case 'az':
434
+			$orderby = "$wpdb->posts.post_title asc, ";
435
+			break;
436
+		// sort by rating
437
+		case 'overall_rating_desc':
438
+			$orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
439
+			break;
440
+		case 'overall_rating_asc':
441
+			$orderby = " " . $table . ".overall_rating ASC, " . $table . ".rating_count ASC, ";
442
+			break;
443
+		default:
444
+
445
+			break;
446
+	endswitch;
447
+
448
+	if ($sort_by != '' && geodir_cpt_has_rating_disabled($geodir_post_type)) {
449
+		if (in_array($sort_by, array('high_review', 'rating_count_desc', 'high_rating', 'overall_rating_desc'))) {
450
+			$orderby = "$wpdb->posts.comment_count DESC, ";
451
+			$sort_by = 'comment_count_desc';
452
+		} else if (in_array($sort_by, array('low_review', 'rating_count_asc', 'low_rating', 'overall_rating_asc'))) {
453
+			$orderby = "$wpdb->posts.comment_count ASC, ";
454
+			$sort_by = 'comment_count_asc';
455
+		}
456
+	}
459 457
 
460
-    if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
461
-        $keywords = explode(" ", $s);
462
-        if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
463
-            foreach($keywords as $kkey=>$kword){
464
-                if(geodir_utf8_strlen($kword)<=$klimit){
465
-                    unset($keywords[$kkey]);
466
-                }
467
-            }
468
-        }
469
-        if ($sort_by == 'nearest' || $sort_by == 'farthest') {
470
-            if (count($keywords) > 1) {
471
-                $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ";
472
-            } else {
473
-                $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ";
474
-            }
475
-        } else {
476
-            if (count($keywords) > 1) {
477
-                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, " . $orderby;
478
-            } else {
479
-                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, " . $orderby;
480
-            }
481
-        }
482
-    }
458
+	global $s;
459
+
460
+	if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
461
+		$keywords = explode(" ", $s);
462
+		if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
463
+			foreach($keywords as $kkey=>$kword){
464
+				if(geodir_utf8_strlen($kword)<=$klimit){
465
+					unset($keywords[$kkey]);
466
+				}
467
+			}
468
+		}
469
+		if ($sort_by == 'nearest' || $sort_by == 'farthest') {
470
+			if (count($keywords) > 1) {
471
+				$orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ";
472
+			} else {
473
+				$orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ";
474
+			}
475
+		} else {
476
+			if (count($keywords) > 1) {
477
+				$orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, " . $orderby;
478
+			} else {
479
+				$orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, " . $orderby;
480
+			}
481
+		}
482
+	}
483 483
 
484
-    /**
485
-     * Filter order by SQL.
486
-     *
487
-     * @since 1.0.0
488
-     * @param string $orderby The orderby query string.
489
-     * @param string $sort_by Sortby query string.
490
-     * @param string $table Listing table name.
491
-     */
492
-    $orderby = apply_filters('geodir_posts_order_by_sort', $orderby, $sort_by, $table);
484
+	/**
485
+	 * Filter order by SQL.
486
+	 *
487
+	 * @since 1.0.0
488
+	 * @param string $orderby The orderby query string.
489
+	 * @param string $sort_by Sortby query string.
490
+	 * @param string $table Listing table name.
491
+	 */
492
+	$orderby = apply_filters('geodir_posts_order_by_sort', $orderby, $sort_by, $table);
493 493
 
494
-    $orderby .= $table . ".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title ";
494
+	$orderby .= $table . ".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title ";
495 495
 
496
-    return $orderby;
496
+	return $orderby;
497 497
 }
498 498
 
499 499
 
@@ -511,78 +511,78 @@  discard block
 block discarded – undo
511 511
 function geodir_posts_order_by_custom_sort($orderby, $sort_by, $table)
512 512
 {
513 513
 
514
-    global $wpdb;
514
+	global $wpdb;
515 515
 
516
-    if ($sort_by != '' && (!is_search() || ( isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear']=='' && ( $_REQUEST['s']=='' ||  $_REQUEST['s']==' ') ) )) {
516
+	if ($sort_by != '' && (!is_search() || ( isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear']=='' && ( $_REQUEST['s']=='' ||  $_REQUEST['s']==' ') ) )) {
517 517
 
518
-        $sort_array = explode('_', $sort_by);
518
+		$sort_array = explode('_', $sort_by);
519 519
 
520
-        $sort_by_count = count($sort_array);
520
+		$sort_by_count = count($sort_array);
521 521
 
522
-        $order = $sort_array[$sort_by_count - 1];
522
+		$order = $sort_array[$sort_by_count - 1];
523 523
 
524
-        if ($sort_by_count > 1 && ($order == 'asc' || $order == 'desc')) {
524
+		if ($sort_by_count > 1 && ($order == 'asc' || $order == 'desc')) {
525 525
 
526
-            $sort_by = str_replace('_' . $order, '', $sort_by);
526
+			$sort_by = str_replace('_' . $order, '', $sort_by);
527 527
 
528
-            switch ($sort_by):
528
+			switch ($sort_by):
529 529
 
530
-                case 'post_date':
531
-                case 'comment_count':
530
+				case 'post_date':
531
+				case 'comment_count':
532 532
 
533
-                    $orderby = "$wpdb->posts." . $sort_by . " " . $order . ", ".$table . ".overall_rating " . $order . ", ";
534
-                    break;
533
+					$orderby = "$wpdb->posts." . $sort_by . " " . $order . ", ".$table . ".overall_rating " . $order . ", ";
534
+					break;
535 535
 
536
-                case 'distance':
537
-                    $orderby = $sort_by . " " . $order . ", ";
538
-                    break;
536
+				case 'distance':
537
+					$orderby = $sort_by . " " . $order . ", ";
538
+					break;
539 539
 
540 540
 
541
-                // sort by rating
542
-                case 'overall_rating':
541
+				// sort by rating
542
+				case 'overall_rating':
543 543
 
544
-                    $use_bayesian = apply_filters('gd_use_bayesian',true,$table);
545
-                    $avg_rating = 0;
546
-                    if($use_bayesian){
547
-                        $avg_num_votes = get_transient( 'gd_avg_num_votes_'.$table );
548
-                        if(!$avg_num_votes){
549
-                            $avg_num_votes = $wpdb->get_var("SELECT SUM(rating_count) FROM $table");
550
-                            if($avg_num_votes){
544
+					$use_bayesian = apply_filters('gd_use_bayesian',true,$table);
545
+					$avg_rating = 0;
546
+					if($use_bayesian){
547
+						$avg_num_votes = get_transient( 'gd_avg_num_votes_'.$table );
548
+						if(!$avg_num_votes){
549
+							$avg_num_votes = $wpdb->get_var("SELECT SUM(rating_count) FROM $table");
550
+							if($avg_num_votes){
551 551
 
552
-                                $avg_rating = get_transient( 'gd_avg_rating_'.$table );
553
-                                if(!$avg_rating){
554
-                                    $avg_rating = $wpdb->get_var("SELECT SUM(overall_rating) FROM $table")/$avg_num_votes;
555
-                                }
556
-                                set_transient( 'gd_avg_num_votes_'.$table, $avg_num_votes, 12 * HOUR_IN_SECONDS );
557
-                                set_transient( 'gd_avg_rating_'.$table, $avg_rating , 12 * HOUR_IN_SECONDS );
558
-                            }
559
-                        }
552
+								$avg_rating = get_transient( 'gd_avg_rating_'.$table );
553
+								if(!$avg_rating){
554
+									$avg_rating = $wpdb->get_var("SELECT SUM(overall_rating) FROM $table")/$avg_num_votes;
555
+								}
556
+								set_transient( 'gd_avg_num_votes_'.$table, $avg_num_votes, 12 * HOUR_IN_SECONDS );
557
+								set_transient( 'gd_avg_rating_'.$table, $avg_rating , 12 * HOUR_IN_SECONDS );
558
+							}
559
+						}
560 560
 
561
-                        if(!$avg_num_votes){ $avg_num_votes = 0;}
561
+						if(!$avg_num_votes){ $avg_num_votes = 0;}
562 562
 
563
-                        $orderby = " (( $avg_num_votes * $avg_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating ))  / ( $avg_num_votes + " . $table . ".rating_count )  $order , ";
563
+						$orderby = " (( $avg_num_votes * $avg_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating ))  / ( $avg_num_votes + " . $table . ".rating_count )  $order , ";
564 564
 
565
-                        //$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
566
-                    }else{
567
-                        $orderby = " " . $table . "." . $sort_by . "  " . $order . ", " . $table . ".rating_count " . $order . ", ";
568
-                    }
565
+						//$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
566
+					}else{
567
+						$orderby = " " . $table . "." . $sort_by . "  " . $order . ", " . $table . ".rating_count " . $order . ", ";
568
+					}
569 569
 
570
-                    break;
570
+					break;
571 571
 
572 572
 
573
-                default:
574
-                    if (geodir_column_exist($table, $sort_by)) {
573
+				default:
574
+					if (geodir_column_exist($table, $sort_by)) {
575 575
 						$orderby = $table . "." . $sort_by . " " . $order . ", ";
576 576
 					}
577
-                    break;
577
+					break;
578 578
 
579
-            endswitch;
579
+			endswitch;
580 580
 
581
-        }
581
+		}
582 582
 
583
-    }
583
+	}
584 584
 
585
-    return $orderby;
585
+	return $orderby;
586 586
 }
587 587
 
588 588
 /**
@@ -597,34 +597,34 @@  discard block
 block discarded – undo
597 597
 {
598 598
 
599 599
 
600
-    global $wpdb, $geodir_post_type, $table, $s, $snear;
600
+	global $wpdb, $geodir_post_type, $table, $s, $snear;
601 601
 
602
-    if (!is_admin()) {
602
+	if (!is_admin()) {
603 603
 
604
-        if (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
605
-            add_filter('posts_where', 'geodir_edit_listing_where', 1);
604
+		if (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
605
+			add_filter('posts_where', 'geodir_edit_listing_where', 1);
606 606
 
607
-        } elseif ((is_search() && $_REQUEST['geodir_search'])) {
607
+		} elseif ((is_search() && $_REQUEST['geodir_search'])) {
608 608
 
609
-            add_filter('posts_where', 'searching_filter_where', 1);
609
+			add_filter('posts_where', 'searching_filter_where', 1);
610 610
 
611
-            if ($snear != '')
612
-                add_filter('posts_where', 'searching_filter_where', 1);
611
+			if ($snear != '')
612
+				add_filter('posts_where', 'searching_filter_where', 1);
613 613
 
614
-            add_filter('posts_orderby', 'geodir_posts_orderby', 1);
614
+			add_filter('posts_orderby', 'geodir_posts_orderby', 1);
615 615
 
616
-        } elseif (geodir_is_page('author')) {
616
+		} elseif (geodir_is_page('author')) {
617 617
 
618
-            add_filter('posts_where', 'author_filter_where', 1);
618
+			add_filter('posts_where', 'author_filter_where', 1);
619 619
 
620
-        }
620
+		}
621 621
 
622
-        //if (!geodir_is_page('detail'))
623
-            add_filter('posts_where', 'geodir_default_where', 1);/**/
622
+		//if (!geodir_is_page('detail'))
623
+			add_filter('posts_where', 'geodir_default_where', 1);/**/
624 624
 
625
-        //add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts
625
+		//add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts
626 626
 
627
-    }
627
+	}
628 628
 }
629 629
 
630 630
 /**
@@ -639,13 +639,13 @@  discard block
 block discarded – undo
639 639
  */
640 640
 function geodir_preview_post_cap($allcaps, $caps, $args)
641 641
 {
642
-    $user_id = get_current_user_id();
643
-    if ($user_id && isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != '' && isset($_REQUEST['p']) && $_REQUEST['p'] != '' && $args[0] == 'edit_post' && $_REQUEST['p'] == $args[2]) {
642
+	$user_id = get_current_user_id();
643
+	if ($user_id && isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != '' && isset($_REQUEST['p']) && $_REQUEST['p'] != '' && $args[0] == 'edit_post' && $_REQUEST['p'] == $args[2]) {
644 644
 
645
-        $allcaps['edit_posts'] = true;
646
-    }
647
-    //print_r($allcaps);
648
-    return $allcaps;
645
+		$allcaps['edit_posts'] = true;
646
+	}
647
+	//print_r($allcaps);
648
+	return $allcaps;
649 649
 }
650 650
 
651 651
 
@@ -660,9 +660,9 @@  discard block
 block discarded – undo
660 660
  */
661 661
 function geodir_edit_listing_where($where)
662 662
 {
663
-    global $wpdb;
664
-    $where = $wpdb->prepare(" AND $wpdb->posts.ID = %d ", $_REQUEST['pid']);
665
-    return $where;
663
+	global $wpdb;
664
+	$where = $wpdb->prepare(" AND $wpdb->posts.ID = %d ", $_REQUEST['pid']);
665
+	return $where;
666 666
 }
667 667
 
668 668
 
@@ -679,29 +679,29 @@  discard block
 block discarded – undo
679 679
  */
680 680
 function geodir_default_where($where)
681 681
 {
682
-    global $wp_query, $wpdb;
683
-
684
-    //print_r($wp_query);
685
-    ########### WPML ###########
686
-
687
-    if (geodir_is_wpml()) {
688
-        global $sitepress, $table_prefix;
689
-        $lang_code = ICL_LANGUAGE_CODE;
690
-        $default_lang_code = $sitepress->get_default_language();
691
-        $q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : '';
692
-        //echo '##########'.$q_post_type;
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 . "') ";
695
-            //$where .= " AND icl_t.language_code = '$lang_code' ";
696
-        }
682
+	global $wp_query, $wpdb;
697 683
 
698
-    }
699
-    ########### WPML ###########
684
+	//print_r($wp_query);
685
+	########### WPML ###########
700 686
 
687
+	if (geodir_is_wpml()) {
688
+		global $sitepress, $table_prefix;
689
+		$lang_code = ICL_LANGUAGE_CODE;
690
+		$default_lang_code = $sitepress->get_default_language();
691
+		$q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : '';
692
+		//echo '##########'.$q_post_type;
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 . "') ";
695
+			//$where .= " AND icl_t.language_code = '$lang_code' ";
696
+		}
701 697
 
702
-    return $where = str_replace("0 = 1", "1=1", $where);
698
+	}
699
+	########### WPML ###########
700
+
701
+
702
+	return $where = str_replace("0 = 1", "1=1", $where);
703 703
 
704
-    /* ====== old code start ===
704
+	/* ====== old code start ===
705 705
     $where = str_replace("0 = 1", "1=1", $where);
706 706
     $country = get_query_var('gd_country');
707 707
     $region = get_query_var('gd_region');
@@ -742,92 +742,92 @@  discard block
 block discarded – undo
742 742
  * @return string Modified where query string.
743 743
  */
744 744
 function searching_filter_where($where) {
745
-    global $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $s, $snear, $s_A, $s_SA, $search_term, $gd_session;
745
+	global $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $s, $snear, $s_A, $s_SA, $search_term, $gd_session;
746 746
 
747
-    $search_term = 'OR';
748
-    $search_term = 'AND';
749
-    $geodir_custom_search = '';
750
-    $category_search_range = '';
747
+	$search_term = 'OR';
748
+	$search_term = 'AND';
749
+	$geodir_custom_search = '';
750
+	$category_search_range = '';
751 751
 
752
-    if (is_single() && get_query_var('post_type')) {
752
+	if (is_single() && get_query_var('post_type')) {
753 753
 		return $where;
754 754
 	}
755 755
 
756
-    if (is_tax()) {
756
+	if (is_tax()) {
757 757
 		return $where;
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);
763
-
764
-    $where = '';
765
-    $better_search_terms = '';
766
-    if (isset($_REQUEST['stype']))
767
-        $post_types = esc_attr(wp_strip_all_tags($_REQUEST['stype']));
768
-    else
769
-        $post_types = 'gd_place';
770
-
771
-    if ($s != '') {
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){
776
-                    unset($keywords[$kkey]);
777
-                }
778
-            }
779
-        }
761
+	$s  = wp_specialchars_decode($s ,ENT_QUOTES);
762
+	$s_A = wp_specialchars_decode($s_A ,ENT_QUOTES);
763
+
764
+	$where = '';
765
+	$better_search_terms = '';
766
+	if (isset($_REQUEST['stype']))
767
+		$post_types = esc_attr(wp_strip_all_tags($_REQUEST['stype']));
768
+	else
769
+		$post_types = 'gd_place';
780 770
 
781
-        if (!empty($keywords)) {
782
-            foreach ($keywords as $keyword) {
783
-                $keyword = trim($keyword);
784
-                $keyword  = wp_specialchars_decode($keyword ,ENT_QUOTES);
785
-                if ($keyword != '') {
786
-                    /**
787
-                     * Filter the search query keywords SQL.
788
-                     *
789
-                     * @since 1.5.9
790
-                     * @package GeoDirectory
791
-                     * @param string $better_search_terms The query values, default: `' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )'`.
792
-                     * @param array $keywords The array of keywords for the query.
793
-                     * @param string $keyword The single keyword being searched.
794
-                     */
771
+	if ($s != '') {
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){
776
+					unset($keywords[$kkey]);
777
+				}
778
+			}
779
+		}
780
+
781
+		if (!empty($keywords)) {
782
+			foreach ($keywords as $keyword) {
783
+				$keyword = trim($keyword);
784
+				$keyword  = wp_specialchars_decode($keyword ,ENT_QUOTES);
785
+				if ($keyword != '') {
786
+					/**
787
+					 * Filter the search query keywords SQL.
788
+					 *
789
+					 * @since 1.5.9
790
+					 * @package GeoDirectory
791
+					 * @param string $better_search_terms The query values, default: `' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )'`.
792
+					 * @param array $keywords The array of keywords for the query.
793
+					 * @param string $keyword The single keyword being searched.
794
+					 */
795 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
-                }
797
-            }
798
-        }
799
-    }
796
+				}
797
+			}
798
+		}
799
+	}
800 800
 
801
-    /* get taxonomy */
802
-    $taxonomies = geodir_get_taxonomies($post_types, true);
803
-    if($taxonomies) {
804
-        $taxonomies = implode("','", $taxonomies);
805
-        $taxonomies = "'" . $taxonomies . "'";
806
-    }else{$taxonomies='';}
801
+	/* get taxonomy */
802
+	$taxonomies = geodir_get_taxonomies($post_types, true);
803
+	if($taxonomies) {
804
+		$taxonomies = implode("','", $taxonomies);
805
+		$taxonomies = "'" . $taxonomies . "'";
806
+	}else{$taxonomies='';}
807 807
 
808
-    $content_where = $terms_where = '';
808
+	$content_where = $terms_where = '';
809 809
 	if ($s != '') {
810
-        /**
811
-         * Filter the search query content where values.
812
-         *
813
-         * @since 1.5.0
814
-         * @package GeoDirectory
815
-         * @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%\") ") "`.
816
-         */
810
+		/**
811
+		 * Filter the search query content where values.
812
+		 *
813
+		 * @since 1.5.0
814
+		 * @package GeoDirectory
815
+		 * @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%\") ") "`.
816
+		 */
817 817
 		$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%\") ");
818
-        /**
819
-         * Filter the search query term values.
820
-         *
821
-         * @since 1.5.0
822
-         * @package GeoDirectory
823
-         * @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)) "`.
824
-         */
825
-        $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)) ");
818
+		/**
819
+		 * Filter the search query term values.
820
+		 *
821
+		 * @since 1.5.0
822
+		 * @package GeoDirectory
823
+		 * @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)) "`.
824
+		 */
825
+		$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)) ");
826 826
 	}
827 827
 
828 828
 
829
-    // get term sql
830
-    $term_sql = "SELECT $wpdb->term_taxonomy.term_id, $wpdb->terms.name, $wpdb->term_taxonomy.taxonomy
829
+	// get term sql
830
+	$term_sql = "SELECT $wpdb->term_taxonomy.term_id, $wpdb->terms.name, $wpdb->term_taxonomy.taxonomy
831 831
                     FROM $wpdb->term_taxonomy,  $wpdb->terms, $wpdb->term_relationships
832 832
                     WHERE $wpdb->term_taxonomy.term_id =  $wpdb->terms.term_id
833 833
                     AND $wpdb->term_relationships.term_taxonomy_id =  $wpdb->term_taxonomy.term_taxonomy_id
@@ -835,45 +835,45 @@  discard block
 block discarded – undo
835 835
                     $terms_where
836 836
                     GROUP BY $wpdb->term_taxonomy.term_id";
837 837
 
838
-    $term_results = $wpdb->get_results($term_sql);
839
-    $term_ids = array();
840
-    $terms_sql = '';
841
-
842
-    if(!empty($term_results)){
843
-        foreach($term_results as $term_id){
844
-            $term_ids[] = $term_id;
845
-        }
846
-        if (!empty($term_ids)) {
847
-            foreach($term_ids as $term){
848
-                if ($term->taxonomy == $post_types.'_tags') {
849
-                    $terms_sql .= $wpdb->prepare(" OR FIND_IN_SET(%s , " . $table . ".post_tags) ", $term->name);
850
-                } else {
851
-                    $terms_sql .= " OR FIND_IN_SET($term->term_id , " . $table . "." . $post_types . "category) ";
852
-                }
853
-            }
854
-        }
855
-    }
838
+	$term_results = $wpdb->get_results($term_sql);
839
+	$term_ids = array();
840
+	$terms_sql = '';
841
+
842
+	if(!empty($term_results)){
843
+		foreach($term_results as $term_id){
844
+			$term_ids[] = $term_id;
845
+		}
846
+		if (!empty($term_ids)) {
847
+			foreach($term_ids as $term){
848
+				if ($term->taxonomy == $post_types.'_tags') {
849
+					$terms_sql .= $wpdb->prepare(" OR FIND_IN_SET(%s , " . $table . ".post_tags) ", $term->name);
850
+				} else {
851
+					$terms_sql .= " OR FIND_IN_SET($term->term_id , " . $table . "." . $post_types . "category) ";
852
+				}
853
+			}
854
+		}
855
+	}
856 856
 
857 857
 
858
-    if ($snear != '') {
858
+	if ($snear != '') {
859 859
 
860 860
 
861
-        if (is_numeric($gd_session->get('near_me_range')) && !isset($_REQUEST['sdist'])) {
862
-            $dist = $gd_session->get('near_me_range');
863
-        }
864
-        $lon1 = $mylon - $dist / abs(cos(deg2rad($mylat)) * 69);
865
-        $lon2 = $mylon + $dist / abs(cos(deg2rad($mylat)) * 69);
866
-        $lat1 = $mylat - ($dist / 69);
867
-        $lat2 = $mylat + ($dist / 69);
861
+		if (is_numeric($gd_session->get('near_me_range')) && !isset($_REQUEST['sdist'])) {
862
+			$dist = $gd_session->get('near_me_range');
863
+		}
864
+		$lon1 = $mylon - $dist / abs(cos(deg2rad($mylat)) * 69);
865
+		$lon2 = $mylon + $dist / abs(cos(deg2rad($mylat)) * 69);
866
+		$lat1 = $mylat - ($dist / 69);
867
+		$lat2 = $mylat + ($dist / 69);
868 868
 
869
-        $rlon1 = is_numeric(min($lon1, $lon2)) ? min($lon1, $lon2) : '';
870
-        $rlon2 = is_numeric(max($lon1, $lon2)) ? max($lon1, $lon2) : '';
871
-        $rlat1 = is_numeric(min($lat1, $lat2)) ? min($lat1, $lat2) : '';
872
-        $rlat2 = is_numeric(max($lat1, $lat2)) ? max($lat1, $lat2) : '';
869
+		$rlon1 = is_numeric(min($lon1, $lon2)) ? min($lon1, $lon2) : '';
870
+		$rlon2 = is_numeric(max($lon1, $lon2)) ? max($lon1, $lon2) : '';
871
+		$rlat1 = is_numeric(min($lat1, $lat2)) ? min($lat1, $lat2) : '';
872
+		$rlat2 = is_numeric(max($lat1, $lat2)) ? max($lat1, $lat2) : '';
873 873
 
874 874
 
875 875
 
876
-	    $where .= " AND ( ( $wpdb->posts.post_title LIKE \"$s\" $better_search_terms)
876
+		$where .= " AND ( ( $wpdb->posts.post_title LIKE \"$s\" $better_search_terms)
877 877
 			                    $content_where 
878 878
 								$terms_sql 
879 879
 							)
@@ -882,35 +882,35 @@  discard block
 block discarded – undo
882 882
 						AND ( " . $table . ".post_latitude between $rlat1 and $rlat2 )
883 883
 						AND ( " . $table . ".post_longitude between $rlon1 and $rlon2 ) ";
884 884
 
885
-        if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
886
-            $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
887
-            $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;
888
-        }
885
+		if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
886
+			$DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
887
+			$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;
888
+		}
889 889
 
890
-    } else {
890
+	} else {
891 891
 
892 892
 
893 893
 
894
-        $where .= " AND (	( $wpdb->posts.post_title LIKE \"$s\" $better_search_terms)
894
+		$where .= " AND (	( $wpdb->posts.post_title LIKE \"$s\" $better_search_terms)
895 895
                             $content_where  
896 896
 							$terms_sql 
897 897
 					    ) 
898 898
 					
899 899
 				AND $wpdb->posts.post_type in ('$post_types')
900 900
 				AND ($wpdb->posts.post_status = 'publish') ";
901
-    }
901
+	}
902 902
 
903 903
 	########### WPML ###########
904
-    if ( geodir_wpml_is_post_type_translated( $post_types ) ) {
904
+	if ( geodir_wpml_is_post_type_translated( $post_types ) ) {
905 905
 		$lang_code = ICL_LANGUAGE_CODE;
906 906
 
907 907
 		if ($lang_code && $post_types) {
908
-            $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
909
-        }
910
-    }
911
-    ########### WPML ###########
908
+			$where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
909
+		}
910
+	}
911
+	########### WPML ###########
912 912
 
913
-    return $where;
913
+	return $where;
914 914
 }
915 915
 
916 916
 
@@ -925,45 +925,45 @@  discard block
 block discarded – undo
925 925
  * @return string Modified where query string.
926 926
  */
927 927
 function author_filter_where($where) {
928
-    global $wpdb, $geodir_post_type, $table, $curr;
928
+	global $wpdb, $geodir_post_type, $table, $curr;
929 929
 
930
-    $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
931
-    $user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0;
930
+	$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
931
+	$user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0;
932 932
 
933
-    if (isset($_REQUEST['stype'])) {
934
-        $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
935
-    } else {
936
-        $where = " AND $wpdb->posts.post_type IN ('gd_place') ";
937
-    }
933
+	if (isset($_REQUEST['stype'])) {
934
+		$where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
935
+	} else {
936
+		$where = " AND $wpdb->posts.post_type IN ('gd_place') ";
937
+	}
938 938
 
939
-    if ($user_id > 0) {
940
-        if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
941
-            $user_fav_posts = geodir_get_user_favourites($user_id);
942
-            $user_fav_posts = !empty($user_fav_posts) && is_array($user_fav_posts) ? implode("','", $user_fav_posts) : '-1';
943
-            $where .= " AND $wpdb->posts.ID IN ('$user_fav_posts')";
944
-        } else
945
-            $where .= " AND $wpdb->posts.post_author = $user_id";
946
-
947
-        if ($user_id == (int)get_current_user_id()) {
948
-            $where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
949
-        } else {
950
-            $where .= " AND $wpdb->posts.post_status = 'publish' ";
951
-        }
952
-    } else {
953
-        $where .= " AND $wpdb->posts.post_author = '-1' AND $wpdb->posts.post_status = 'publish' ";
954
-    }
939
+	if ($user_id > 0) {
940
+		if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
941
+			$user_fav_posts = geodir_get_user_favourites($user_id);
942
+			$user_fav_posts = !empty($user_fav_posts) && is_array($user_fav_posts) ? implode("','", $user_fav_posts) : '-1';
943
+			$where .= " AND $wpdb->posts.ID IN ('$user_fav_posts')";
944
+		} else
945
+			$where .= " AND $wpdb->posts.post_author = $user_id";
946
+
947
+		if ($user_id == (int)get_current_user_id()) {
948
+			$where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
949
+		} else {
950
+			$where .= " AND $wpdb->posts.post_status = 'publish' ";
951
+		}
952
+	} else {
953
+		$where .= " AND $wpdb->posts.post_author = '-1' AND $wpdb->posts.post_status = 'publish' ";
954
+	}
955 955
 
956
-    ########### WPML ###########
957
-    if (geodir_wpml_is_post_type_translated(sanitize_text_field($_REQUEST['stype']))) {
958
-        $lang_code = ICL_LANGUAGE_CODE;
959
-        if ($lang_code) {
960
-            $where .= " AND icl_t.language_code='" . $lang_code . "' ";
961
-        }
956
+	########### WPML ###########
957
+	if (geodir_wpml_is_post_type_translated(sanitize_text_field($_REQUEST['stype']))) {
958
+		$lang_code = ICL_LANGUAGE_CODE;
959
+		if ($lang_code) {
960
+			$where .= " AND icl_t.language_code='" . $lang_code . "' ";
961
+		}
962 962
 
963
-    }
964
-    ########### WPML ###########
963
+	}
964
+	########### WPML ###########
965 965
 
966
-    return $where;
966
+	return $where;
967 967
 }
968 968
 
969 969
 /**
@@ -978,11 +978,11 @@  discard block
 block discarded – undo
978 978
  */
979 979
 function geodir_filter_widget_join($join)
980 980
 {
981
-    global $wp_query, $table;
982
-    if (!empty($wp_query->query['with_pics_only'])) {
983
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
984
-    }
985
-    return $join;
981
+	global $wp_query, $table;
982
+	if (!empty($wp_query->query['with_pics_only'])) {
983
+		$join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
984
+	}
985
+	return $join;
986 986
 }
987 987
 
988 988
 /**
@@ -997,43 +997,43 @@  discard block
 block discarded – undo
997 997
  */
998 998
 function geodir_filter_widget_where($where)
999 999
 {
1000
-    global $wp_query, $table;
1001
-    if (!empty($wp_query->query['show_featured_only'])) {
1002
-        $where .= " AND " . $table . ".is_featured = '1'";
1003
-    }
1004
-    if (!empty($wp_query->query['show_special_only'])) {
1005
-        $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
1006
-    }
1007
-    if (!empty($wp_query->query['with_pics_only'])) {
1008
-        $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id";
1009
-    }
1010
-    if (!empty($wp_query->query['with_videos_only'])) {
1011
-        $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
1012
-    }
1013
-    return $where;
1000
+	global $wp_query, $table;
1001
+	if (!empty($wp_query->query['show_featured_only'])) {
1002
+		$where .= " AND " . $table . ".is_featured = '1'";
1003
+	}
1004
+	if (!empty($wp_query->query['show_special_only'])) {
1005
+		$where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
1006
+	}
1007
+	if (!empty($wp_query->query['with_pics_only'])) {
1008
+		$where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id";
1009
+	}
1010
+	if (!empty($wp_query->query['with_videos_only'])) {
1011
+		$where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
1012
+	}
1013
+	return $where;
1014 1014
 }
1015 1015
 
1016 1016
 
1017 1017
 function geodir_related_posts_fields($fields) {
1018
-    global $wp_query, $wpdb, $table, $post;
1018
+	global $wp_query, $wpdb, $table, $post;
1019 1019
 
1020
-    $fields .= ", " . $table . ".* ";
1020
+	$fields .= ", " . $table . ".* ";
1021 1021
 
1022
-    $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
1022
+	$DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
1023 1023
 
1024
-    $mylat = $post->post_latitude;
1025
-    $mylon = $post->post_longitude;
1024
+	$mylat = $post->post_latitude;
1025
+	$mylon = $post->post_longitude;
1026 1026
 
1027
-    $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 ";
1028
-    return $fields;
1027
+	$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 ";
1028
+	return $fields;
1029 1029
 }
1030 1030
 function geodir_related_posts_fields_filter($query) {
1031
-    if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']
1032
-        && isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest'
1033
-        && isset($query->query_vars['related_listings']) && $query->query_vars['related_listings']
1034
-    ) {
1035
-        add_filter('posts_fields', 'geodir_related_posts_fields', 1);
1036
-    }
1031
+	if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']
1032
+		&& isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest'
1033
+		&& isset($query->query_vars['related_listings']) && $query->query_vars['related_listings']
1034
+	) {
1035
+		add_filter('posts_fields', 'geodir_related_posts_fields', 1);
1036
+	}
1037 1037
 }
1038 1038
 add_action('pre_get_posts', 'geodir_related_posts_fields_filter', 1);
1039 1039
 
@@ -1048,30 +1048,30 @@  discard block
 block discarded – undo
1048 1048
  * @return string|null If field exists in table returns order by clause else returns empty.
1049 1049
  */
1050 1050
 function geodir_prepare_custom_sorting( $sorting, $table ) {
1051
-    $orderby = '';
1051
+	$orderby = '';
1052 1052
     
1053
-    if ( empty( $sorting ) || empty( $table ) ) {
1054
-        return $orderby;
1055
-    }
1053
+	if ( empty( $sorting ) || empty( $table ) ) {
1054
+		return $orderby;
1055
+	}
1056 1056
     
1057
-    if ( strpos( strtoupper( $sorting ), '_ASC' ) !== false || strpos( strtoupper( $sorting ), '_DESC') !== false ) {
1058
-        $sorting_array = explode( '_', $sorting );
1057
+	if ( strpos( strtoupper( $sorting ), '_ASC' ) !== false || strpos( strtoupper( $sorting ), '_DESC') !== false ) {
1058
+		$sorting_array = explode( '_', $sorting );
1059 1059
         
1060
-        if ( ( $count = count( $sorting_array ) ) > 1 ) {
1061
-            $order = !empty( $sorting_array[$count - 1] ) ? strtoupper( $sorting_array[$count - 1] ) : '';
1062
-            array_pop( $sorting_array );
1060
+		if ( ( $count = count( $sorting_array ) ) > 1 ) {
1061
+			$order = !empty( $sorting_array[$count - 1] ) ? strtoupper( $sorting_array[$count - 1] ) : '';
1062
+			array_pop( $sorting_array );
1063 1063
             
1064
-            if ( !empty( $sorting_array ) && ( $order == 'ASC' || $order == 'DESC' ) ) {
1065
-                $sort_by = implode( '_', $sorting_array );
1064
+			if ( !empty( $sorting_array ) && ( $order == 'ASC' || $order == 'DESC' ) ) {
1065
+				$sort_by = implode( '_', $sorting_array );
1066 1066
                 
1067
-                if ( geodir_column_exist( $table, $sort_by ) ) {
1068
-                    $orderby = $table . "." . $sort_by . " " . $order;
1069
-                }
1070
-            }
1071
-        }
1072
-    }
1067
+				if ( geodir_column_exist( $table, $sort_by ) ) {
1068
+					$orderby = $table . "." . $sort_by . " " . $order;
1069
+				}
1070
+			}
1071
+		}
1072
+	}
1073 1073
 
1074
-    return $orderby;
1074
+	return $orderby;
1075 1075
 }
1076 1076
 
1077 1077
 /**
@@ -1091,21 +1091,21 @@  discard block
 block discarded – undo
1091 1091
  * @return string Modified fields SQL.
1092 1092
  */
1093 1093
 function geodir_search_widget_location_filter_fields( $fields, $table, $post_type ) {
1094
-    global $wpdb, $gd_query_args_widgets, $snear, $gd_session;
1094
+	global $wpdb, $gd_query_args_widgets, $snear, $gd_session;
1095 1095
 
1096
-    if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1097
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1096
+	if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1097
+		$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1098 1098
 
1099
-        if ( $location_allowed && strpos( strtolower( $fields ), ' as distance ' ) === false && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1100
-            $latitude = sanitize_text_field( $_REQUEST['sgeo_lat'] );
1101
-            $longitude = sanitize_text_field( $_REQUEST['sgeo_lon'] );
1102
-            $radius = geodir_getDistanceRadius( get_option( 'geodir_search_dist_1' ) );
1099
+		if ( $location_allowed && strpos( strtolower( $fields ), ' as distance ' ) === false && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1100
+			$latitude = sanitize_text_field( $_REQUEST['sgeo_lat'] );
1101
+			$longitude = sanitize_text_field( $_REQUEST['sgeo_lon'] );
1102
+			$radius = geodir_getDistanceRadius( get_option( 'geodir_search_dist_1' ) );
1103 1103
 
1104
-            $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 );
1105
-        }
1106
-    }
1104
+			$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 );
1105
+		}
1106
+	}
1107 1107
 
1108
-    return $fields;
1108
+	return $fields;
1109 1109
 }
1110 1110
 
1111 1111
 /**
@@ -1124,17 +1124,17 @@  discard block
 block discarded – undo
1124 1124
  * @return string Modified fields SQL.
1125 1125
  */
1126 1126
 function geodir_search_widget_location_filter_orderby( $orderby, $table, $post_type ) {
1127
-    global $gd_query_args_widgets, $snear, $gd_session;
1127
+	global $gd_query_args_widgets, $snear, $gd_session;
1128 1128
 
1129
-    if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1130
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1129
+	if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1130
+		$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1131 1131
 
1132
-        if ( $location_allowed && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1133
-            $orderby = "distance ASC, " . $orderby;
1134
-        }
1135
-    }
1132
+		if ( $location_allowed && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1133
+			$orderby = "distance ASC, " . $orderby;
1134
+		}
1135
+	}
1136 1136
 
1137
-    return $orderby;
1137
+	return $orderby;
1138 1138
 }
1139 1139
 
1140 1140
 /**
@@ -1145,23 +1145,23 @@  discard block
 block discarded – undo
1145 1145
  * @return string Filtered url.
1146 1146
  */
1147 1147
 function geodir_search_page_base_url() {
1148
-    if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1149
-        remove_filter( 'home_url', 'geodir_location_geo_home_link', 100000 );
1150
-    }
1148
+	if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1149
+		remove_filter( 'home_url', 'geodir_location_geo_home_link', 100000 );
1150
+	}
1151 1151
 
1152
-    if ( defined( 'DOING_AJAX' ) && DOING_AJAX && geodir_is_wpml() ) {
1153
-        $url = icl_get_home_url();
1154
-    } else {
1155
-        $url = get_home_url();
1156
-    }
1152
+	if ( defined( 'DOING_AJAX' ) && DOING_AJAX && geodir_is_wpml() ) {
1153
+		$url = icl_get_home_url();
1154
+	} else {
1155
+		$url = get_home_url();
1156
+	}
1157 1157
 
1158
-    $url = trailingslashit( $url );
1158
+	$url = trailingslashit( $url );
1159 1159
 
1160
-    if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1161
-        add_filter( 'home_url', 'geodir_location_geo_home_link', 100000, 2 );
1162
-    }
1160
+	if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1161
+		add_filter( 'home_url', 'geodir_location_geo_home_link', 100000, 2 );
1162
+	}
1163 1163
 
1164
-    return apply_filters( 'geodir_search_page_base_url', $url );
1164
+	return apply_filters( 'geodir_search_page_base_url', $url );
1165 1165
 }
1166 1166
 
1167 1167
 /**
@@ -1172,6 +1172,6 @@  discard block
 block discarded – undo
1172 1172
 function geodir_jetpack_fix_post_types_search(){
1173 1173
 	if ( defined( 'JETPACK__VERSION' ) && ! empty( $_REQUEST['geodir_search'] ) ) {
1174 1174
 		add_filter( 'jetpack_search_should_handle_query', '__return_false', 999, 1 );
1175
-    }
1175
+	}
1176 1176
 }
1177 1177
 add_action( 'plugins_loaded','geodir_jetpack_fix_post_types_search', 10 );
1178 1178
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +131 added lines, -131 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'])) {
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
 
117 117
         if (isset($_REQUEST['s'])) {
118 118
             $s = trim(esc_attr(wp_strip_all_tags($_REQUEST['s'])));
119
-            $s = str_replace(array("%E2%80%99","’"),array("%27","'"),$s);
119
+            $s = str_replace(array("%E2%80%99", "’"), array("%27", "'"), $s);
120 120
         }
121 121
 
122 122
         if ($snear == 'NEAR ME') {
123 123
             $ip = $_SERVER['REMOTE_ADDR'];
124
-            $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
124
+            $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip));
125 125
             $mylat = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_latitude]));
126 126
             $mylon = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_longitude]));
127 127
         }
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
             $s_AA = str_replace(" ", "", $s);
132 132
             $s_A = explode(",", $s_AA);
133 133
             $s_A = implode('","', $s_A);
134
-            $s_A = '"' . $s_A . '"';
134
+            $s_A = '"'.$s_A.'"';
135 135
         } else {
136
-            $s_A = '"' . $s . '"';
136
+            $s_A = '"'.$s.'"';
137 137
         }
138 138
 
139 139
         if (strstr($s, ' ')) {
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
     }
195 195
     if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
196 196
 
197
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
197
+        $table = $plugin_prefix.$geodir_post_type.'_detail';
198 198
 
199 199
         add_filter('posts_fields', 'geodir_posts_fields', 1);
200 200
         add_filter('posts_join', 'geodir_posts_join', 1);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
     global $wp_query, $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $snear, $gd_session;
235 235
 
236 236
     // Filter-Location-Manager to add location table.
237
-    $fields .= ", " . $table . ".* ";
237
+    $fields .= ", ".$table.".* ";
238 238
 
239 239
 	if ($snear != '' || $gd_session->get('all_near_me')) {
240 240
         $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
@@ -244,16 +244,16 @@  discard block
 block discarded – undo
244 244
             $mylon = $gd_session->get('user_lon');
245 245
         }
246 246
 
247
-        $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
+        $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 ";
248 248
     }
249 249
 
250 250
     global $s;
251 251
     if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
252 252
         $keywords = explode(" ", $s);
253 253
 
254
-        if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
255
-            foreach($keywords as $kkey=>$kword){
256
-                if(geodir_utf8_strlen($kword)<=$klimit){
254
+        if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
255
+            foreach ($keywords as $kkey=>$kword) {
256
+                if (geodir_utf8_strlen($kword) <= $klimit) {
257 257
                     unset($keywords[$kkey]);
258 258
                 }
259 259
             }
@@ -271,24 +271,24 @@  discard block
 block discarded – undo
271 271
                 $count = 0;
272 272
                 foreach ($keywords as $keyword) {
273 273
                     $keyword = trim($keyword);
274
-                    $keyword  = wp_specialchars_decode($keyword ,ENT_QUOTES);
274
+                    $keyword = wp_specialchars_decode($keyword, ENT_QUOTES);
275 275
 					$count++;
276 276
                     if ($count < count($keywords)) {
277 277
                        // $gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' " . $key . " ";
278
-						$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
+						$gd_titlematch_part .= "( ".$wpdb->posts.".post_title LIKE '".$keyword."' OR ".$wpdb->posts.".post_title LIKE '".$keyword."%%' OR ".$wpdb->posts.".post_title LIKE '%% ".$keyword."%%' ) ".$key." ";
279 279
                     } else {
280 280
                         //$gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' ";
281
-						$gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) ";
281
+						$gd_titlematch_part .= "( ".$wpdb->posts.".post_title LIKE '".$keyword."' OR ".$wpdb->posts.".post_title LIKE '".$keyword."%%' OR ".$wpdb->posts.".post_title LIKE '%% ".$keyword."%%' ) ";
282 282
                     }
283 283
                 }
284
-                $gd_titlematch_part .= "THEN 1 ELSE 0 END AS " . $part . ",";
284
+                $gd_titlematch_part .= "THEN 1 ELSE 0 END AS ".$part.",";
285 285
             }
286 286
         } else {
287 287
             $gd_titlematch_part = "";
288 288
         }
289
-        $s = stripslashes_deep( $s );
290
-        $s = wp_specialchars_decode($s,ENT_QUOTES);
291
-		$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));
289
+        $s = stripslashes_deep($s);
290
+        $s = wp_specialchars_decode($s, ENT_QUOTES);
291
+		$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));
292 292
     }
293 293
 
294 294
     return $fields;
@@ -312,18 +312,18 @@  discard block
 block discarded – undo
312 312
 
313 313
     ########### WPML ###########
314 314
 
315
-    if ( geodir_wpml_is_post_type_translated( $geodir_post_type ) ) {
315
+    if (geodir_wpml_is_post_type_translated($geodir_post_type)) {
316 316
         global $sitepress;
317 317
         $lang_code = ICL_LANGUAGE_CODE;
318 318
         $default_lang_code = $sitepress->get_default_language();
319 319
         if ($lang_code) {
320
-            $join .= "JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
320
+            $join .= "JOIN ".$table_prefix."icl_translations icl_t ON icl_t.element_id = ".$table_prefix."posts.ID";
321 321
         }
322 322
 
323 323
     }
324 324
     ########### WPML ###########
325 325
 
326
-    $join .= " INNER JOIN " . $table . " ON (" . $table . ".post_id = $wpdb->posts.ID)  ";
326
+    $join .= " INNER JOIN ".$table." ON (".$table.".post_id = $wpdb->posts.ID)  ";
327 327
     //===old code start
328 328
     //$join .= " INNER JOIN ".POST_LOCATION_TABLE." ON (".$table.".post_location_id = ".POST_LOCATION_TABLE.".location_id)  " ;//===old code end
329 329
 
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
             $sort_by = 'az';
393 393
         }
394 394
 
395
-        if ($snear != '' &&  $sort_by!='farthest') {
395
+        if ($snear != '' && $sort_by != 'farthest') {
396 396
             $sort_by = 'nearest';
397 397
         }
398 398
     }
@@ -406,20 +406,20 @@  discard block
 block discarded – undo
406 406
             break;
407 407
         case 'low_review':
408 408
         case 'rating_count_asc':
409
-            $orderby = $table . ".rating_count ASC, " . $table . ".overall_rating ASC, ";
409
+            $orderby = $table.".rating_count ASC, ".$table.".overall_rating ASC, ";
410 410
             break;
411 411
         case 'high_review':
412 412
         case 'rating_count_desc':
413
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
413
+            $orderby = $table.".rating_count DESC, ".$table.".overall_rating DESC, ";
414 414
             break;
415 415
         case 'low_rating':
416
-            $orderby = "( " . $table . ".overall_rating  ) ASC, " . $table . ".rating_count ASC,  ";
416
+            $orderby = "( ".$table.".overall_rating  ) ASC, ".$table.".rating_count ASC,  ";
417 417
             break;
418 418
         case 'high_rating':
419
-            $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
419
+            $orderby = " ".$table.".overall_rating DESC, ".$table.".rating_count DESC, ";
420 420
             break;
421 421
         case 'featured':
422
-            $orderby = $table . ".is_featured asc, ";
422
+            $orderby = $table.".is_featured asc, ";
423 423
             break;
424 424
         case 'nearest':
425 425
             $orderby = " distance asc, ";
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
             break;
436 436
         // sort by rating
437 437
         case 'overall_rating_desc':
438
-            $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
438
+            $orderby = " ".$table.".overall_rating DESC, ".$table.".rating_count DESC, ";
439 439
             break;
440 440
         case 'overall_rating_asc':
441
-            $orderby = " " . $table . ".overall_rating ASC, " . $table . ".rating_count ASC, ";
441
+            $orderby = " ".$table.".overall_rating ASC, ".$table.".rating_count ASC, ";
442 442
             break;
443 443
         default:
444 444
 
@@ -459,24 +459,24 @@  discard block
 block discarded – undo
459 459
 
460 460
     if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
461 461
         $keywords = explode(" ", $s);
462
-        if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
463
-            foreach($keywords as $kkey=>$kword){
464
-                if(geodir_utf8_strlen($kword)<=$klimit){
462
+        if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
463
+            foreach ($keywords as $kkey=>$kword) {
464
+                if (geodir_utf8_strlen($kword) <= $klimit) {
465 465
                     unset($keywords[$kkey]);
466 466
                 }
467 467
             }
468 468
         }
469 469
         if ($sort_by == 'nearest' || $sort_by == 'farthest') {
470 470
             if (count($keywords) > 1) {
471
-                $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
+                $orderby = $orderby." ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ";
472 472
             } else {
473
-                $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ";
473
+                $orderby = $orderby." ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ";
474 474
             }
475 475
         } else {
476 476
             if (count($keywords) > 1) {
477
-                $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
+                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ".$orderby;
478 478
             } else {
479
-                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, " . $orderby;
479
+                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ".$orderby;
480 480
             }
481 481
         }
482 482
     }
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
      */
492 492
     $orderby = apply_filters('geodir_posts_order_by_sort', $orderby, $sort_by, $table);
493 493
 
494
-    $orderby .= $table . ".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title ";
494
+    $orderby .= $table.".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title ";
495 495
 
496 496
     return $orderby;
497 497
 }
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 
514 514
     global $wpdb;
515 515
 
516
-    if ($sort_by != '' && (!is_search() || ( isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear']=='' && ( $_REQUEST['s']=='' ||  $_REQUEST['s']==' ') ) )) {
516
+    if ($sort_by != '' && (!is_search() || (isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear'] == '' && ($_REQUEST['s'] == '' || $_REQUEST['s'] == ' ')))) {
517 517
 
518 518
         $sort_array = explode('_', $sort_by);
519 519
 
@@ -523,48 +523,48 @@  discard block
 block discarded – undo
523 523
 
524 524
         if ($sort_by_count > 1 && ($order == 'asc' || $order == 'desc')) {
525 525
 
526
-            $sort_by = str_replace('_' . $order, '', $sort_by);
526
+            $sort_by = str_replace('_'.$order, '', $sort_by);
527 527
 
528 528
             switch ($sort_by):
529 529
 
530 530
                 case 'post_date':
531 531
                 case 'comment_count':
532 532
 
533
-                    $orderby = "$wpdb->posts." . $sort_by . " " . $order . ", ".$table . ".overall_rating " . $order . ", ";
533
+                    $orderby = "$wpdb->posts.".$sort_by." ".$order.", ".$table.".overall_rating ".$order.", ";
534 534
                     break;
535 535
 
536 536
                 case 'distance':
537
-                    $orderby = $sort_by . " " . $order . ", ";
537
+                    $orderby = $sort_by." ".$order.", ";
538 538
                     break;
539 539
 
540 540
 
541 541
                 // sort by rating
542 542
                 case 'overall_rating':
543 543
 
544
-                    $use_bayesian = apply_filters('gd_use_bayesian',true,$table);
544
+                    $use_bayesian = apply_filters('gd_use_bayesian', true, $table);
545 545
                     $avg_rating = 0;
546
-                    if($use_bayesian){
547
-                        $avg_num_votes = get_transient( 'gd_avg_num_votes_'.$table );
548
-                        if(!$avg_num_votes){
546
+                    if ($use_bayesian) {
547
+                        $avg_num_votes = get_transient('gd_avg_num_votes_'.$table);
548
+                        if (!$avg_num_votes) {
549 549
                             $avg_num_votes = $wpdb->get_var("SELECT SUM(rating_count) FROM $table");
550
-                            if($avg_num_votes){
550
+                            if ($avg_num_votes) {
551 551
 
552
-                                $avg_rating = get_transient( 'gd_avg_rating_'.$table );
553
-                                if(!$avg_rating){
554
-                                    $avg_rating = $wpdb->get_var("SELECT SUM(overall_rating) FROM $table")/$avg_num_votes;
552
+                                $avg_rating = get_transient('gd_avg_rating_'.$table);
553
+                                if (!$avg_rating) {
554
+                                    $avg_rating = $wpdb->get_var("SELECT SUM(overall_rating) FROM $table") / $avg_num_votes;
555 555
                                 }
556
-                                set_transient( 'gd_avg_num_votes_'.$table, $avg_num_votes, 12 * HOUR_IN_SECONDS );
557
-                                set_transient( 'gd_avg_rating_'.$table, $avg_rating , 12 * HOUR_IN_SECONDS );
556
+                                set_transient('gd_avg_num_votes_'.$table, $avg_num_votes, 12 * HOUR_IN_SECONDS);
557
+                                set_transient('gd_avg_rating_'.$table, $avg_rating, 12 * HOUR_IN_SECONDS);
558 558
                             }
559 559
                         }
560 560
 
561
-                        if(!$avg_num_votes){ $avg_num_votes = 0;}
561
+                        if (!$avg_num_votes) { $avg_num_votes = 0; }
562 562
 
563
-                        $orderby = " (( $avg_num_votes * $avg_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating ))  / ( $avg_num_votes + " . $table . ".rating_count )  $order , ";
563
+                        $orderby = " (( $avg_num_votes * $avg_rating ) + (".$table.".rating_count * ".$table.".overall_rating ))  / ( $avg_num_votes + ".$table.".rating_count )  $order , ";
564 564
 
565 565
                         //$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
566
-                    }else{
567
-                        $orderby = " " . $table . "." . $sort_by . "  " . $order . ", " . $table . ".rating_count " . $order . ", ";
566
+                    } else {
567
+                        $orderby = " ".$table.".".$sort_by."  ".$order.", ".$table.".rating_count ".$order.", ";
568 568
                     }
569 569
 
570 570
                     break;
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
                 default:
574 574
                     if (geodir_column_exist($table, $sort_by)) {
575
-						$orderby = $table . "." . $sort_by . " " . $order . ", ";
575
+						$orderby = $table.".".$sort_by." ".$order.", ";
576 576
 					}
577 577
                     break;
578 578
 
@@ -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,10 +800,10 @@  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 809
 	if ($s != '') {
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
          * @package GeoDirectory
815 815
          * @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%\") ") "`.
816 816
          */
817
-		$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%\") ");
817
+		$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%\") ");
818 818
         /**
819 819
          * Filter the search query term values.
820 820
          *
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
          * @package GeoDirectory
823 823
          * @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)) "`.
824 824
          */
825
-        $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)) ");
825
+        $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)) ");
826 826
 	}
827 827
 
828 828
 
@@ -839,16 +839,16 @@  discard block
 block discarded – undo
839 839
     $term_ids = array();
840 840
     $terms_sql = '';
841 841
 
842
-    if(!empty($term_results)){
843
-        foreach($term_results as $term_id){
842
+    if (!empty($term_results)) {
843
+        foreach ($term_results as $term_id) {
844 844
             $term_ids[] = $term_id;
845 845
         }
846 846
         if (!empty($term_ids)) {
847
-            foreach($term_ids as $term){
847
+            foreach ($term_ids as $term) {
848 848
                 if ($term->taxonomy == $post_types.'_tags') {
849
-                    $terms_sql .= $wpdb->prepare(" OR FIND_IN_SET(%s , " . $table . ".post_tags) ", $term->name);
849
+                    $terms_sql .= $wpdb->prepare(" OR FIND_IN_SET(%s , ".$table.".post_tags) ", $term->name);
850 850
                 } else {
851
-                    $terms_sql .= " OR FIND_IN_SET($term->term_id , " . $table . "." . $post_types . "category) ";
851
+                    $terms_sql .= " OR FIND_IN_SET($term->term_id , ".$table.".".$post_types."category) ";
852 852
                 }
853 853
             }
854 854
         }
@@ -879,12 +879,12 @@  discard block
 block discarded – undo
879 879
 							)
880 880
 						AND $wpdb->posts.post_type in ('{$post_types}')
881 881
 						AND ($wpdb->posts.post_status = 'publish')
882
-						AND ( " . $table . ".post_latitude between $rlat1 and $rlat2 )
883
-						AND ( " . $table . ".post_longitude between $rlon1 and $rlon2 ) ";
882
+						AND ( ".$table.".post_latitude between $rlat1 and $rlat2 )
883
+						AND ( ".$table.".post_longitude between $rlon1 and $rlon2 ) ";
884 884
 
885 885
         if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
886 886
             $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
887
-            $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;
887
+            $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;
888 888
         }
889 889
 
890 890
     } else {
@@ -901,11 +901,11 @@  discard block
 block discarded – undo
901 901
     }
902 902
 
903 903
 	########### WPML ###########
904
-    if ( geodir_wpml_is_post_type_translated( $post_types ) ) {
904
+    if (geodir_wpml_is_post_type_translated($post_types)) {
905 905
 		$lang_code = ICL_LANGUAGE_CODE;
906 906
 
907 907
 		if ($lang_code && $post_types) {
908
-            $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
908
+            $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_".$post_types."') ";
909 909
         }
910 910
     }
911 911
     ########### WPML ###########
@@ -928,10 +928,10 @@  discard block
 block discarded – undo
928 928
     global $wpdb, $geodir_post_type, $table, $curr;
929 929
 
930 930
     $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
931
-    $user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0;
931
+    $user_id = !empty($curauth->ID) ? (int) $curauth->ID : 0;
932 932
 
933 933
     if (isset($_REQUEST['stype'])) {
934
-        $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
934
+        $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ", $_REQUEST['stype']);
935 935
     } else {
936 936
         $where = " AND $wpdb->posts.post_type IN ('gd_place') ";
937 937
     }
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
         } else
945 945
             $where .= " AND $wpdb->posts.post_author = $user_id";
946 946
 
947
-        if ($user_id == (int)get_current_user_id()) {
947
+        if ($user_id == (int) get_current_user_id()) {
948 948
             $where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
949 949
         } else {
950 950
             $where .= " AND $wpdb->posts.post_status = 'publish' ";
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
     if (geodir_wpml_is_post_type_translated(sanitize_text_field($_REQUEST['stype']))) {
958 958
         $lang_code = ICL_LANGUAGE_CODE;
959 959
         if ($lang_code) {
960
-            $where .= " AND icl_t.language_code='" . $lang_code . "' ";
960
+            $where .= " AND icl_t.language_code='".$lang_code."' ";
961 961
         }
962 962
 
963 963
     }
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 {
981 981
     global $wp_query, $table;
982 982
     if (!empty($wp_query->query['with_pics_only'])) {
983
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
983
+        $join .= " LEFT JOIN ".GEODIR_ATTACHMENT_TABLE." ON ( ".GEODIR_ATTACHMENT_TABLE.".post_id=".$table.".post_id AND ".GEODIR_ATTACHMENT_TABLE.".mime_type LIKE '%image%' )";
984 984
     }
985 985
     return $join;
986 986
 }
@@ -999,16 +999,16 @@  discard block
 block discarded – undo
999 999
 {
1000 1000
     global $wp_query, $table;
1001 1001
     if (!empty($wp_query->query['show_featured_only'])) {
1002
-        $where .= " AND " . $table . ".is_featured = '1'";
1002
+        $where .= " AND ".$table.".is_featured = '1'";
1003 1003
     }
1004 1004
     if (!empty($wp_query->query['show_special_only'])) {
1005
-        $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
1005
+        $where .= " AND ( ".$table.".geodir_special_offers != '' AND ".$table.".geodir_special_offers IS NOT NULL )";
1006 1006
     }
1007 1007
     if (!empty($wp_query->query['with_pics_only'])) {
1008
-        $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id";
1008
+        $where .= " AND ".GEODIR_ATTACHMENT_TABLE.".ID IS NOT NULL GROUP BY ".$table.".post_id";
1009 1009
     }
1010 1010
     if (!empty($wp_query->query['with_videos_only'])) {
1011
-        $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
1011
+        $where .= " AND ( ".$table.".geodir_video != '' AND ".$table.".geodir_video IS NOT NULL )";
1012 1012
     }
1013 1013
     return $where;
1014 1014
 }
@@ -1017,18 +1017,18 @@  discard block
 block discarded – undo
1017 1017
 function geodir_related_posts_fields($fields) {
1018 1018
     global $wp_query, $wpdb, $table, $post;
1019 1019
 
1020
-    $fields .= ", " . $table . ".* ";
1020
+    $fields .= ", ".$table.".* ";
1021 1021
 
1022 1022
     $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
1023 1023
 
1024 1024
     $mylat = $post->post_latitude;
1025 1025
     $mylon = $post->post_longitude;
1026 1026
 
1027
-    $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 ";
1027
+    $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 ";
1028 1028
     return $fields;
1029 1029
 }
1030 1030
 function geodir_related_posts_fields_filter($query) {
1031
-    if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']
1031
+    if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']
1032 1032
         && isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest'
1033 1033
         && isset($query->query_vars['related_listings']) && $query->query_vars['related_listings']
1034 1034
     ) {
@@ -1047,25 +1047,25 @@  discard block
 block discarded – undo
1047 1047
  * @param string $table Listing table name.
1048 1048
  * @return string|null If field exists in table returns order by clause else returns empty.
1049 1049
  */
1050
-function geodir_prepare_custom_sorting( $sorting, $table ) {
1050
+function geodir_prepare_custom_sorting($sorting, $table) {
1051 1051
     $orderby = '';
1052 1052
     
1053
-    if ( empty( $sorting ) || empty( $table ) ) {
1053
+    if (empty($sorting) || empty($table)) {
1054 1054
         return $orderby;
1055 1055
     }
1056 1056
     
1057
-    if ( strpos( strtoupper( $sorting ), '_ASC' ) !== false || strpos( strtoupper( $sorting ), '_DESC') !== false ) {
1058
-        $sorting_array = explode( '_', $sorting );
1057
+    if (strpos(strtoupper($sorting), '_ASC') !== false || strpos(strtoupper($sorting), '_DESC') !== false) {
1058
+        $sorting_array = explode('_', $sorting);
1059 1059
         
1060
-        if ( ( $count = count( $sorting_array ) ) > 1 ) {
1061
-            $order = !empty( $sorting_array[$count - 1] ) ? strtoupper( $sorting_array[$count - 1] ) : '';
1062
-            array_pop( $sorting_array );
1060
+        if (($count = count($sorting_array)) > 1) {
1061
+            $order = !empty($sorting_array[$count - 1]) ? strtoupper($sorting_array[$count - 1]) : '';
1062
+            array_pop($sorting_array);
1063 1063
             
1064
-            if ( !empty( $sorting_array ) && ( $order == 'ASC' || $order == 'DESC' ) ) {
1065
-                $sort_by = implode( '_', $sorting_array );
1064
+            if (!empty($sorting_array) && ($order == 'ASC' || $order == 'DESC')) {
1065
+                $sort_by = implode('_', $sorting_array);
1066 1066
                 
1067
-                if ( geodir_column_exist( $table, $sort_by ) ) {
1068
-                    $orderby = $table . "." . $sort_by . " " . $order;
1067
+                if (geodir_column_exist($table, $sort_by)) {
1068
+                    $orderby = $table.".".$sort_by." ".$order;
1069 1069
                 }
1070 1070
             }
1071 1071
         }
@@ -1090,18 +1090,18 @@  discard block
 block discarded – undo
1090 1090
  *
1091 1091
  * @return string Modified fields SQL.
1092 1092
  */
1093
-function geodir_search_widget_location_filter_fields( $fields, $table, $post_type ) {
1093
+function geodir_search_widget_location_filter_fields($fields, $table, $post_type) {
1094 1094
     global $wpdb, $gd_query_args_widgets, $snear, $gd_session;
1095 1095
 
1096
-    if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1097
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1096
+    if (!empty($gd_query_args_widgets['gd_location']) && geodir_is_page('search') && !empty($_REQUEST['sgeo_lat']) && !empty($_REQUEST['sgeo_lon'])) {
1097
+        $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
1098 1098
 
1099
-        if ( $location_allowed && strpos( strtolower( $fields ), ' as distance ' ) === false && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1100
-            $latitude = sanitize_text_field( $_REQUEST['sgeo_lat'] );
1101
-            $longitude = sanitize_text_field( $_REQUEST['sgeo_lon'] );
1102
-            $radius = geodir_getDistanceRadius( get_option( 'geodir_search_dist_1' ) );
1099
+        if ($location_allowed && strpos(strtolower($fields), ' as distance ') === false && ($snear != '' || $gd_session->get('all_near_me'))) {
1100
+            $latitude = sanitize_text_field($_REQUEST['sgeo_lat']);
1101
+            $longitude = sanitize_text_field($_REQUEST['sgeo_lon']);
1102
+            $radius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
1103 1103
 
1104
-            $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 );
1104
+            $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);
1105 1105
         }
1106 1106
     }
1107 1107
 
@@ -1123,14 +1123,14 @@  discard block
 block discarded – undo
1123 1123
  *
1124 1124
  * @return string Modified fields SQL.
1125 1125
  */
1126
-function geodir_search_widget_location_filter_orderby( $orderby, $table, $post_type ) {
1126
+function geodir_search_widget_location_filter_orderby($orderby, $table, $post_type) {
1127 1127
     global $gd_query_args_widgets, $snear, $gd_session;
1128 1128
 
1129
-    if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1130
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1129
+    if (!empty($gd_query_args_widgets['gd_location']) && geodir_is_page('search') && !empty($_REQUEST['sgeo_lat']) && !empty($_REQUEST['sgeo_lon'])) {
1130
+        $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
1131 1131
 
1132
-        if ( $location_allowed && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1133
-            $orderby = "distance ASC, " . $orderby;
1132
+        if ($location_allowed && ($snear != '' || $gd_session->get('all_near_me'))) {
1133
+            $orderby = "distance ASC, ".$orderby;
1134 1134
         }
1135 1135
     }
1136 1136
 
@@ -1145,23 +1145,23 @@  discard block
 block discarded – undo
1145 1145
  * @return string Filtered url.
1146 1146
  */
1147 1147
 function geodir_search_page_base_url() {
1148
-    if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1149
-        remove_filter( 'home_url', 'geodir_location_geo_home_link', 100000 );
1148
+    if (function_exists('geodir_location_geo_home_link')) {
1149
+        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1150 1150
     }
1151 1151
 
1152
-    if ( defined( 'DOING_AJAX' ) && DOING_AJAX && geodir_is_wpml() ) {
1152
+    if (defined('DOING_AJAX') && DOING_AJAX && geodir_is_wpml()) {
1153 1153
         $url = icl_get_home_url();
1154 1154
     } else {
1155 1155
         $url = get_home_url();
1156 1156
     }
1157 1157
 
1158
-    $url = trailingslashit( $url );
1158
+    $url = trailingslashit($url);
1159 1159
 
1160
-    if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1161
-        add_filter( 'home_url', 'geodir_location_geo_home_link', 100000, 2 );
1160
+    if (function_exists('geodir_location_geo_home_link')) {
1161
+        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1162 1162
     }
1163 1163
 
1164
-    return apply_filters( 'geodir_search_page_base_url', $url );
1164
+    return apply_filters('geodir_search_page_base_url', $url);
1165 1165
 }
1166 1166
 
1167 1167
 /**
@@ -1169,9 +1169,9 @@  discard block
 block discarded – undo
1169 1169
  *
1170 1170
  * @since 1.6.31
1171 1171
  */
1172
-function geodir_jetpack_fix_post_types_search(){
1173
-	if ( defined( 'JETPACK__VERSION' ) && ! empty( $_REQUEST['geodir_search'] ) ) {
1174
-		add_filter( 'jetpack_search_should_handle_query', '__return_false', 999, 1 );
1172
+function geodir_jetpack_fix_post_types_search() {
1173
+	if (defined('JETPACK__VERSION') && !empty($_REQUEST['geodir_search'])) {
1174
+		add_filter('jetpack_search_should_handle_query', '__return_false', 999, 1);
1175 1175
     }
1176 1176
 }
1177
-add_action( 'plugins_loaded','geodir_jetpack_fix_post_types_search', 10 );
1178 1177
\ No newline at end of file
1178
+add_action('plugins_loaded', 'geodir_jetpack_fix_post_types_search', 10);
1179 1179
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-admin/admin_hooks_actions.php 1 patch
Indentation   +1649 added lines, -1649 removed lines patch added patch discarded remove patch
@@ -10,33 +10,33 @@  discard block
 block discarded – undo
10 10
 
11 11
 add_action('admin_init', 'geodir_admin_init');
12 12
 if (!function_exists('geodir_admin_init')) {
13
-    /**
14
-     * Adds GD setting pages in admin.
15
-     *
16
-     * @since 1.0.0
17
-     * @package GeoDirectory
18
-     * @global string $current_tab The current settings tab name.
19
-     */
20
-    function geodir_admin_init()
21
-    {
22
-
23
-        if (is_admin()):
24
-            global $current_tab;
25
-            geodir_redirect_to_admin_panel_on_installed();
26
-            $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
-            if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
-                geodir_handle_option_form_submit($current_tab); // located in admin function.php
29
-            /**
30
-             * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31
-             *
32
-             * @since 1.0.0
33
-             */
34
-            do_action('admin_panel_init');
35
-            add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
36
-
37
-
38
-        endif;
39
-    }
13
+	/**
14
+	 * Adds GD setting pages in admin.
15
+	 *
16
+	 * @since 1.0.0
17
+	 * @package GeoDirectory
18
+	 * @global string $current_tab The current settings tab name.
19
+	 */
20
+	function geodir_admin_init()
21
+	{
22
+
23
+		if (is_admin()):
24
+			global $current_tab;
25
+			geodir_redirect_to_admin_panel_on_installed();
26
+			$current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
+			if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
+				geodir_handle_option_form_submit($current_tab); // located in admin function.php
29
+			/**
30
+			 * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31
+			 *
32
+			 * @since 1.0.0
33
+			 */
34
+			do_action('admin_panel_init');
35
+			add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
36
+
37
+
38
+		endif;
39
+	}
40 40
 }
41 41
 
42 42
 /**
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function geodir_redirect_to_admin_panel_on_installed()
49 49
 {
50
-    if (get_option('geodir_installation_redirect', false)) {
51
-        delete_option('geodir_installation_redirect');
52
-        wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
53
-    }
50
+	if (get_option('geodir_installation_redirect', false)) {
51
+		delete_option('geodir_installation_redirect');
52
+		wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
53
+	}
54 54
 }
55 55
 
56 56
 /**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function geodir_get_admin_option_form($current_tab)
64 64
 {
65
-    geodir_admin_option_form($current_tab);// defined in admin template tags.php
65
+	geodir_admin_option_form($current_tab);// defined in admin template tags.php
66 66
 }
67 67
 
68 68
 
@@ -86,24 +86,24 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function geodir_conditional_admin_script_load()
88 88
 {
89
-    global $pagenow;
89
+	global $pagenow;
90 90
 	
91 91
 	// Get the current post type
92 92
 	$post_type = geodir_admin_current_post_type();
93 93
 	$geodir_post_types = geodir_get_posttypes();
94 94
     
95 95
 	if ((isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') || (($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') && $post_type && in_array($post_type, $geodir_post_types)) || ($pagenow == 'edit-tags.php' || $pagenow == 'term.php' || $pagenow == 'edit-comments.php' || $pagenow == 'comment.php')) {
96
-        add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
97
-        add_action('admin_enqueue_scripts', 'geodir_admin_styles');
98
-        add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
96
+		add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
97
+		add_action('admin_enqueue_scripts', 'geodir_admin_styles');
98
+		add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
99 99
         
100
-        // Disable VC editor for GD post types.
101
-        if (class_exists('Vc_Role_Access_Controller')) {
102
-            add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 );
103
-        }
104
-    }
100
+		// Disable VC editor for GD post types.
101
+		if (class_exists('Vc_Role_Access_Controller')) {
102
+			add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 );
103
+		}
104
+	}
105 105
 
106
-    add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
106
+	add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
107 107
 
108 108
 }
109 109
 
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
  */
139 139
 function create_default_admin_main_nav()
140 140
 {
141
-    add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
142
-    add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
143
-    add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
144
-    add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
145
-    add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
146
-    //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
141
+	add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
142
+	add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
143
+	add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
144
+	add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
145
+	add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
146
+	//add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
147 147
 
148 148
 }
149 149
 
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
  */
158 158
 function geodir_admin_list_columns()
159 159
 {
160
-    if ($post_types = geodir_get_posttypes()) {
160
+	if ($post_types = geodir_get_posttypes()) {
161 161
 
162
-        foreach ($post_types as $post_type):
163
-            add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
164
-            //Filter-Payment-Manager to show Package
165
-            add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
162
+		foreach ($post_types as $post_type):
163
+			add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
164
+			//Filter-Payment-Manager to show Package
165
+			add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
166 166
 
167
-            add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
167
+			add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
168 168
             
169
-            // Filter bulk actions
170
-            add_filter("bulk_actions-edit-{$post_type}", 'geodir_filter_bulk_actions', 10, 1);
171
-        endforeach;
172
-    }
169
+			// Filter bulk actions
170
+			add_filter("bulk_actions-edit-{$post_type}", 'geodir_filter_bulk_actions', 10, 1);
171
+		endforeach;
172
+	}
173 173
 }
174 174
 
175 175
 /**
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
  */
183 183
 function geodir_default_admin_main_tabs($tabs)
184 184
 {
185
-    return $tabs = array(
186
-        'general_settings' => array('label' => __('General', 'geodirectory')),
187
-        'design_settings' => array('label' => __('Design', 'geodirectory')),
188
-        'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
189
-        'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
190
-        'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
191
-        'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
192
-
193
-    );
185
+	return $tabs = array(
186
+		'general_settings' => array('label' => __('General', 'geodirectory')),
187
+		'design_settings' => array('label' => __('Design', 'geodirectory')),
188
+		'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
189
+		'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
190
+		'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
191
+		'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
192
+
193
+	);
194 194
 }
195 195
 
196 196
 add_action('do_meta_boxes', 'geodir_remove_image_box');
@@ -203,16 +203,16 @@  discard block
 block discarded – undo
203 203
  */
204 204
 function geodir_remove_image_box()
205 205
 {
206
-    global $post;
206
+	global $post;
207 207
 
208
-    $geodir_posttypes = geodir_get_posttypes();
208
+	$geodir_posttypes = geodir_get_posttypes();
209 209
 
210
-    if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
210
+	if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
211 211
 
212
-        remove_meta_box('postimagediv', $post->post_type, 'side');
213
-        remove_meta_box('revisionsdiv', $post->post_type, 'normal');
212
+		remove_meta_box('postimagediv', $post->post_type, 'side');
213
+		remove_meta_box('revisionsdiv', $post->post_type, 'normal');
214 214
 
215
-    endif;
215
+	endif;
216 216
 
217 217
 }
218 218
 
@@ -227,27 +227,27 @@  discard block
 block discarded – undo
227 227
  */
228 228
 function geodir_meta_box_add()
229 229
 {
230
-    global $post;
230
+	global $post;
231 231
 
232
-    $geodir_post_types = geodir_get_posttypes('array');
233
-    $geodir_posttypes = array_keys($geodir_post_types);
232
+	$geodir_post_types = geodir_get_posttypes('array');
233
+	$geodir_posttypes = array_keys($geodir_post_types);
234 234
 
235
-    if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
235
+	if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
236 236
 
237
-        $geodir_posttype = $post->post_type;
238
-        $post_typename = __($geodir_post_types[$geodir_posttype]['labels']['singular_name'], 'geodirectory');
239
-        $post_typename = geodir_ucwords($post_typename);
237
+		$geodir_posttype = $post->post_type;
238
+		$post_typename = __($geodir_post_types[$geodir_posttype]['labels']['singular_name'], 'geodirectory');
239
+		$post_typename = geodir_ucwords($post_typename);
240 240
 
241
-        // Filter-Payment-Manager
241
+		// Filter-Payment-Manager
242 242
 
243
-        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
243
+		add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
244 244
 
245
-        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
245
+		add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
246 246
 
247
-        // no need of this box as all fields moved to main information box
248
-        //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
247
+		// no need of this box as all fields moved to main information box
248
+		//add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
249 249
 
250
-    endif;
250
+	endif;
251 251
 
252 252
 }
253 253
 
@@ -271,23 +271,23 @@  discard block
 block discarded – undo
271 271
 function geodir_hide_post_taxonomy_meta_boxes()
272 272
 {
273 273
 
274
-    $geodir_post_types = get_option('geodir_post_types');
274
+	$geodir_post_types = get_option('geodir_post_types');
275 275
 
276
-    if (!empty($geodir_post_types)) {
277
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
276
+	if (!empty($geodir_post_types)) {
277
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
278 278
 
279
-            $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
279
+			$gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
280 280
 
281
-            if(!empty($gd_taxonomy)) {
282
-                foreach ($gd_taxonomy as $tax) {
281
+			if(!empty($gd_taxonomy)) {
282
+				foreach ($gd_taxonomy as $tax) {
283 283
 
284
-                    remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
284
+					remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
285 285
 
286
-                }
287
-            }
286
+				}
287
+			}
288 288
 
289
-        }
290
-    }
289
+		}
290
+	}
291 291
 }
292 292
 
293 293
 add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict');
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
  */
302 302
 function geodir_add_listing_map_restrict($map_restirct)
303 303
 {
304
-    if (is_admin()) {
305
-        if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
306
-            $map_restirct = false;
307
-        }
308
-    }
309
-    return $map_restirct;
304
+	if (is_admin()) {
305
+		if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
306
+			$map_restirct = false;
307
+		}
308
+	}
309
+	return $map_restirct;
310 310
 }
311 311
 
312 312
 
@@ -325,16 +325,16 @@  discard block
 block discarded – undo
325 325
 function geodir_enable_editor_on_notifications($notification)
326 326
 {
327 327
 
328
-    if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
328
+	if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
329 329
 
330
-        foreach ($notification as $key => $value) {
331
-            if ($value['type'] == 'textarea')
332
-                $notification[$key]['type'] = 'editor';
333
-        }
330
+		foreach ($notification as $key => $value) {
331
+			if ($value['type'] == 'textarea')
332
+				$notification[$key]['type'] = 'editor';
333
+		}
334 334
 
335
-    }
335
+	}
336 336
 
337
-    return $notification;
337
+	return $notification;
338 338
 }
339 339
 
340 340
 
@@ -351,16 +351,16 @@  discard block
 block discarded – undo
351 351
 function geodir_enable_editor_on_design_settings($design_setting)
352 352
 {
353 353
 
354
-    if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
354
+	if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
355 355
 
356
-        foreach ($design_setting as $key => $value) {
357
-            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
358
-                $design_setting[$key]['type'] = 'editor';
359
-        }
356
+		foreach ($design_setting as $key => $value) {
357
+			if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
358
+				$design_setting[$key]['type'] = 'editor';
359
+		}
360 360
 
361
-    }
361
+	}
362 362
 
363
-    return $design_setting;
363
+	return $design_setting;
364 364
 }
365 365
 
366 366
 /* ----------- START MANAGE CUSTOM FIELDS ---------------- */
@@ -368,15 +368,15 @@  discard block
 block discarded – undo
368 368
 add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom');
369 369
 
370 370
 function geodir_manage_available_fields_predefined($sub_tab){
371
-    if($sub_tab=='custom_fields'){
372
-        geodir_custom_available_fields('predefined');
373
-    }
371
+	if($sub_tab=='custom_fields'){
372
+		geodir_custom_available_fields('predefined');
373
+	}
374 374
 }
375 375
 
376 376
 function geodir_manage_available_fields_custom($sub_tab){
377
-    if($sub_tab=='custom_fields'){
378
-        geodir_custom_available_fields('custom');
379
-    }
377
+	if($sub_tab=='custom_fields'){
378
+		geodir_custom_available_fields('custom');
379
+	}
380 380
 }
381 381
 
382 382
 
@@ -395,16 +395,16 @@  discard block
 block discarded – undo
395 395
 function geodir_manage_available_fields($sub_tab)
396 396
 {
397 397
 
398
-    switch ($sub_tab) {
399
-        case 'custom_fields':
400
-            geodir_custom_available_fields();
401
-            break;
398
+	switch ($sub_tab) {
399
+		case 'custom_fields':
400
+			geodir_custom_available_fields();
401
+			break;
402 402
 
403
-        case 'sorting_options':
404
-            geodir_sorting_options_available_fields();
405
-            break;
403
+		case 'sorting_options':
404
+			geodir_sorting_options_available_fields();
405
+			break;
406 406
 
407
-    }
407
+	}
408 408
 }
409 409
 
410 410
 
@@ -420,16 +420,16 @@  discard block
 block discarded – undo
420 420
 function geodir_manage_selected_fields($sub_tab)
421 421
 {
422 422
 
423
-    switch ($sub_tab) {
424
-        case 'custom_fields':
425
-            geodir_custom_selected_fields();
426
-            break;
423
+	switch ($sub_tab) {
424
+		case 'custom_fields':
425
+			geodir_custom_selected_fields();
426
+			break;
427 427
 
428
-        case 'sorting_options':
429
-            geodir_sorting_options_selected_fields();
430
-            break;
428
+		case 'sorting_options':
429
+			geodir_sorting_options_selected_fields();
430
+			break;
431 431
 
432
-    }
432
+	}
433 433
 }
434 434
 
435 435
 /**
@@ -441,52 +441,52 @@  discard block
 block discarded – undo
441 441
  */
442 442
 function geodir_sorting_options_available_fields()
443 443
 {
444
-    global $wpdb;
445
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
446
-    ?>
444
+	global $wpdb;
445
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
446
+	?>
447 447
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
448 448
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
449 449
     <ul>
450 450
     <?php
451
-        $sort_options = geodir_get_custom_sort_options($listing_type);
451
+		$sort_options = geodir_get_custom_sort_options($listing_type);
452 452
         
453
-        foreach ($sort_options as $key => $val) {
454
-            $val = stripslashes_deep($val); // strip slashes
455
-
456
-            $check_html_variable = $wpdb->get_var(
457
-                $wpdb->prepare(
458
-                    "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
459
-                    array($val['htmlvar_name'], $listing_type, $val['field_type'])
460
-                )
461
-            );
453
+		foreach ($sort_options as $key => $val) {
454
+			$val = stripslashes_deep($val); // strip slashes
455
+
456
+			$check_html_variable = $wpdb->get_var(
457
+				$wpdb->prepare(
458
+					"SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
459
+					array($val['htmlvar_name'], $listing_type, $val['field_type'])
460
+				)
461
+			);
462 462
             
463
-            $display = $check_html_variable ? ' style="display:none;"' : '';
464
-           ?>
463
+			$display = $check_html_variable ? ' style="display:none;"' : '';
464
+		   ?>
465 465
 
466 466
             <li   class="gd-cf-tooltip-wrap" <?php echo $display;?>>
467 467
                 <?php
468
-                if(isset($val['description']) && $val['description']){
469
-                    echo '<div class="gdcf-tooltip">'.$val['description'].'</div>';
470
-                }?>
468
+				if(isset($val['description']) && $val['description']){
469
+					echo '<div class="gdcf-tooltip">'.$val['description'].'</div>';
470
+				}?>
471 471
 
472 472
                 <a id="gd-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" data-field-type-key="<?php echo $val['htmlvar_name'];?>"  data-field-type="<?php echo $val['field_type'];?>"
473 473
                    title="<?php echo $val['site_title'];?>"
474 474
                    class="gd-draggable-form-items  gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);">
475 475
                     <?php if (isset($val['field_icon']) && strpos($val['field_icon'], 'fa fa-') !== false) {
476
-                        echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>';
477
-                    }elseif(isset($val['field_icon']) && $val['field_icon'] ){
478
-                        echo '<b class="gd-cf-icon" style="background-image: url(\''.$val['field_icon'].'\')"></b>';
479
-                    }else{
480
-                        echo '<i class="fa fa-cog" aria-hidden="true"></i>';
481
-                    }?>
476
+						echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>';
477
+					}elseif(isset($val['field_icon']) && $val['field_icon'] ){
478
+						echo '<b class="gd-cf-icon" style="background-image: url(\''.$val['field_icon'].'\')"></b>';
479
+					}else{
480
+						echo '<i class="fa fa-cog" aria-hidden="true"></i>';
481
+					}?>
482 482
                     <?php echo (! empty( $val['admin_title'] ) ? $val['admin_title'] : $val['site_title'] );?>
483 483
                 </a>
484 484
             </li>
485 485
 
486 486
 
487 487
             <?php
488
-        }
489
-    ?>
488
+		}
489
+	?>
490 490
     </ul>
491 491
     <?php
492 492
 }
@@ -500,28 +500,28 @@  discard block
 block discarded – undo
500 500
  */
501 501
 function geodir_sorting_options_selected_fields()
502 502
 {
503
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
504
-    ?>
503
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
504
+	?>
505 505
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
506 506
     <ul class="core">
507 507
     <?php 
508
-        global $wpdb;
508
+		global $wpdb;
509 509
         
510
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
510
+		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
511 511
 
512
-        if (!empty($fields)) {
513
-            foreach ($fields as $field) {
514
-                //$result_str = $field->id;
515
-                $result_str = $field;
516
-                $field_type = $field->field_type;
517
-                $field_ins_upd = 'display';
512
+		if (!empty($fields)) {
513
+			foreach ($fields as $field) {
514
+				//$result_str = $field->id;
515
+				$result_str = $field;
516
+				$field_type = $field->field_type;
517
+				$field_ins_upd = 'display';
518 518
 
519
-                $default = false;
519
+				$default = false;
520 520
 
521
-                geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
522
-            }
523
-        }
524
-    ?>
521
+				geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
522
+			}
523
+		}
524
+	?>
525 525
     </ul>
526 526
     <?php
527 527
 }
@@ -534,12 +534,12 @@  discard block
 block discarded – undo
534 534
  */
535 535
 function geodir_custom_fields_custom($post_type=''){
536 536
 
537
-    $custom_fields = array();
537
+	$custom_fields = array();
538 538
 
539
-    /**
540
-     * @see `geodir_custom_fields`
541
-     */
542
-    return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
539
+	/**
540
+	 * @see `geodir_custom_fields`
541
+	 */
542
+	return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
543 543
 }
544 544
 
545 545
 
@@ -552,140 +552,140 @@  discard block
 block discarded – undo
552 552
  */
553 553
 function geodir_custom_fields($post_type=''){
554 554
     
555
-    $custom_fields = array(
556
-        'text' => array(
557
-            'field_type'  =>  'text',
558
-            'class' =>  'gd-text',
559
-            'icon'  =>  'fa fa-minus',
560
-            'name'  =>  __('Text', 'geodirectory'),
561
-            'description' =>  __('Add any sort of text field, text or numbers', 'geodirectory')
562
-        ),
563
-        'datepicker' => array(
564
-            'field_type'  =>  'datepicker',
565
-            'class' =>  'gd-datepicker',
566
-            'icon'  =>  'fa fa-calendar',
567
-            'name'  =>  __('Date', 'geodirectory'),
568
-            'description' =>  __('Adds a date picker.', 'geodirectory')
569
-        ),
570
-        'textarea' => array(
571
-            'field_type'  =>  'textarea',
572
-            'class' =>  'gd-textarea',
573
-            'icon'  =>  'fa fa-bars',
574
-            'name'  =>  __('Textarea', 'geodirectory'),
575
-            'description' =>  __('Adds a textarea', 'geodirectory')
576
-        ),
577
-        'time' => array(
578
-            'field_type'  =>  'time',
579
-            'class' =>  'gd-time',
580
-            'icon' =>  'fa fa-clock-o',
581
-            'name'  =>  __('Time', 'geodirectory'),
582
-            'description' =>  __('Adds a time picker', 'geodirectory')
583
-        ),
584
-        'checkbox' => array(
585
-            'field_type'  =>  'checkbox',
586
-            'class' =>  'gd-checkbox',
587
-            'icon' =>  'fa fa-check-square-o',
588
-            'name'  =>  __('Checkbox', 'geodirectory'),
589
-            'description' =>  __('Adds a checkbox', 'geodirectory')
590
-        ),
591
-        'phone' => array(
592
-            'field_type'  =>  'phone',
593
-            'class' =>  'gd-phone',
594
-            'icon' =>  'fa fa-phone',
595
-            'name'  =>  __('Phone', 'geodirectory'),
596
-            'description' =>  __('Adds a phone input', 'geodirectory')
597
-        ),
598
-        'radio' => array(
599
-            'field_type'  =>  'radio',
600
-            'class' =>  'gd-radio',
601
-            'icon' =>  'fa fa-dot-circle-o',
602
-            'name'  =>  __('Radio', 'geodirectory'),
603
-            'description' =>  __('Adds a radio input', 'geodirectory')
604
-        ),
605
-        'email' => array(
606
-            'field_type'  =>  'email',
607
-            'class' =>  'gd-email',
608
-            'icon' =>  'fa fa-envelope-o',
609
-            'name'  =>  __('Email', 'geodirectory'),
610
-            'description' =>  __('Adds a email input', 'geodirectory')
611
-        ),
612
-        'select' => array(
613
-            'field_type'  =>  'select',
614
-            'class' =>  'gd-select',
615
-            'icon' =>  'fa fa-caret-square-o-down',
616
-            'name'  =>  __('Select', 'geodirectory'),
617
-            'description' =>  __('Adds a select input', 'geodirectory')
618
-        ),
619
-        'multiselect' => array(
620
-            'field_type'  =>  'multiselect',
621
-            'class' =>  'gd-multiselect',
622
-            'icon' =>  'fa fa-caret-square-o-down',
623
-            'name'  =>  __('Multi Select', 'geodirectory'),
624
-            'description' =>  __('Adds a multiselect input', 'geodirectory')
625
-        ),
626
-        'url' => array(
627
-            'field_type'  =>  'url',
628
-            'class' =>  'gd-url',
629
-            'icon' =>  'fa fa-link',
630
-            'name'  =>  __('URL', 'geodirectory'),
631
-            'description' =>  __('Adds a url input', 'geodirectory')
632
-        ),
633
-        'html' => array(
634
-            'field_type'  =>  'html',
635
-            'class' =>  'gd-html',
636
-            'icon' =>  'fa fa-code',
637
-            'name'  =>  __('HTML', 'geodirectory'),
638
-            'description' =>  __('Adds a html input textarea', 'geodirectory')
639
-        ),
640
-        'file' => array(
641
-            'field_type'  =>  'file',
642
-            'class' =>  'gd-file',
643
-            'icon' =>  'fa fa-file',
644
-            'name'  =>  __('File Upload', 'geodirectory'),
645
-            'description' =>  __('Adds a file input', 'geodirectory')
646
-        )
647
-    );
648
-
649
-    /**
650
-     * Filter the custom fields array to be able to add or remove items.
651
-     * 
652
-     * @since 1.6.6
653
-     *
654
-     * @param array $custom_fields {
655
-     *     The custom fields array to be filtered.
656
-     *
657
-     *     @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file.
658
-     *     @type string $class The class for the field in backend.
659
-     *     @type string $icon Can be font-awesome class name or icon image url.
660
-     *     @type string $name The name of the field.
661
-     *     @type string $description A short description about the field.
662
-     *     @type array $defaults {
663
-     *                    Optional. Used to set the default value of the field.
664
-     *
665
-     *                    @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE
666
-     *                    @type int decimal_point limit if using FLOAT data_type
667
-     *                    @type string admin_title The admin title for the field.
668
-     *                    @type string site_title This will be the title for the field on the frontend.
669
-     *                    @type string admin_desc This will be shown below the field on the add listing form.
670
-     *                    @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.
671
-     *                    @type bool is_active If false the field will not be displayed anywhere.
672
-     *                    @type bool for_admin_use If true then only site admin can see and edit this field.
673
-     *                    @type string default_value The default value for the input on the add listing page.
674
-     *                    @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble]
675
-     *                    @type bool is_required If true the field will be required on the add listing page.
676
-     *                    @type string option_values The option values for select and multiselect only
677
-     *                    @type string validation_pattern HTML5 validation pattern (text input only by default).
678
-     *                    @type string validation_msg HTML5 validation message (text input only by default).
679
-     *                    @type string required_msg Required warning message.
680
-     *                    @type string field_icon Icon url or font awesome class.
681
-     *                    @type string css_class Field custom css class for field custom style.
682
-     *                    @type bool cat_sort If true the field will appear in the category sort options, if false the field will be hidden, leave blank to show option.
683
-     *                    @type bool cat_sort If true the field will appear in the advanced search sort options, if false the field will be hidden, leave blank to show option. (advanced search addon required)
684
-     *     }
685
-     * }
686
-     * @param string $post_type The post type requested.
687
-     */
688
-    return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
555
+	$custom_fields = array(
556
+		'text' => array(
557
+			'field_type'  =>  'text',
558
+			'class' =>  'gd-text',
559
+			'icon'  =>  'fa fa-minus',
560
+			'name'  =>  __('Text', 'geodirectory'),
561
+			'description' =>  __('Add any sort of text field, text or numbers', 'geodirectory')
562
+		),
563
+		'datepicker' => array(
564
+			'field_type'  =>  'datepicker',
565
+			'class' =>  'gd-datepicker',
566
+			'icon'  =>  'fa fa-calendar',
567
+			'name'  =>  __('Date', 'geodirectory'),
568
+			'description' =>  __('Adds a date picker.', 'geodirectory')
569
+		),
570
+		'textarea' => array(
571
+			'field_type'  =>  'textarea',
572
+			'class' =>  'gd-textarea',
573
+			'icon'  =>  'fa fa-bars',
574
+			'name'  =>  __('Textarea', 'geodirectory'),
575
+			'description' =>  __('Adds a textarea', 'geodirectory')
576
+		),
577
+		'time' => array(
578
+			'field_type'  =>  'time',
579
+			'class' =>  'gd-time',
580
+			'icon' =>  'fa fa-clock-o',
581
+			'name'  =>  __('Time', 'geodirectory'),
582
+			'description' =>  __('Adds a time picker', 'geodirectory')
583
+		),
584
+		'checkbox' => array(
585
+			'field_type'  =>  'checkbox',
586
+			'class' =>  'gd-checkbox',
587
+			'icon' =>  'fa fa-check-square-o',
588
+			'name'  =>  __('Checkbox', 'geodirectory'),
589
+			'description' =>  __('Adds a checkbox', 'geodirectory')
590
+		),
591
+		'phone' => array(
592
+			'field_type'  =>  'phone',
593
+			'class' =>  'gd-phone',
594
+			'icon' =>  'fa fa-phone',
595
+			'name'  =>  __('Phone', 'geodirectory'),
596
+			'description' =>  __('Adds a phone input', 'geodirectory')
597
+		),
598
+		'radio' => array(
599
+			'field_type'  =>  'radio',
600
+			'class' =>  'gd-radio',
601
+			'icon' =>  'fa fa-dot-circle-o',
602
+			'name'  =>  __('Radio', 'geodirectory'),
603
+			'description' =>  __('Adds a radio input', 'geodirectory')
604
+		),
605
+		'email' => array(
606
+			'field_type'  =>  'email',
607
+			'class' =>  'gd-email',
608
+			'icon' =>  'fa fa-envelope-o',
609
+			'name'  =>  __('Email', 'geodirectory'),
610
+			'description' =>  __('Adds a email input', 'geodirectory')
611
+		),
612
+		'select' => array(
613
+			'field_type'  =>  'select',
614
+			'class' =>  'gd-select',
615
+			'icon' =>  'fa fa-caret-square-o-down',
616
+			'name'  =>  __('Select', 'geodirectory'),
617
+			'description' =>  __('Adds a select input', 'geodirectory')
618
+		),
619
+		'multiselect' => array(
620
+			'field_type'  =>  'multiselect',
621
+			'class' =>  'gd-multiselect',
622
+			'icon' =>  'fa fa-caret-square-o-down',
623
+			'name'  =>  __('Multi Select', 'geodirectory'),
624
+			'description' =>  __('Adds a multiselect input', 'geodirectory')
625
+		),
626
+		'url' => array(
627
+			'field_type'  =>  'url',
628
+			'class' =>  'gd-url',
629
+			'icon' =>  'fa fa-link',
630
+			'name'  =>  __('URL', 'geodirectory'),
631
+			'description' =>  __('Adds a url input', 'geodirectory')
632
+		),
633
+		'html' => array(
634
+			'field_type'  =>  'html',
635
+			'class' =>  'gd-html',
636
+			'icon' =>  'fa fa-code',
637
+			'name'  =>  __('HTML', 'geodirectory'),
638
+			'description' =>  __('Adds a html input textarea', 'geodirectory')
639
+		),
640
+		'file' => array(
641
+			'field_type'  =>  'file',
642
+			'class' =>  'gd-file',
643
+			'icon' =>  'fa fa-file',
644
+			'name'  =>  __('File Upload', 'geodirectory'),
645
+			'description' =>  __('Adds a file input', 'geodirectory')
646
+		)
647
+	);
648
+
649
+	/**
650
+	 * Filter the custom fields array to be able to add or remove items.
651
+	 * 
652
+	 * @since 1.6.6
653
+	 *
654
+	 * @param array $custom_fields {
655
+	 *     The custom fields array to be filtered.
656
+	 *
657
+	 *     @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file.
658
+	 *     @type string $class The class for the field in backend.
659
+	 *     @type string $icon Can be font-awesome class name or icon image url.
660
+	 *     @type string $name The name of the field.
661
+	 *     @type string $description A short description about the field.
662
+	 *     @type array $defaults {
663
+	 *                    Optional. Used to set the default value of the field.
664
+	 *
665
+	 *                    @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE
666
+	 *                    @type int decimal_point limit if using FLOAT data_type
667
+	 *                    @type string admin_title The admin title for the field.
668
+	 *                    @type string site_title This will be the title for the field on the frontend.
669
+	 *                    @type string admin_desc This will be shown below the field on the add listing form.
670
+	 *                    @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.
671
+	 *                    @type bool is_active If false the field will not be displayed anywhere.
672
+	 *                    @type bool for_admin_use If true then only site admin can see and edit this field.
673
+	 *                    @type string default_value The default value for the input on the add listing page.
674
+	 *                    @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble]
675
+	 *                    @type bool is_required If true the field will be required on the add listing page.
676
+	 *                    @type string option_values The option values for select and multiselect only
677
+	 *                    @type string validation_pattern HTML5 validation pattern (text input only by default).
678
+	 *                    @type string validation_msg HTML5 validation message (text input only by default).
679
+	 *                    @type string required_msg Required warning message.
680
+	 *                    @type string field_icon Icon url or font awesome class.
681
+	 *                    @type string css_class Field custom css class for field custom style.
682
+	 *                    @type bool cat_sort If true the field will appear in the category sort options, if false the field will be hidden, leave blank to show option.
683
+	 *                    @type bool cat_sort If true the field will appear in the advanced search sort options, if false the field will be hidden, leave blank to show option. (advanced search addon required)
684
+	 *     }
685
+	 * }
686
+	 * @param string $post_type The post type requested.
687
+	 */
688
+	return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
689 689
 }
690 690
 
691 691
 /**
@@ -698,19 +698,19 @@  discard block
 block discarded – undo
698 698
  */
699 699
 function geodir_custom_available_fields($type='')
700 700
 {
701
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
702
-    ?>
701
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
702
+	?>
703 703
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
704 704
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" />
705 705
 
706 706
         <?php
707
-        if($type=='predefined'){
708
-            $cfs = geodir_custom_fields_predefined($listing_type);
709
-        }elseif($type=='custom'){
710
-            $cfs = geodir_custom_fields_custom($listing_type);
711
-        }else{
712
-            $cfs = geodir_custom_fields($listing_type);
713
-            ?>
707
+		if($type=='predefined'){
708
+			$cfs = geodir_custom_fields_predefined($listing_type);
709
+		}elseif($type=='custom'){
710
+			$cfs = geodir_custom_fields_custom($listing_type);
711
+		}else{
712
+			$cfs = geodir_custom_fields($listing_type);
713
+			?>
714 714
             <ul class="full gd-cf-tooltip-wrap">
715 715
                 <li>
716 716
                     <div class="gdcf-tooltip">
@@ -731,18 +731,18 @@  discard block
 block discarded – undo
731 731
             </ul>
732 732
 
733 733
             <?php
734
-        }
734
+		}
735 735
 
736
-    if(!empty($cfs)) {
737
-        echo '<ul>';
738
-        foreach ( $cfs as $id => $cf ) {
739
-            ?>
736
+	if(!empty($cfs)) {
737
+		echo '<ul>';
738
+		foreach ( $cfs as $id => $cf ) {
739
+			?>
740 740
 
741 741
             <li class="gd-cf-tooltip-wrap">
742 742
                 <?php
743
-                if ( isset( $cf['description'] ) && $cf['description'] ) {
744
-                    echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>';
745
-                } ?>
743
+				if ( isset( $cf['description'] ) && $cf['description'] ) {
744
+					echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>';
745
+				} ?>
746 746
 
747 747
                 <a id="gd-<?php echo $id; ?>"
748 748
                    data-field-custom-type="<?php echo $type; ?>"
@@ -752,21 +752,21 @@  discard block
 block discarded – undo
752 752
                    href="javascript:void(0);">
753 753
 
754 754
                     <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], 'fa fa-' ) !== false ) {
755
-                        echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>';
756
-                    } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
757
-                        echo '<b class="gd-cf-icon" style="background-image: url(\'' . $cf['icon'] . '\')"></b>';
758
-                    } else {
759
-                        echo '<i class="fa fa-cog" aria-hidden="true"></i>';
760
-                    } ?>
755
+						echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>';
756
+					} elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
757
+						echo '<b class="gd-cf-icon" style="background-image: url(\'' . $cf['icon'] . '\')"></b>';
758
+					} else {
759
+						echo '<i class="fa fa-cog" aria-hidden="true"></i>';
760
+					} ?>
761 761
                     <?php echo $cf['name']; ?>
762 762
                 </a>
763 763
             </li>
764 764
             <?php
765
-        }
766
-    }else{
767
-        _e('There are no custom fields here yet.', 'geodirectory');
768
-    }
769
-        ?>
765
+		}
766
+	}else{
767
+		_e('There are no custom fields here yet.', 'geodirectory');
768
+	}
769
+		?>
770 770
 
771 771
 
772 772
     </ul>
@@ -785,26 +785,26 @@  discard block
 block discarded – undo
785 785
  */
786 786
 function geodir_custom_selected_fields()
787 787
 {
788
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
789
-    ?>
788
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
789
+	?>
790 790
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
791 791
     <ul class="core">
792 792
     <?php 
793
-        global $wpdb;
794
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
795
-
796
-        if (!empty($fields)) {
797
-            foreach ($fields as $field) {
798
-                //$result_str = $field->id;
799
-                $result_str = $field;
800
-                $field_type = $field->field_type;
801
-                $field_type_key = $field->field_type_key;
802
-                $field_ins_upd = 'display';
803
-
804
-                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key);
805
-            }
806
-        }
807
-        ?></ul>
793
+		global $wpdb;
794
+		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
795
+
796
+		if (!empty($fields)) {
797
+			foreach ($fields as $field) {
798
+				//$result_str = $field->id;
799
+				$result_str = $field;
800
+				$field_type = $field->field_type;
801
+				$field_type_key = $field->field_type_key;
802
+				$field_ins_upd = 'display';
803
+
804
+				geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key);
805
+			}
806
+		}
807
+		?></ul>
808 808
 <?php
809 809
 
810 810
 }
@@ -823,16 +823,16 @@  discard block
 block discarded – undo
823 823
 function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type)
824 824
 {
825 825
 
826
-    switch ($sub_tab) {
827
-        case 'custom_fields':
828
-            $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
829
-            break;
826
+	switch ($sub_tab) {
827
+		case 'custom_fields':
828
+			$heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
829
+			break;
830 830
 
831
-        case 'sorting_options':
832
-            $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
833
-            break;
834
-    }
835
-    return $heading;
831
+		case 'sorting_options':
832
+			$heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
833
+			break;
834
+	}
835
+	return $heading;
836 836
 }
837 837
 
838 838
 
@@ -850,16 +850,16 @@  discard block
 block discarded – undo
850 850
 function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type)
851 851
 {
852 852
 
853
-    switch ($sub_tab) {
854
-        case 'custom_fields':
855
-            $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
856
-            break;
853
+	switch ($sub_tab) {
854
+		case 'custom_fields':
855
+			$heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
856
+			break;
857 857
 
858
-        case 'sorting_options':
859
-            $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
860
-            break;
861
-    }
862
-    return $heading;
858
+		case 'sorting_options':
859
+			$heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
860
+			break;
861
+	}
862
+	return $heading;
863 863
 }
864 864
 
865 865
 
@@ -877,16 +877,16 @@  discard block
 block discarded – undo
877 877
 function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type)
878 878
 {
879 879
 
880
-    switch ($sub_tab) {
881
-        case 'custom_fields':
882
-            $note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
883
-            break;
880
+	switch ($sub_tab) {
881
+		case 'custom_fields':
882
+			$note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
883
+			break;
884 884
 
885
-        case 'sorting_options':
886
-            $note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing page.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
887
-            break;
888
-    }
889
-    return $note;
885
+		case 'sorting_options':
886
+			$note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing page.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
887
+			break;
888
+	}
889
+	return $note;
890 890
 }
891 891
 
892 892
 
@@ -904,16 +904,16 @@  discard block
 block discarded – undo
904 904
 function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type)
905 905
 {
906 906
 
907
-    switch ($sub_tab) {
908
-        case 'custom_fields':
909
-            $heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
910
-            break;
907
+	switch ($sub_tab) {
908
+		case 'custom_fields':
909
+			$heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
910
+			break;
911 911
 
912
-        case 'sorting_options':
913
-            $heading = sprintf(__('List of fields that will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
914
-            break;
915
-    }
916
-    return $heading;
912
+		case 'sorting_options':
913
+			$heading = sprintf(__('List of fields that will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
914
+			break;
915
+	}
916
+	return $heading;
917 917
 }
918 918
 
919 919
 
@@ -931,16 +931,16 @@  discard block
 block discarded – undo
931 931
 function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type)
932 932
 {
933 933
 
934
-    switch ($sub_tab) {
935
-        case 'custom_fields':
936
-            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
937
-            break;
934
+	switch ($sub_tab) {
935
+		case 'custom_fields':
936
+			$note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
937
+			break;
938 938
 
939
-        case 'sorting_options':
940
-            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing page.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
941
-            break;
942
-    }
943
-    return $note;
939
+		case 'sorting_options':
940
+			$note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing page.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
941
+			break;
942
+	}
943
+	return $note;
944 944
 }
945 945
 
946 946
 
@@ -956,16 +956,16 @@  discard block
 block discarded – undo
956 956
  */
957 957
 function geodir_remove_unnecessary_fields()
958 958
 {
959
-    global $wpdb, $plugin_prefix;
959
+	global $wpdb, $plugin_prefix;
960 960
 
961
-    if (!get_option('geodir_remove_unnecessary_fields')) {
961
+	if (!get_option('geodir_remove_unnecessary_fields')) {
962 962
 
963
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
964
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
963
+		if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
964
+			$wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
965 965
 
966
-        update_option('geodir_remove_unnecessary_fields', '1');
966
+		update_option('geodir_remove_unnecessary_fields', '1');
967 967
 
968
-    }
968
+	}
969 969
 
970 970
 }
971 971
 
@@ -983,28 +983,28 @@  discard block
 block discarded – undo
983 983
  */
984 984
 function geodir_admin_ajax_handler()
985 985
 {
986
-    if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
987
-        $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
988
-        $diagnose_this = "";
989
-        switch ($geodir_admin_ajax_action) {
990
-            case 'diagnosis' :
991
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
992
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
993
-                    call_user_func('geodir_diagnose_' . $diagnose_this);
994
-
995
-                }
996
-                exit();
997
-                break;
998
-
999
-            case 'diagnosis-fix' :
1000
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
1001
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
1002
-                call_user_func('geodir_diagnose_' . $diagnose_this);
1003
-                exit();
1004
-                break;
1005
-        }
1006
-    }
1007
-    exit();
986
+	if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
987
+		$geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
988
+		$diagnose_this = "";
989
+		switch ($geodir_admin_ajax_action) {
990
+			case 'diagnosis' :
991
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
992
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
993
+					call_user_func('geodir_diagnose_' . $diagnose_this);
994
+
995
+				}
996
+				exit();
997
+				break;
998
+
999
+			case 'diagnosis-fix' :
1000
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
1001
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
1002
+				call_user_func('geodir_diagnose_' . $diagnose_this);
1003
+				exit();
1004
+				break;
1005
+		}
1006
+	}
1007
+	exit();
1008 1008
 }
1009 1009
 
1010 1010
 
@@ -1022,127 +1022,127 @@  discard block
 block discarded – undo
1022 1022
  */
1023 1023
 function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix)
1024 1024
 {
1025
-    global $wpdb;
1026
-    //$filter_arr['output_str'] .='###'.$table.'###';
1027
-    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
1028
-        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
1029
-        $filter_arr['is_error_during_diagnose'] = true;
1030
-
1031
-    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1032
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
1033
-        $filter_arr['is_error_during_diagnose'] = true;
1034
-        $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
1035
-        $filter_arr['is_error_during_diagnose'] = true;
1036
-
1037
-        if ($fix) {
1038
-            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
1039
-            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
1040
-
1041
-            if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
1042
-                //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
1043
-
1044
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
1045
-
1046
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1047
-                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
1048
-                } else {
1049
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1050
-                }
1051
-
1052
-            } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
1053
-
1054
-                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
1055
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
1056
-
1057
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1058
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
1059
-                } else {
1060
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1061
-                }
1062
-
1063
-            } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
1064
-
1065
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
1066
-
1067
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1068
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
1069
-                } else {
1070
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1071
-                }
1072
-
1073
-            }
1074
-
1075
-        }
1076
-
1077
-
1078
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1079
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
1080
-        $filter_arr['is_error_during_diagnose'] = true;
1081
-
1082
-        if ($fix) {
1083
-            if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
1084
-                if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
1085
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
1086
-                } else {
1087
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
1088
-                }
1089
-
1090
-            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
1091
-                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
1092
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1093
-                } else {
1094
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1095
-                }
1096
-                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1097
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1098
-                } else {
1099
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1100
-                }
1101
-            } else {// else rename the original table to _ms_bak
1102
-                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1103
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1104
-                } else {
1105
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1106
-                }
1107
-            }
1108
-        }
1109
-
1110
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1111
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
1112
-        $filter_arr['is_error_during_diagnose'] = true;
1113
-
1114
-        if ($fix) {
1115
-            // if original table exists but new does not, rename
1116
-            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1117
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1118
-            } else {
1119
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1120
-            }
1121
-
1122
-        }
1123
-
1124
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1125
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
1126
-        $filter_arr['is_error_during_diagnose'] = true;
1127
-
1128
-        if ($fix) {
1129
-            // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
1130
-            delete_option('geodirlocation_db_version');
1131
-            delete_option('geodirevents_db_version');
1132
-            delete_option('geodir_reviewrating_db_version');
1133
-            delete_option('gdevents_db_version');
1134
-            delete_option('geodirectory_db_version');
1135
-            delete_option('geodirclaim_db_version');
1136
-            delete_option('geodir_custom_posts_db_version');
1137
-            delete_option('geodir_reviewratings_db_version');
1138
-            delete_option('geodiradvancesearch_db_version');
1139
-            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
1140
-        }
1141
-
1142
-    } else {
1143
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
1144
-    }
1145
-    return $filter_arr;
1025
+	global $wpdb;
1026
+	//$filter_arr['output_str'] .='###'.$table.'###';
1027
+	if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
1028
+		$filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
1029
+		$filter_arr['is_error_during_diagnose'] = true;
1030
+
1031
+	} elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1032
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
1033
+		$filter_arr['is_error_during_diagnose'] = true;
1034
+		$filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
1035
+		$filter_arr['is_error_during_diagnose'] = true;
1036
+
1037
+		if ($fix) {
1038
+			$ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
1039
+			$new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
1040
+
1041
+			if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
1042
+				//$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
1043
+
1044
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
1045
+
1046
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1047
+					$filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
1048
+				} else {
1049
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1050
+				}
1051
+
1052
+			} elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
1053
+
1054
+				$wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
1055
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
1056
+
1057
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1058
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
1059
+				} else {
1060
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1061
+				}
1062
+
1063
+			} elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
1064
+
1065
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
1066
+
1067
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1068
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
1069
+				} else {
1070
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1071
+				}
1072
+
1073
+			}
1074
+
1075
+		}
1076
+
1077
+
1078
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1079
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
1080
+		$filter_arr['is_error_during_diagnose'] = true;
1081
+
1082
+		if ($fix) {
1083
+			if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
1084
+				if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
1085
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
1086
+				} else {
1087
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
1088
+				}
1089
+
1090
+			} elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
1091
+				if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
1092
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1093
+				} else {
1094
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1095
+				}
1096
+				if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1097
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1098
+				} else {
1099
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1100
+				}
1101
+			} else {// else rename the original table to _ms_bak
1102
+				if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1103
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1104
+				} else {
1105
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1106
+				}
1107
+			}
1108
+		}
1109
+
1110
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1111
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
1112
+		$filter_arr['is_error_during_diagnose'] = true;
1113
+
1114
+		if ($fix) {
1115
+			// if original table exists but new does not, rename
1116
+			if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1117
+				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1118
+			} else {
1119
+				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1120
+			}
1121
+
1122
+		}
1123
+
1124
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1125
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
1126
+		$filter_arr['is_error_during_diagnose'] = true;
1127
+
1128
+		if ($fix) {
1129
+			// if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
1130
+			delete_option('geodirlocation_db_version');
1131
+			delete_option('geodirevents_db_version');
1132
+			delete_option('geodir_reviewrating_db_version');
1133
+			delete_option('gdevents_db_version');
1134
+			delete_option('geodirectory_db_version');
1135
+			delete_option('geodirclaim_db_version');
1136
+			delete_option('geodir_custom_posts_db_version');
1137
+			delete_option('geodir_reviewratings_db_version');
1138
+			delete_option('geodiradvancesearch_db_version');
1139
+			$filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
1140
+		}
1141
+
1142
+	} else {
1143
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
1144
+	}
1145
+	return $filter_arr;
1146 1146
 }
1147 1147
 
1148 1148
 
@@ -1156,111 +1156,111 @@  discard block
 block discarded – undo
1156 1156
  */
1157 1157
 function geodir_diagnose_tags_sync()
1158 1158
 {
1159
-    global $wpdb, $plugin_prefix;
1160
-    $fix = isset($_POST['fix']) ? true : false;
1161
-    $step = isset($_POST['step']) ? strip_tags(esc_sql($_POST['step'])) : 0;
1162
-    $step_max_items = geodir_get_diagnose_step_max_items();
1163
-    $offset = (int) $step * $step_max_items;
1164
-    $ptype = isset($_POST['ptype']) ? strip_tags(esc_sql($_POST['ptype'])) : false;
1165
-
1166
-    $total_listings = geodir_total_listings_count();
1167
-    $total_ptype_listings = 0;
1168
-    if ($ptype) {
1169
-        $total_ptype_listings = geodir_total_listings_count($ptype);
1170
-    }
1171
-    $max_step = ceil($total_ptype_listings / $step_max_items) - 1;
1159
+	global $wpdb, $plugin_prefix;
1160
+	$fix = isset($_POST['fix']) ? true : false;
1161
+	$step = isset($_POST['step']) ? strip_tags(esc_sql($_POST['step'])) : 0;
1162
+	$step_max_items = geodir_get_diagnose_step_max_items();
1163
+	$offset = (int) $step * $step_max_items;
1164
+	$ptype = isset($_POST['ptype']) ? strip_tags(esc_sql($_POST['ptype'])) : false;
1165
+
1166
+	$total_listings = geodir_total_listings_count();
1167
+	$total_ptype_listings = 0;
1168
+	if ($ptype) {
1169
+		$total_ptype_listings = geodir_total_listings_count($ptype);
1170
+	}
1171
+	$max_step = ceil($total_ptype_listings / $step_max_items) - 1;
1172 1172
     
1173
-    //if($fix){echo 'true';}else{echo 'false';}
1174
-    $is_error_during_diagnose = false;
1175
-    $output_str = '';
1173
+	//if($fix){echo 'true';}else{echo 'false';}
1174
+	$is_error_during_diagnose = false;
1175
+	$output_str = '';
1176 1176
     
1177
-    if ($ptype && !empty($ptype) && $total_listings > $step_max_items) {
1178
-        $stepped_process = true;
1179
-    } else {
1180
-        $stepped_process = false;
1181
-    }
1182
-
1183
-    if ($stepped_process) {
1184
-        $sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset );
1185
-        $posts = $wpdb->get_results( $sql );
1186
-
1187
-        if (!empty($posts)) {
1188
-
1189
-            foreach ($posts as $p) {
1190
-                $p->post_type = $ptype;
1191
-                $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1192
-                if (empty($raw_tags)) {
1193
-                    $post_tags = '';
1194
-                } else {
1195
-                    $post_tags = implode(",", $raw_tags);
1196
-                }
1197
-                $tablename = $plugin_prefix . $p->post_type . '_detail';
1198
-                $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1199
-
1200
-            }
1201
-            if ($step >= $max_step) {
1202
-                $output_str = "done";    
1203
-            } else {
1204
-                $output_str = $step + 1;
1205
-            }
1206
-        }
1207
-
1208
-    } else {
1209
-        $all_postypes = geodir_get_posttypes();
1210
-
1211
-        if (!empty($all_postypes)) {
1212
-            foreach ($all_postypes as $key) {
1213
-                // update each GD CPT
1214
-                $posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail");
1215
-
1216
-                if (!empty($posts)) {
1217
-
1218
-                    foreach ($posts as $p) {
1219
-                        $p->post_type = $key;
1220
-                        $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1221
-                        if (empty($raw_tags)) {
1222
-                            $post_tags = '';
1223
-                        } else {
1224
-                            $post_tags = implode(",", $raw_tags);
1225
-                        }
1226
-                        $tablename = $plugin_prefix . $p->post_type . '_detail';
1227
-                        $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1228
-
1229
-                    }
1230
-                    $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1231
-                }
1232
-
1233
-            }
1234
-
1235
-        }
1236
-    }
1237
-
1238
-
1239
-    if ($is_error_during_diagnose) {
1240
-        $info_div_class = "geodir_problem_info";
1241
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1242
-    } else {
1243
-        $info_div_class = "geodir_noproblem_info";
1244
-        $fix_button_txt = '';
1245
-    }
1246
-
1247
-    if ($stepped_process) {
1248
-        $percent = ($step/$max_step) * 100;
1249
-        if ($output_str == 'done') {
1250
-            echo $output_str;
1251
-        } else {
1252
-            $output = array(
1253
-                'step' => $output_str,
1254
-                'percent' => $percent
1255
-            );
1256
-            echo json_encode($output);
1257
-        }
1258
-    } else {
1259
-        echo "<ul class='$info_div_class'>";
1260
-        echo $output_str;
1261
-        echo $fix_button_txt;
1262
-        echo "</ul>";
1263
-    }
1177
+	if ($ptype && !empty($ptype) && $total_listings > $step_max_items) {
1178
+		$stepped_process = true;
1179
+	} else {
1180
+		$stepped_process = false;
1181
+	}
1182
+
1183
+	if ($stepped_process) {
1184
+		$sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset );
1185
+		$posts = $wpdb->get_results( $sql );
1186
+
1187
+		if (!empty($posts)) {
1188
+
1189
+			foreach ($posts as $p) {
1190
+				$p->post_type = $ptype;
1191
+				$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1192
+				if (empty($raw_tags)) {
1193
+					$post_tags = '';
1194
+				} else {
1195
+					$post_tags = implode(",", $raw_tags);
1196
+				}
1197
+				$tablename = $plugin_prefix . $p->post_type . '_detail';
1198
+				$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1199
+
1200
+			}
1201
+			if ($step >= $max_step) {
1202
+				$output_str = "done";    
1203
+			} else {
1204
+				$output_str = $step + 1;
1205
+			}
1206
+		}
1207
+
1208
+	} else {
1209
+		$all_postypes = geodir_get_posttypes();
1210
+
1211
+		if (!empty($all_postypes)) {
1212
+			foreach ($all_postypes as $key) {
1213
+				// update each GD CPT
1214
+				$posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail");
1215
+
1216
+				if (!empty($posts)) {
1217
+
1218
+					foreach ($posts as $p) {
1219
+						$p->post_type = $key;
1220
+						$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1221
+						if (empty($raw_tags)) {
1222
+							$post_tags = '';
1223
+						} else {
1224
+							$post_tags = implode(",", $raw_tags);
1225
+						}
1226
+						$tablename = $plugin_prefix . $p->post_type . '_detail';
1227
+						$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1228
+
1229
+					}
1230
+					$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1231
+				}
1232
+
1233
+			}
1234
+
1235
+		}
1236
+	}
1237
+
1238
+
1239
+	if ($is_error_during_diagnose) {
1240
+		$info_div_class = "geodir_problem_info";
1241
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1242
+	} else {
1243
+		$info_div_class = "geodir_noproblem_info";
1244
+		$fix_button_txt = '';
1245
+	}
1246
+
1247
+	if ($stepped_process) {
1248
+		$percent = ($step/$max_step) * 100;
1249
+		if ($output_str == 'done') {
1250
+			echo $output_str;
1251
+		} else {
1252
+			$output = array(
1253
+				'step' => $output_str,
1254
+				'percent' => $percent
1255
+			);
1256
+			echo json_encode($output);
1257
+		}
1258
+	} else {
1259
+		echo "<ul class='$info_div_class'>";
1260
+		echo $output_str;
1261
+		echo $fix_button_txt;
1262
+		echo "</ul>";
1263
+	}
1264 1264
 }
1265 1265
 
1266 1266
 /**
@@ -1275,75 +1275,75 @@  discard block
 block discarded – undo
1275 1275
  */
1276 1276
 function geodir_diagnose_cats_sync()
1277 1277
 {
1278
-    global $wpdb, $plugin_prefix;
1279
-    $fix = isset($_POST['fix']) ? true : false;
1278
+	global $wpdb, $plugin_prefix;
1279
+	$fix = isset($_POST['fix']) ? true : false;
1280 1280
 
1281
-    //if($fix){echo 'true';}else{echo 'false';}
1282
-    $is_error_during_diagnose = false;
1283
-    $output_str = '';
1281
+	//if($fix){echo 'true';}else{echo 'false';}
1282
+	$is_error_during_diagnose = false;
1283
+	$output_str = '';
1284 1284
 
1285 1285
 
1286
-    $all_postypes = geodir_get_posttypes();
1286
+	$all_postypes = geodir_get_posttypes();
1287 1287
 
1288
-    if (!empty($all_postypes)) {
1289
-        foreach ($all_postypes as $key) {
1290
-            // update each GD CTP
1291
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
1288
+	if (!empty($all_postypes)) {
1289
+		foreach ($all_postypes as $key) {
1290
+			// update each GD CTP
1291
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
1292 1292
 
1293
-            if (!empty($posts)) {
1293
+			if (!empty($posts)) {
1294 1294
 
1295
-                foreach ($posts as $p) {
1296
-                    $p->post_type = $key;
1297
-                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
1295
+				foreach ($posts as $p) {
1296
+					$p->post_type = $key;
1297
+					$raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
1298 1298
 
1299
-                    if (empty($raw_cats)) {
1300
-                        $post_categories = get_post_meta($p->post_id, 'post_categories', true);
1299
+					if (empty($raw_cats)) {
1300
+						$post_categories = get_post_meta($p->post_id, 'post_categories', true);
1301 1301
 
1302
-                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1303
-                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1304
-                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1305
-                                if (is_numeric($cat_part)) {
1306
-                                    $raw_cats[] = (int)$cat_part;
1307
-                                }
1308
-                            }
1302
+						if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1303
+							$post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1304
+							foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1305
+								if (is_numeric($cat_part)) {
1306
+									$raw_cats[] = (int)$cat_part;
1307
+								}
1308
+							}
1309 1309
 
1310
-                        }
1310
+						}
1311 1311
 
1312
-                        if (!empty($raw_cats)) {
1313
-                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1312
+						if (!empty($raw_cats)) {
1313
+							$term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1314 1314
 
1315
-                        }
1315
+						}
1316 1316
 
1317
-                    }
1317
+					}
1318 1318
 
1319 1319
 
1320
-                    if (empty($raw_cats)) {
1321
-                        $post_cats = '';
1322
-                    } else {
1323
-                        $post_cats = ',' . implode(",", $raw_cats) . ',';
1324
-                    }
1325
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1326
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1327
-                }
1320
+					if (empty($raw_cats)) {
1321
+						$post_cats = '';
1322
+					} else {
1323
+						$post_cats = ',' . implode(",", $raw_cats) . ',';
1324
+					}
1325
+					$tablename = $plugin_prefix . $p->post_type . '_detail';
1326
+					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1327
+				}
1328 1328
 
1329
-            }
1330
-            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1329
+			}
1330
+			$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1331 1331
 
1332
-        }
1332
+		}
1333 1333
 
1334
-    }
1334
+	}
1335 1335
 
1336
-    if ($is_error_during_diagnose) {
1337
-        $info_div_class = "geodir_problem_info";
1338
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1339
-    } else {
1340
-        $info_div_class = "geodir_noproblem_info";
1341
-        $fix_button_txt = '';
1342
-    }
1343
-    echo "<ul class='$info_div_class'>";
1344
-    echo $output_str;
1345
-    echo $fix_button_txt;
1346
-    echo "</ul>";
1336
+	if ($is_error_during_diagnose) {
1337
+		$info_div_class = "geodir_problem_info";
1338
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1339
+	} else {
1340
+		$info_div_class = "geodir_noproblem_info";
1341
+		$fix_button_txt = '';
1342
+	}
1343
+	echo "<ul class='$info_div_class'>";
1344
+	echo $output_str;
1345
+	echo $fix_button_txt;
1346
+	echo "</ul>";
1347 1347
 
1348 1348
 }
1349 1349
 
@@ -1357,61 +1357,61 @@  discard block
 block discarded – undo
1357 1357
  */
1358 1358
 function geodir_diagnose_version_clear()
1359 1359
 {
1360
-    global $wpdb, $plugin_prefix;
1361
-    $fix = isset($_POST['fix']) ? true : false;
1362
-
1363
-    //if($fix){echo 'true';}else{echo 'false';}
1364
-    $is_error_during_diagnose = false;
1365
-    $output_str = '';
1366
-
1367
-
1368
-    $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1369
-        'Payment Manager' => 'geodir_payments_db_version',
1370
-        'GeoDirectory Framework' => 'gdf_db_version',
1371
-        'Advanced Search' => 'geodiradvancesearch_db_version',
1372
-        'Review Rating Manager' => 'geodir_reviewratings_db_version',
1373
-        'Claim Manager' => 'geodirclaim_db_version',
1374
-        'CPT Manager' => 'geodir_custom_posts_db_version',
1375
-        'Location Manager' => 'geodirlocation_db_version',
1376
-        'Payment Manager' => 'geodir_payments_db_version',
1377
-        'Events Manager' => 'geodirevents_db_version',
1378
-    );
1379
-
1380
-    /**
1381
-     * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1382
-     *
1383
-     * @since 1.0.0
1384
-     * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1385
-     */
1386
-    $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1387
-
1388
-    if (!empty($ver_arr)) {
1389
-        foreach ($ver_arr as $key => $val) {
1390
-            if (delete_option($val)) {
1391
-                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1392
-            } else {
1393
-                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1394
-            }
1395
-
1396
-        }
1397
-
1398
-        if ($output_str) {
1399
-            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1400
-        }
1401
-
1402
-    }
1403
-
1404
-    if ($is_error_during_diagnose) {
1405
-        $info_div_class = "geodir_problem_info";
1406
-        $fix_button_txt = "";
1407
-    } else {
1408
-        $info_div_class = "geodir_noproblem_info";
1409
-        $fix_button_txt = '';
1410
-    }
1411
-    echo "<ul class='$info_div_class'>";
1412
-    echo $output_str;
1413
-    echo $fix_button_txt;
1414
-    echo "</ul>";
1360
+	global $wpdb, $plugin_prefix;
1361
+	$fix = isset($_POST['fix']) ? true : false;
1362
+
1363
+	//if($fix){echo 'true';}else{echo 'false';}
1364
+	$is_error_during_diagnose = false;
1365
+	$output_str = '';
1366
+
1367
+
1368
+	$gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1369
+		'Payment Manager' => 'geodir_payments_db_version',
1370
+		'GeoDirectory Framework' => 'gdf_db_version',
1371
+		'Advanced Search' => 'geodiradvancesearch_db_version',
1372
+		'Review Rating Manager' => 'geodir_reviewratings_db_version',
1373
+		'Claim Manager' => 'geodirclaim_db_version',
1374
+		'CPT Manager' => 'geodir_custom_posts_db_version',
1375
+		'Location Manager' => 'geodirlocation_db_version',
1376
+		'Payment Manager' => 'geodir_payments_db_version',
1377
+		'Events Manager' => 'geodirevents_db_version',
1378
+	);
1379
+
1380
+	/**
1381
+	 * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1382
+	 *
1383
+	 * @since 1.0.0
1384
+	 * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1385
+	 */
1386
+	$ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1387
+
1388
+	if (!empty($ver_arr)) {
1389
+		foreach ($ver_arr as $key => $val) {
1390
+			if (delete_option($val)) {
1391
+				$output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1392
+			} else {
1393
+				$output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1394
+			}
1395
+
1396
+		}
1397
+
1398
+		if ($output_str) {
1399
+			$output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1400
+		}
1401
+
1402
+	}
1403
+
1404
+	if ($is_error_during_diagnose) {
1405
+		$info_div_class = "geodir_problem_info";
1406
+		$fix_button_txt = "";
1407
+	} else {
1408
+		$info_div_class = "geodir_noproblem_info";
1409
+		$fix_button_txt = '';
1410
+	}
1411
+	echo "<ul class='$info_div_class'>";
1412
+	echo $output_str;
1413
+	echo $fix_button_txt;
1414
+	echo "</ul>";
1415 1415
 
1416 1416
 }
1417 1417
 
@@ -1425,59 +1425,59 @@  discard block
 block discarded – undo
1425 1425
  */
1426 1426
 function geodir_diagnose_ratings()
1427 1427
 {
1428
-    global $wpdb;
1429
-    $fix = isset($_POST['fix']) ? true : false;
1430
-
1431
-    //if($fix){echo 'true';}else{echo 'false';}
1432
-    $is_error_during_diagnose = false;
1433
-    $output_str = '';
1434
-
1435
-    // check review locations
1436
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
1437
-        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1438
-        $is_error_during_diagnose = true;
1439
-
1440
-        if ($fix) {
1441
-            if (geodir_fix_review_location()) {
1442
-                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1443
-            } else {
1444
-                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1445
-            }
1446
-        }
1447
-
1448
-    } else {
1449
-        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1450
-    }
1451
-
1452
-    // check review content
1453
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1454
-        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1455
-        $is_error_during_diagnose = true;
1456
-
1457
-        if ($fix) {
1458
-            if (geodir_fix_review_content()) {
1459
-                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1460
-            } else {
1461
-                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1462
-            }
1463
-        }
1464
-
1465
-    } else {
1466
-        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1467
-    }
1468
-
1469
-
1470
-    if ($is_error_during_diagnose) {
1471
-        $info_div_class = "geodir_problem_info";
1472
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1473
-    } else {
1474
-        $info_div_class = "geodir_noproblem_info";
1475
-        $fix_button_txt = '';
1476
-    }
1477
-    echo "<ul class='$info_div_class'>";
1478
-    echo $output_str;
1479
-    echo $fix_button_txt;
1480
-    echo "</ul>";
1428
+	global $wpdb;
1429
+	$fix = isset($_POST['fix']) ? true : false;
1430
+
1431
+	//if($fix){echo 'true';}else{echo 'false';}
1432
+	$is_error_during_diagnose = false;
1433
+	$output_str = '';
1434
+
1435
+	// check review locations
1436
+	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
1437
+		$output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1438
+		$is_error_during_diagnose = true;
1439
+
1440
+		if ($fix) {
1441
+			if (geodir_fix_review_location()) {
1442
+				$output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1443
+			} else {
1444
+				$output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1445
+			}
1446
+		}
1447
+
1448
+	} else {
1449
+		$output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1450
+	}
1451
+
1452
+	// check review content
1453
+	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1454
+		$output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1455
+		$is_error_during_diagnose = true;
1456
+
1457
+		if ($fix) {
1458
+			if (geodir_fix_review_content()) {
1459
+				$output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1460
+			} else {
1461
+				$output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1462
+			}
1463
+		}
1464
+
1465
+	} else {
1466
+		$output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1467
+	}
1468
+
1469
+
1470
+	if ($is_error_during_diagnose) {
1471
+		$info_div_class = "geodir_problem_info";
1472
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1473
+	} else {
1474
+		$info_div_class = "geodir_noproblem_info";
1475
+		$fix_button_txt = '';
1476
+	}
1477
+	echo "<ul class='$info_div_class'>";
1478
+	echo $output_str;
1479
+	echo $fix_button_txt;
1480
+	echo "</ul>";
1481 1481
 
1482 1482
 }
1483 1483
 
@@ -1491,57 +1491,57 @@  discard block
 block discarded – undo
1491 1491
  */
1492 1492
 function geodir_diagnose_multisite_conversion()
1493 1493
 {
1494
-    global $wpdb;
1495
-    $fix = isset($_POST['fix']) ? true : false;
1496
-    //if($fix){echo 'true';}else{echo 'false';}
1497
-    $is_error_during_diagnose = false;
1498
-    $output_str = '';
1499
-
1500
-    $filter_arr = array();
1501
-    $filter_arr['output_str'] = $output_str;
1502
-    $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1503
-    $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1504
-        'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1505
-        'geodir_post_icon' => __('Post icon', 'geodirectory'),
1506
-        'geodir_attachments' => __('Attachments', 'geodirectory'),
1507
-        'geodir_post_review' => __('Reviews', 'geodirectory'),
1508
-        'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1509
-        'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1510
-    );
1511
-
1512
-    // allow other addons to hook in and add their checks
1513
-
1514
-    /**
1515
-     * Filter the array of tables.
1516
-     *
1517
-     * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks.
1518
-     *
1519
-     * @since 1.0.0
1520
-     * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1521
-     */
1522
-    $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1523
-
1524
-    foreach ($table_arr as $table => $table_name) {
1525
-        // Diagnose table
1526
-        $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1527
-    }
1528
-
1529
-
1530
-    $output_str = $filter_arr['output_str'];
1531
-    $is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1532
-
1533
-
1534
-    if ($is_error_during_diagnose) {
1535
-        $info_div_class = "geodir_problem_info";
1536
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1537
-    } else {
1538
-        $info_div_class = "geodir_noproblem_info";
1539
-        $fix_button_txt = '';
1540
-    }
1541
-    echo "<ul class='$info_div_class'>";
1542
-    echo $output_str;
1543
-    echo $fix_button_txt;
1544
-    echo "</ul>";
1494
+	global $wpdb;
1495
+	$fix = isset($_POST['fix']) ? true : false;
1496
+	//if($fix){echo 'true';}else{echo 'false';}
1497
+	$is_error_during_diagnose = false;
1498
+	$output_str = '';
1499
+
1500
+	$filter_arr = array();
1501
+	$filter_arr['output_str'] = $output_str;
1502
+	$filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1503
+	$table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1504
+		'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1505
+		'geodir_post_icon' => __('Post icon', 'geodirectory'),
1506
+		'geodir_attachments' => __('Attachments', 'geodirectory'),
1507
+		'geodir_post_review' => __('Reviews', 'geodirectory'),
1508
+		'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1509
+		'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1510
+	);
1511
+
1512
+	// allow other addons to hook in and add their checks
1513
+
1514
+	/**
1515
+	 * Filter the array of tables.
1516
+	 *
1517
+	 * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks.
1518
+	 *
1519
+	 * @since 1.0.0
1520
+	 * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1521
+	 */
1522
+	$table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1523
+
1524
+	foreach ($table_arr as $table => $table_name) {
1525
+		// Diagnose table
1526
+		$filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1527
+	}
1528
+
1529
+
1530
+	$output_str = $filter_arr['output_str'];
1531
+	$is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1532
+
1533
+
1534
+	if ($is_error_during_diagnose) {
1535
+		$info_div_class = "geodir_problem_info";
1536
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1537
+	} else {
1538
+		$info_div_class = "geodir_noproblem_info";
1539
+		$fix_button_txt = '';
1540
+	}
1541
+	echo "<ul class='$info_div_class'>";
1542
+	echo $output_str;
1543
+	echo $fix_button_txt;
1544
+	echo "</ul>";
1545 1545
 }
1546 1546
 
1547 1547
 /**
@@ -1559,39 +1559,39 @@  discard block
 block discarded – undo
1559 1559
  */
1560 1560
 function geodir_fix_virtual_page($slug, $page_title, $old_id, $option)
1561 1561
 {
1562
-    global $wpdb, $current_user;
1563
-
1564
-    if (!empty($old_id)) {
1565
-        wp_delete_post($old_id, true);
1566
-    }//delete post if already there
1567
-    else {
1568
-        $page_found = $wpdb->get_var(
1569
-            $wpdb->prepare(
1570
-                "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1571
-                array($slug)
1572
-            )
1573
-        );
1574
-        wp_delete_post($page_found, true);
1575
-
1576
-    }
1577
-
1578
-    $page_data = array(
1579
-        'post_status' => 'publish',
1580
-        'post_type' => 'page',
1581
-        'post_author' => $current_user->ID,
1582
-        'post_name' => $slug,
1583
-        'post_title' => $page_title,
1584
-        'post_content' => '',
1585
-        'post_parent' => 0,
1586
-        'comment_status' => 'closed'
1587
-    );
1588
-    $page_id = wp_insert_post($page_data);
1589
-    update_option($option, $page_id);
1590
-    if ($page_id) {
1591
-        return true;
1592
-    } else {
1593
-        return false;
1594
-    }
1562
+	global $wpdb, $current_user;
1563
+
1564
+	if (!empty($old_id)) {
1565
+		wp_delete_post($old_id, true);
1566
+	}//delete post if already there
1567
+	else {
1568
+		$page_found = $wpdb->get_var(
1569
+			$wpdb->prepare(
1570
+				"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1571
+				array($slug)
1572
+			)
1573
+		);
1574
+		wp_delete_post($page_found, true);
1575
+
1576
+	}
1577
+
1578
+	$page_data = array(
1579
+		'post_status' => 'publish',
1580
+		'post_type' => 'page',
1581
+		'post_author' => $current_user->ID,
1582
+		'post_name' => $slug,
1583
+		'post_title' => $page_title,
1584
+		'post_content' => '',
1585
+		'post_parent' => 0,
1586
+		'comment_status' => 'closed'
1587
+	);
1588
+	$page_id = wp_insert_post($page_data);
1589
+	update_option($option, $page_id);
1590
+	if ($page_id) {
1591
+		return true;
1592
+	} else {
1593
+		return false;
1594
+	}
1595 1595
 }
1596 1596
 
1597 1597
 /**
@@ -1603,212 +1603,212 @@  discard block
 block discarded – undo
1603 1603
  */
1604 1604
 function geodir_diagnose_default_pages()
1605 1605
 {
1606
-    global $wpdb;
1607
-    $is_error_during_diagnose = false;
1608
-    $output_str = '';
1609
-    $fix = isset($_POST['fix']) ? true : false;
1610
-
1611
-    //////////////////////////////////
1612
-    /* Diagnose GD Home Page Starts */
1613
-    //////////////////////////////////
1614
-    $option_value = get_option('geodir_home_page');
1615
-    $page = get_post($option_value);
1616
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1617
-
1618
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1619
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1620
-    else {
1621
-        $is_error_during_diagnose = true;
1622
-        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1623
-        if ($fix) {
1624
-            if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1625
-                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1626
-            } else {
1627
-                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1628
-            }
1629
-        }
1630
-    }
1631
-
1632
-    ////////////////////////////////
1633
-    /* Diagnose GD Home Page Ends */
1634
-    ////////////////////////////////
1635
-
1636
-    //////////////////////////////////
1637
-    /* Diagnose Add Listing Page Starts */
1638
-    //////////////////////////////////
1639
-    $option_value = get_option('geodir_add_listing_page');
1640
-    $page = get_post($option_value);
1641
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1642
-
1643
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1644
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1645
-    else {
1646
-        $is_error_during_diagnose = true;
1647
-        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1648
-        if ($fix) {
1649
-            if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1650
-                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1651
-            } else {
1652
-                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1653
-            }
1654
-        }
1655
-    }
1656
-
1657
-    ////////////////////////////////
1658
-    /* Diagnose Add Listing Page Ends */
1659
-    ////////////////////////////////
1660
-
1661
-
1662
-    //////////////////////////////////
1663
-    /* Diagnose Listing Preview Page Starts */
1664
-    //////////////////////////////////
1665
-    $option_value = get_option('geodir_preview_page');
1666
-    $page = get_post($option_value);
1667
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1668
-
1669
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1670
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1671
-    else {
1672
-        $is_error_during_diagnose = true;
1673
-        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1674
-        if ($fix) {
1675
-            if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1676
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1677
-            } else {
1678
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1679
-            }
1680
-        }
1681
-    }
1682
-
1683
-    ////////////////////////////////
1684
-    /* Diagnose Listing Preview Page Ends */
1685
-    ////////////////////////////////
1686
-
1687
-    //////////////////////////////////
1688
-    /* Diagnose Listing Success Page Starts */
1689
-    //////////////////////////////////
1690
-    $option_value = get_option('geodir_success_page');
1691
-    $page = get_post($option_value);
1692
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1693
-
1694
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1695
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1696
-    else {
1697
-        $is_error_during_diagnose = true;
1698
-        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1699
-        if ($fix) {
1700
-            if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1701
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1702
-            } else {
1703
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1704
-            }
1705
-        }
1706
-    }
1707
-
1708
-    ////////////////////////////////
1709
-    /* Diagnose Listing Sucess Page Ends */
1710
-    ////////////////////////////////
1711
-
1712
-    //////////////////////////////////
1713
-    /* Diagnose Info Page Starts */
1714
-    //////////////////////////////////
1715
-    $option_value = get_option('geodir_info_page');
1716
-    $page = get_post($option_value);
1717
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1718
-
1719
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1720
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1721
-    else {
1722
-        $is_error_during_diagnose = true;
1723
-        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1724
-        if ($fix) {
1725
-            if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1726
-                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1727
-            } else {
1728
-                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1729
-            }
1730
-        }
1731
-    }
1732
-
1733
-    ////////////////////////////////
1734
-    /* Diagnose Info Page Ends */
1735
-    ////////////////////////////////
1736
-
1737
-    //////////////////////////////////
1738
-    /* Diagnose Login Page Starts */
1739
-    //////////////////////////////////
1740
-    $option_value = get_option('geodir_login_page');
1741
-    $page = get_post($option_value);
1742
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1743
-
1744
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1745
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1746
-    else {
1747
-        $is_error_during_diagnose = true;
1748
-        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1749
-        if ($fix) {
1750
-            if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1751
-                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1752
-            } else {
1753
-                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1754
-            }
1755
-        }
1756
-    }
1757
-
1758
-    ////////////////////////////////
1759
-    /* Diagnose Info Page Ends */
1760
-    ////////////////////////////////
1761
-
1762
-    //////////////////////////////////
1763
-    /* Diagnose Location Page Starts */
1764
-    //////////////////////////////////
1765
-    $option_value = get_option('geodir_location_page');
1766
-    $page = get_post($option_value);
1767
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1768
-
1769
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1770
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1771
-    else {
1772
-        $is_error_during_diagnose = true;
1773
-        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1774
-        if ($fix) {
1775
-            if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1776
-                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1777
-            } else {
1778
-                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1779
-            }
1780
-        }
1781
-    }
1782
-
1783
-    ////////////////////////////////
1784
-    /* Diagnose Location Page Ends */
1785
-    ////////////////////////////////
1786
-
1787
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1788
-    /**
1789
-     * This action is called at the end of the GD Tools page check function.
1790
-     *
1791
-     * @since 1.5.2
1792
-     */
1793
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1794
-
1795
-    $output_str = $page_chk_arr['output_str'];
1796
-    $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1797
-
1798
-    if ($is_error_during_diagnose) {
1799
-        if ($fix) {
1800
-            flush_rewrite_rules();
1801
-        }
1802
-        $info_div_class = "geodir_problem_info";
1803
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1804
-    } else {
1805
-        $info_div_class = "geodir_noproblem_info";
1806
-        $fix_button_txt = '';
1807
-    }
1808
-    echo "<ul class='$info_div_class'>";
1809
-    echo $output_str;
1810
-    echo $fix_button_txt;
1811
-    echo "</ul>";
1606
+	global $wpdb;
1607
+	$is_error_during_diagnose = false;
1608
+	$output_str = '';
1609
+	$fix = isset($_POST['fix']) ? true : false;
1610
+
1611
+	//////////////////////////////////
1612
+	/* Diagnose GD Home Page Starts */
1613
+	//////////////////////////////////
1614
+	$option_value = get_option('geodir_home_page');
1615
+	$page = get_post($option_value);
1616
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1617
+
1618
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1619
+		$output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1620
+	else {
1621
+		$is_error_during_diagnose = true;
1622
+		$output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1623
+		if ($fix) {
1624
+			if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1625
+				$output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1626
+			} else {
1627
+				$output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1628
+			}
1629
+		}
1630
+	}
1631
+
1632
+	////////////////////////////////
1633
+	/* Diagnose GD Home Page Ends */
1634
+	////////////////////////////////
1635
+
1636
+	//////////////////////////////////
1637
+	/* Diagnose Add Listing Page Starts */
1638
+	//////////////////////////////////
1639
+	$option_value = get_option('geodir_add_listing_page');
1640
+	$page = get_post($option_value);
1641
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1642
+
1643
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1644
+		$output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1645
+	else {
1646
+		$is_error_during_diagnose = true;
1647
+		$output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1648
+		if ($fix) {
1649
+			if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1650
+				$output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1651
+			} else {
1652
+				$output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1653
+			}
1654
+		}
1655
+	}
1656
+
1657
+	////////////////////////////////
1658
+	/* Diagnose Add Listing Page Ends */
1659
+	////////////////////////////////
1660
+
1661
+
1662
+	//////////////////////////////////
1663
+	/* Diagnose Listing Preview Page Starts */
1664
+	//////////////////////////////////
1665
+	$option_value = get_option('geodir_preview_page');
1666
+	$page = get_post($option_value);
1667
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1668
+
1669
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1670
+		$output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1671
+	else {
1672
+		$is_error_during_diagnose = true;
1673
+		$output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1674
+		if ($fix) {
1675
+			if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1676
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1677
+			} else {
1678
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1679
+			}
1680
+		}
1681
+	}
1682
+
1683
+	////////////////////////////////
1684
+	/* Diagnose Listing Preview Page Ends */
1685
+	////////////////////////////////
1686
+
1687
+	//////////////////////////////////
1688
+	/* Diagnose Listing Success Page Starts */
1689
+	//////////////////////////////////
1690
+	$option_value = get_option('geodir_success_page');
1691
+	$page = get_post($option_value);
1692
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1693
+
1694
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1695
+		$output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1696
+	else {
1697
+		$is_error_during_diagnose = true;
1698
+		$output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1699
+		if ($fix) {
1700
+			if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1701
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1702
+			} else {
1703
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1704
+			}
1705
+		}
1706
+	}
1707
+
1708
+	////////////////////////////////
1709
+	/* Diagnose Listing Sucess Page Ends */
1710
+	////////////////////////////////
1711
+
1712
+	//////////////////////////////////
1713
+	/* Diagnose Info Page Starts */
1714
+	//////////////////////////////////
1715
+	$option_value = get_option('geodir_info_page');
1716
+	$page = get_post($option_value);
1717
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1718
+
1719
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1720
+		$output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1721
+	else {
1722
+		$is_error_during_diagnose = true;
1723
+		$output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1724
+		if ($fix) {
1725
+			if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1726
+				$output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1727
+			} else {
1728
+				$output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1729
+			}
1730
+		}
1731
+	}
1732
+
1733
+	////////////////////////////////
1734
+	/* Diagnose Info Page Ends */
1735
+	////////////////////////////////
1736
+
1737
+	//////////////////////////////////
1738
+	/* Diagnose Login Page Starts */
1739
+	//////////////////////////////////
1740
+	$option_value = get_option('geodir_login_page');
1741
+	$page = get_post($option_value);
1742
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1743
+
1744
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1745
+		$output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1746
+	else {
1747
+		$is_error_during_diagnose = true;
1748
+		$output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1749
+		if ($fix) {
1750
+			if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1751
+				$output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1752
+			} else {
1753
+				$output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1754
+			}
1755
+		}
1756
+	}
1757
+
1758
+	////////////////////////////////
1759
+	/* Diagnose Info Page Ends */
1760
+	////////////////////////////////
1761
+
1762
+	//////////////////////////////////
1763
+	/* Diagnose Location Page Starts */
1764
+	//////////////////////////////////
1765
+	$option_value = get_option('geodir_location_page');
1766
+	$page = get_post($option_value);
1767
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1768
+
1769
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1770
+		$output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1771
+	else {
1772
+		$is_error_during_diagnose = true;
1773
+		$output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1774
+		if ($fix) {
1775
+			if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1776
+				$output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1777
+			} else {
1778
+				$output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1779
+			}
1780
+		}
1781
+	}
1782
+
1783
+	////////////////////////////////
1784
+	/* Diagnose Location Page Ends */
1785
+	////////////////////////////////
1786
+
1787
+	$page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1788
+	/**
1789
+	 * This action is called at the end of the GD Tools page check function.
1790
+	 *
1791
+	 * @since 1.5.2
1792
+	 */
1793
+	$page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1794
+
1795
+	$output_str = $page_chk_arr['output_str'];
1796
+	$is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1797
+
1798
+	if ($is_error_during_diagnose) {
1799
+		if ($fix) {
1800
+			flush_rewrite_rules();
1801
+		}
1802
+		$info_div_class = "geodir_problem_info";
1803
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1804
+	} else {
1805
+		$info_div_class = "geodir_noproblem_info";
1806
+		$fix_button_txt = '';
1807
+	}
1808
+	echo "<ul class='$info_div_class'>";
1809
+	echo $output_str;
1810
+	echo $fix_button_txt;
1811
+	echo "</ul>";
1812 1812
 
1813 1813
 }
1814 1814
 
@@ -1820,26 +1820,26 @@  discard block
 block discarded – undo
1820 1820
  * @global object $wpdb WordPress Database object.
1821 1821
  */
1822 1822
 function geodir_diagnose_load_db_language() {
1823
-    global $wpdb;
1823
+	global $wpdb;
1824 1824
 	
1825 1825
 	$is_error_during_diagnose = geodirectory_load_db_language();
1826 1826
 
1827
-    $output_str = '';
1828
-    $fix_button_txt = '';
1827
+	$output_str = '';
1828
+	$fix_button_txt = '';
1829 1829
 
1830
-    if ($is_error_during_diagnose) {
1831
-        $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
1830
+	if ($is_error_during_diagnose) {
1831
+		$output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
1832 1832
 		$info_div_class = "geodir_problem_info";
1833
-    } else {
1834
-        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1833
+	} else {
1834
+		$output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1835 1835
 		$info_div_class = "geodir_noproblem_info";
1836
-        $fix_button_txt = '';
1837
-    }
1836
+		$fix_button_txt = '';
1837
+	}
1838 1838
     
1839 1839
 	echo "<ul class='$info_div_class'>";
1840
-    echo $output_str;
1841
-    echo $fix_button_txt;
1842
-    echo "</ul>";
1840
+	echo $output_str;
1841
+	echo $fix_button_txt;
1842
+	echo "</ul>";
1843 1843
 
1844 1844
 }
1845 1845
 
@@ -1870,23 +1870,23 @@  discard block
 block discarded – undo
1870 1870
  */
1871 1871
 function geodir_posts_clauses_request($clauses)
1872 1872
 {
1873
-    global $wpdb, $wp_query, $plugin_prefix;
1873
+	global $wpdb, $wp_query, $plugin_prefix;
1874 1874
 
1875
-    if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
1876
-        $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1875
+	if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
1876
+		$table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1877 1877
 
1878
-        $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1879
-        $clauses['join'] = $join;
1878
+		$join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1879
+		$clauses['join'] = $join;
1880 1880
 
1881
-        $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1882
-        $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire';
1883
-        $clauses['fields'] = $fields;
1881
+		$fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1882
+		$fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire';
1883
+		$clauses['fields'] = $fields;
1884 1884
 
1885
-        $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1886
-        $orderby = 'gd_expire ' . $order;
1887
-        $clauses['orderby'] = $orderby;
1888
-    }
1889
-    return $clauses;
1885
+		$order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1886
+		$orderby = 'gd_expire ' . $order;
1887
+		$clauses['orderby'] = $orderby;
1888
+	}
1889
+	return $clauses;
1890 1890
 }
1891 1891
 
1892 1892
 
@@ -1907,7 +1907,7 @@  discard block
 block discarded – undo
1907 1907
  */
1908 1908
 function gd_theme_switch_compat_check()
1909 1909
 {
1910
-    gd_set_theme_compat();
1910
+	gd_set_theme_compat();
1911 1911
 }
1912 1912
 
1913 1913
 /**
@@ -1920,27 +1920,27 @@  discard block
 block discarded – undo
1920 1920
  */
1921 1921
 function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\")
1922 1922
 {
1923
-    if (function_exists('str_getcsv')) {
1924
-        $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1925
-    } else {
1926
-        global $current_user;
1927
-        $upload_dir = wp_upload_dir();
1928
-
1929
-        $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1930
-        $handle = fopen($file, 'w');
1931
-
1932
-        fwrite($handle, $input);
1933
-        fclose($handle);
1934
-
1935
-        $handle = fopen($file, 'rt');
1936
-        if (PHP_VERSION >= '5.3.0') {
1937
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1938
-        } else {
1939
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1940
-        }
1941
-        fclose($handle);
1942
-    }
1943
-    return $fgetcsv;
1923
+	if (function_exists('str_getcsv')) {
1924
+		$fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1925
+	} else {
1926
+		global $current_user;
1927
+		$upload_dir = wp_upload_dir();
1928
+
1929
+		$file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1930
+		$handle = fopen($file, 'w');
1931
+
1932
+		fwrite($handle, $input);
1933
+		fclose($handle);
1934
+
1935
+		$handle = fopen($file, 'rt');
1936
+		if (PHP_VERSION >= '5.3.0') {
1937
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1938
+		} else {
1939
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1940
+		}
1941
+		fclose($handle);
1942
+	}
1943
+	return $fgetcsv;
1944 1944
 }
1945 1945
 
1946 1946
 add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv');
@@ -1955,375 +1955,375 @@  discard block
 block discarded – undo
1955 1955
  */
1956 1956
 function geodir_ajax_import_csv()
1957 1957
 {
1958
-    error_reporting(0); // hide error to get clean json response
1958
+	error_reporting(0); // hide error to get clean json response
1959 1959
 
1960
-    global $wpdb, $plugin_prefix, $current_user;
1961
-    $uploads = wp_upload_dir();
1962
-    @ini_set('auto_detect_line_endings', true);
1960
+	global $wpdb, $plugin_prefix, $current_user;
1961
+	$uploads = wp_upload_dir();
1962
+	@ini_set('auto_detect_line_endings', true);
1963 1963
 	
1964 1964
 	$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
1965 1965
 
1966
-    $task = isset($_POST['task']) ? $_POST['task'] : '';
1967
-    $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1968
-    $filename = $uploadedFile;
1969
-
1970
-    $uploads = wp_upload_dir();
1971
-    $uploads_dir = $uploads['path'];
1972
-    $image_name_arr = explode('/', $filename);
1973
-    $filename = end($image_name_arr);
1974
-    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1975
-    $return = array();
1976
-    $return['file'] = $uploadedFile;
1977
-    $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1978
-
1979
-    if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1980
-        $wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1981
-
1982
-        if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1983
-            $return['error'] = NULL;
1984
-
1985
-            $return['rows'] = 0;
1986
-
1987
-
1988
-
1989
-                if (($handle = fopen($target_path, "r")) !== FALSE) {
1990
-                    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1991
-                        if(is_array($data) && !empty($data)) {
1992
-                            $file[] = '"' . implode('","', $data) . '"';
1993
-                        }
1994
-                    }
1995
-                    fclose($handle);
1996
-                    $file = $file;
1997
-                }
1998
-
1999
-
2000
-
2001
-                $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
2002
-
2003
-
2004
-            if (!$return['rows'] > 0) {
2005
-                $return['error'] = __('No data found in csv file.', 'geodirectory');
2006
-            }
2007
-        }
2008
-    }
2009
-    if ($task == 'prepare' || !empty($return['error'])) {
2010
-        echo json_encode($return);
2011
-        exit;
2012
-    }
2013
-
2014
-    $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
2015
-    $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
2016
-    $count = $importlimit;
2017
-    $requested_limit = $importlimit;
2018
-    $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
2019
-
2020
-    if ($count < $totRecords) {
2021
-        $count = $tmpCnt + $count;
2022
-        if ($count > $totRecords) {
2023
-            $count = $totRecords;
2024
-        }
2025
-    } else {
2026
-        $count = $totRecords;
2027
-    }
2028
-
2029
-    $total_records = 0;
2030
-    $rowcount = 0;
2031
-    $address_invalid = 0;
2032
-    $blank_address = 0;
2033
-    $upload_files = 0;
2034
-    $invalid_post_type = 0;
2035
-    $invalid_title = 0;
2036
-    $customKeyarray = array();
2037
-    $gd_post_info = array();
2038
-    $post_location = array();
2039
-    $countpost = 0;
2040
-
2041
-    if (!empty($file)) {
2042
-        $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
2043
-        $customKeyarray = $columns;
2044
-
2045
-        if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
2046
-            $return['error'] = CSV_INVAILD_FILE;
2047
-            echo json_encode($return);
2048
-            exit;
2049
-        }
2050
-
2051
-        for ($i = 1; $i <= $importlimit; $i++) {
2052
-            $current_index = $tmpCnt + $i;
2053
-            if (isset($file[$current_index])) {
2054
-                $total_records++;
2055
-
2056
-                $buffer = geodir_str_getcsv($file[$current_index]);
2057
-                $post_title = addslashes($buffer[0]);
2058
-                $current_post_author = $buffer[1];
2059
-                $post_desc = addslashes($buffer[2]);
2060
-                $post_cat = array();
2061
-                $catids_arr = array();
2062
-                $post_cat = trim($buffer[3]); // comma seperated category name
2063
-
2064
-                if ($post_cat) {
2065
-                    $post_cat_arr = explode(',', $post_cat);
2066
-
2067
-                    for ($c = 0; $c < count($post_cat_arr); $c++) {
2068
-                        $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
2069
-
2070
-                        if (!empty($buffer[5])) {
2071
-                            if (in_array($buffer[5], geodir_get_posttypes())) {
2072
-
2073
-                                $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
2074
-
2075
-                                if (get_term_by('name', $catid, $p_taxonomy[0])) {
2076
-                                    $cat = get_term_by('name', $catid, $p_taxonomy[0]);
2077
-                                    $catids_arr[] = $cat->slug;
2078
-                                } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
2079
-                                    $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2080
-                                    $catids_arr[] = $cat->slug;
2081
-                                } else {
2082
-                                    $ret = wp_insert_term($catid, $p_taxonomy[0]);
2083
-                                    if ($ret && !is_wp_error($ret)) {
2084
-                                        if (get_term_by('name', $catid, $p_taxonomy[0])) {
2085
-                                            $cat = get_term_by('name', $catid, $p_taxonomy[0]);
2086
-                                            $catids_arr[] = $cat->slug;
2087
-                                        } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
2088
-                                            $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2089
-                                            $catids_arr[] = $cat->slug;
2090
-                                        }
2091
-                                    }
2092
-                                }
2093
-                            }
2094
-                        }
2095
-                    }
2096
-                }
2097
-
2098
-                if (!$catids_arr) {
2099
-                    $catids_arr[] = 1;
2100
-                }
2101
-
2102
-                $post_tags = trim($buffer[4]); // comma seperated tags
2103
-
2104
-                $tag_arr = '';
2105
-                if ($post_tags) {
2106
-                    $tag_arr = explode(',', $post_tags);
2107
-                }
2108
-
2109
-                $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
2110
-
2111
-                $error = '';
2112
-                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
2113
-                    $invalid_post_type++;
2114
-                    continue;
2115
-                }
2116
-
2117
-                if ($post_title != '') {
2118
-                    $menu_order = 0;
2119
-                    $image_folder_name = 'uplaod/';
2120
-
2121
-                    $image_names = array();
2122
-
2123
-                    for ($c = 5; $c < count($customKeyarray); $c++) {
2124
-                        $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
2125
-
2126
-                        if ($customKeyarray[$c] == 'IMAGE') {
2127
-                            $buffer[$c] = trim($buffer[$c]);
2128
-
2129
-                            if (!empty($buffer[$c])) {
2130
-                                $image_names[] = $buffer[$c];
2131
-                            }
2132
-                        }
2133
-
2134
-                        if ($customKeyarray[$c] == 'alive_days') {
2135
-                            if ($buffer[$c] != '0' && $buffer[$c] != '') {
2136
-                                $submitdata = date('Y-m-d');
2137
-
2138
-                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
2139
-                            } else {
2140
-                                $gd_post_info['expire_date'] = 'Never';
2141
-                            }
2142
-                        }
2143
-
2144
-                        if ($customKeyarray[$c] == 'post_city') {
2145
-                            $post_city = addslashes($buffer[$c]);
2146
-                        }
2147
-
2148
-                        if ($customKeyarray[$c] == 'post_region') {
2149
-                            $post_region = addslashes($buffer[$c]);
2150
-                        }
2151
-
2152
-                        if ($customKeyarray[$c] == 'post_country') {
2153
-                            $post_country = addslashes($buffer[$c]);
2154
-                        }
2155
-
2156
-                        if ($customKeyarray[$c] == 'post_latitude') {
2157
-                            $post_latitude = addslashes($buffer[$c]);
2158
-                        }
2159
-
2160
-                        if ($customKeyarray[$c] == 'post_longitude') {
2161
-                            $post_longitude = addslashes($buffer[$c]);
2162
-                        }
1966
+	$task = isset($_POST['task']) ? $_POST['task'] : '';
1967
+	$uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1968
+	$filename = $uploadedFile;
1969
+
1970
+	$uploads = wp_upload_dir();
1971
+	$uploads_dir = $uploads['path'];
1972
+	$image_name_arr = explode('/', $filename);
1973
+	$filename = end($image_name_arr);
1974
+	$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1975
+	$return = array();
1976
+	$return['file'] = $uploadedFile;
1977
+	$return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1978
+
1979
+	if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1980
+		$wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1981
+
1982
+		if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1983
+			$return['error'] = NULL;
1984
+
1985
+			$return['rows'] = 0;
1986
+
1987
+
1988
+
1989
+				if (($handle = fopen($target_path, "r")) !== FALSE) {
1990
+					while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1991
+						if(is_array($data) && !empty($data)) {
1992
+							$file[] = '"' . implode('","', $data) . '"';
1993
+						}
1994
+					}
1995
+					fclose($handle);
1996
+					$file = $file;
1997
+				}
1998
+
1999
+
2000
+
2001
+				$return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
2002
+
2003
+
2004
+			if (!$return['rows'] > 0) {
2005
+				$return['error'] = __('No data found in csv file.', 'geodirectory');
2006
+			}
2007
+		}
2008
+	}
2009
+	if ($task == 'prepare' || !empty($return['error'])) {
2010
+		echo json_encode($return);
2011
+		exit;
2012
+	}
2013
+
2014
+	$totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
2015
+	$importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
2016
+	$count = $importlimit;
2017
+	$requested_limit = $importlimit;
2018
+	$tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
2019
+
2020
+	if ($count < $totRecords) {
2021
+		$count = $tmpCnt + $count;
2022
+		if ($count > $totRecords) {
2023
+			$count = $totRecords;
2024
+		}
2025
+	} else {
2026
+		$count = $totRecords;
2027
+	}
2028
+
2029
+	$total_records = 0;
2030
+	$rowcount = 0;
2031
+	$address_invalid = 0;
2032
+	$blank_address = 0;
2033
+	$upload_files = 0;
2034
+	$invalid_post_type = 0;
2035
+	$invalid_title = 0;
2036
+	$customKeyarray = array();
2037
+	$gd_post_info = array();
2038
+	$post_location = array();
2039
+	$countpost = 0;
2040
+
2041
+	if (!empty($file)) {
2042
+		$columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
2043
+		$customKeyarray = $columns;
2044
+
2045
+		if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
2046
+			$return['error'] = CSV_INVAILD_FILE;
2047
+			echo json_encode($return);
2048
+			exit;
2049
+		}
2050
+
2051
+		for ($i = 1; $i <= $importlimit; $i++) {
2052
+			$current_index = $tmpCnt + $i;
2053
+			if (isset($file[$current_index])) {
2054
+				$total_records++;
2055
+
2056
+				$buffer = geodir_str_getcsv($file[$current_index]);
2057
+				$post_title = addslashes($buffer[0]);
2058
+				$current_post_author = $buffer[1];
2059
+				$post_desc = addslashes($buffer[2]);
2060
+				$post_cat = array();
2061
+				$catids_arr = array();
2062
+				$post_cat = trim($buffer[3]); // comma seperated category name
2063
+
2064
+				if ($post_cat) {
2065
+					$post_cat_arr = explode(',', $post_cat);
2066
+
2067
+					for ($c = 0; $c < count($post_cat_arr); $c++) {
2068
+						$catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
2069
+
2070
+						if (!empty($buffer[5])) {
2071
+							if (in_array($buffer[5], geodir_get_posttypes())) {
2072
+
2073
+								$p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
2074
+
2075
+								if (get_term_by('name', $catid, $p_taxonomy[0])) {
2076
+									$cat = get_term_by('name', $catid, $p_taxonomy[0]);
2077
+									$catids_arr[] = $cat->slug;
2078
+								} else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
2079
+									$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2080
+									$catids_arr[] = $cat->slug;
2081
+								} else {
2082
+									$ret = wp_insert_term($catid, $p_taxonomy[0]);
2083
+									if ($ret && !is_wp_error($ret)) {
2084
+										if (get_term_by('name', $catid, $p_taxonomy[0])) {
2085
+											$cat = get_term_by('name', $catid, $p_taxonomy[0]);
2086
+											$catids_arr[] = $cat->slug;
2087
+										} elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
2088
+											$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2089
+											$catids_arr[] = $cat->slug;
2090
+										}
2091
+									}
2092
+								}
2093
+							}
2094
+						}
2095
+					}
2096
+				}
2097
+
2098
+				if (!$catids_arr) {
2099
+					$catids_arr[] = 1;
2100
+				}
2101
+
2102
+				$post_tags = trim($buffer[4]); // comma seperated tags
2103
+
2104
+				$tag_arr = '';
2105
+				if ($post_tags) {
2106
+					$tag_arr = explode(',', $post_tags);
2107
+				}
2108
+
2109
+				$table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
2110
+
2111
+				$error = '';
2112
+				if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
2113
+					$invalid_post_type++;
2114
+					continue;
2115
+				}
2116
+
2117
+				if ($post_title != '') {
2118
+					$menu_order = 0;
2119
+					$image_folder_name = 'uplaod/';
2120
+
2121
+					$image_names = array();
2122
+
2123
+					for ($c = 5; $c < count($customKeyarray); $c++) {
2124
+						$gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
2125
+
2126
+						if ($customKeyarray[$c] == 'IMAGE') {
2127
+							$buffer[$c] = trim($buffer[$c]);
2128
+
2129
+							if (!empty($buffer[$c])) {
2130
+								$image_names[] = $buffer[$c];
2131
+							}
2132
+						}
2133
+
2134
+						if ($customKeyarray[$c] == 'alive_days') {
2135
+							if ($buffer[$c] != '0' && $buffer[$c] != '') {
2136
+								$submitdata = date('Y-m-d');
2137
+
2138
+								$gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
2139
+							} else {
2140
+								$gd_post_info['expire_date'] = 'Never';
2141
+							}
2142
+						}
2143
+
2144
+						if ($customKeyarray[$c] == 'post_city') {
2145
+							$post_city = addslashes($buffer[$c]);
2146
+						}
2147
+
2148
+						if ($customKeyarray[$c] == 'post_region') {
2149
+							$post_region = addslashes($buffer[$c]);
2150
+						}
2151
+
2152
+						if ($customKeyarray[$c] == 'post_country') {
2153
+							$post_country = addslashes($buffer[$c]);
2154
+						}
2155
+
2156
+						if ($customKeyarray[$c] == 'post_latitude') {
2157
+							$post_latitude = addslashes($buffer[$c]);
2158
+						}
2159
+
2160
+						if ($customKeyarray[$c] == 'post_longitude') {
2161
+							$post_longitude = addslashes($buffer[$c]);
2162
+						}
2163 2163
 						
2164 2164
 						// Post status
2165 2165
 						if ($customKeyarray[$c] == 'post_status') {
2166
-                            $post_status = sanitize_key( $buffer[$c] );
2167
-                        }
2168
-                    }
2169
-
2170
-                    /* ================ before array create ============== */
2171
-                    $location_result = geodir_get_default_location();
2172
-                    if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
2173
-                        $blank_address++;
2174
-                        continue;
2175
-                    } else if ($location_result->location_id == 0) {
2176
-                        if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
2177
-                            $address_invalid++;
2178
-                            continue;
2179
-                        }
2180
-                    }
2166
+							$post_status = sanitize_key( $buffer[$c] );
2167
+						}
2168
+					}
2169
+
2170
+					/* ================ before array create ============== */
2171
+					$location_result = geodir_get_default_location();
2172
+					if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
2173
+						$blank_address++;
2174
+						continue;
2175
+					} else if ($location_result->location_id == 0) {
2176
+						if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
2177
+							$address_invalid++;
2178
+							continue;
2179
+						}
2180
+					}
2181 2181
 					
2182 2182
 					// Default post status
2183 2183
 					$default_status = 'publish';
2184 2184
 					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
2185 2185
 					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
2186 2186
 
2187
-                    $my_post['post_title'] = $post_title;
2188
-                    $my_post['post_content'] = $post_desc;
2189
-                    $my_post['post_type'] = addslashes($buffer[5]);
2190
-                    $my_post['post_author'] = $current_post_author;
2191
-                    $my_post['post_status'] = $post_status;
2192
-                    $my_post['post_category'] = $catids_arr;
2193
-                    $my_post['post_tags'] = $tag_arr;
2194
-
2195
-                    $gd_post_info['post_tags'] = $tag_arr;
2196
-                    $gd_post_info['post_title'] = $post_title;
2197
-                    $gd_post_info['post_status'] = $post_status;
2198
-                    $gd_post_info['submit_time'] = time();
2199
-                    $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
2200
-
2201
-                    $last_postid = wp_insert_post($my_post);
2202
-                    $countpost++;
2203
-
2204
-                    // Check if we need to save post location as new location
2205
-                    if ($location_result->location_id > 0) {
2206
-                        if (isset($post_city) && isset($post_region)) {
2207
-                            $request_info['post_location'] = array(
2208
-                                'city' => $post_city,
2209
-                                'region' => $post_region,
2210
-                                'country' => $post_country,
2211
-                                'geo_lat' => $post_latitude,
2212
-                                'geo_lng' => $post_longitude
2213
-                            );
2214
-
2215
-                            $post_location_info = $request_info['post_location'];
2216
-                            if ($location_id = geodir_add_new_location($post_location_info))
2217
-                                $post_location_id = $location_id;
2218
-                        } else {
2219
-                            $post_location_id = 0;
2220
-                        }
2221
-                    } else {
2222
-                        $post_location_id = 0;
2223
-                    }
2224
-
2225
-                    /* ------- get default package info ----- */
2226
-                    $payment_info = array();
2227
-                    $package_info = array();
2228
-
2229
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2230
-                    $package_id = '';
2231
-                    if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2232
-                        $package_id = $gd_post_info['package_id'];
2233
-                    }
2234
-
2235
-                    if (!empty($package_info)) {
2236
-                        $payment_info['package_id'] = $package_info['pid'];
2237
-
2238
-                        if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2239
-                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2240
-                        } else {
2241
-                            $payment_info['expire_date'] = 'Never';
2242
-                        }
2243
-
2244
-                        $gd_post_info = array_merge($gd_post_info, $payment_info);
2245
-                    }
2246
-
2247
-                    $gd_post_info['post_location_id'] = $post_location_id;
2248
-
2249
-                    $post_type = get_post_type($last_postid);
2250
-
2251
-                    $table = $plugin_prefix . $post_type . '_detail';
2252
-
2253
-                    geodir_save_post_info($last_postid, $gd_post_info);
2254
-
2255
-                    if (!empty($image_names)) {
2256
-                        $upload_files++;
2257
-                        $menu_order = 1;
2258
-
2259
-                        foreach ($image_names as $image_name) {
2260
-                            $img_name_arr = explode('.', $image_name);
2261
-
2262
-                            $uploads = wp_upload_dir();
2263
-                            $sub_dir = $uploads['subdir'];
2264
-
2265
-                            $arr_file_type = wp_check_filetype($image_name);
2266
-                            $uploaded_file_type = $arr_file_type['type'];
2267
-
2268
-                            $attachment = array();
2269
-                            $attachment['post_id'] = $last_postid;
2270
-                            $attachment['title'] = $img_name_arr[0];
2271
-                            $attachment['content'] = '';
2272
-                            $attachment['file'] = $sub_dir . '/' . $image_name;
2273
-                            $attachment['mime_type'] = $uploaded_file_type;
2274
-                            $attachment['menu_order'] = $menu_order;
2275
-                            $attachment['is_featured'] = 0;
2276
-
2277
-                            $attachment_set = '';
2278
-
2279
-                            foreach ($attachment as $key => $val) {
2280
-                                if ($val != '')
2281
-                                    $attachment_set .= $key . " = '" . $val . "', ";
2282
-                            }
2283
-                            $attachment_set = trim($attachment_set, ", ");
2284
-
2285
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2286
-
2287
-                            if ($menu_order == 1) {
2288
-                                $post_type = get_post_type($last_postid);
2289
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2290
-                            }
2291
-                            $menu_order++;
2292
-                        }
2293
-                    }
2294
-
2295
-                    $gd_post_info['package_id'] = $package_id;
2296
-
2297
-                    /** This action is documented in geodirectory-functions/post-functions.php */
2298
-                    do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
2299
-
2300
-                    if (!empty($buffer[5])) {
2301
-                        if (in_array($buffer[5], geodir_get_posttypes())) {
2302
-                            $taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2303
-                            wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2304
-                            wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2305
-
2306
-                            $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2307
-                            $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2308
-                            geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2309
-                        }
2310
-                    }
2311
-                } else {
2312
-                    $invalid_title++;
2313
-                }
2314
-            }
2315
-        }
2316
-    }
2317
-    $return['rowcount'] = $countpost;
2318
-    $return['invalidcount'] = $address_invalid;
2319
-    $return['blank_address'] = $blank_address;
2320
-    $return['upload_files'] = $upload_files;
2321
-    $return['invalid_post_type'] = $invalid_post_type;
2322
-    $return['invalid_title'] = $invalid_title;
2323
-    $return['total_records'] = $total_records;
2324
-
2325
-    echo json_encode($return);
2326
-    exit;
2187
+					$my_post['post_title'] = $post_title;
2188
+					$my_post['post_content'] = $post_desc;
2189
+					$my_post['post_type'] = addslashes($buffer[5]);
2190
+					$my_post['post_author'] = $current_post_author;
2191
+					$my_post['post_status'] = $post_status;
2192
+					$my_post['post_category'] = $catids_arr;
2193
+					$my_post['post_tags'] = $tag_arr;
2194
+
2195
+					$gd_post_info['post_tags'] = $tag_arr;
2196
+					$gd_post_info['post_title'] = $post_title;
2197
+					$gd_post_info['post_status'] = $post_status;
2198
+					$gd_post_info['submit_time'] = time();
2199
+					$gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
2200
+
2201
+					$last_postid = wp_insert_post($my_post);
2202
+					$countpost++;
2203
+
2204
+					// Check if we need to save post location as new location
2205
+					if ($location_result->location_id > 0) {
2206
+						if (isset($post_city) && isset($post_region)) {
2207
+							$request_info['post_location'] = array(
2208
+								'city' => $post_city,
2209
+								'region' => $post_region,
2210
+								'country' => $post_country,
2211
+								'geo_lat' => $post_latitude,
2212
+								'geo_lng' => $post_longitude
2213
+							);
2214
+
2215
+							$post_location_info = $request_info['post_location'];
2216
+							if ($location_id = geodir_add_new_location($post_location_info))
2217
+								$post_location_id = $location_id;
2218
+						} else {
2219
+							$post_location_id = 0;
2220
+						}
2221
+					} else {
2222
+						$post_location_id = 0;
2223
+					}
2224
+
2225
+					/* ------- get default package info ----- */
2226
+					$payment_info = array();
2227
+					$package_info = array();
2228
+
2229
+					$package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2230
+					$package_id = '';
2231
+					if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2232
+						$package_id = $gd_post_info['package_id'];
2233
+					}
2234
+
2235
+					if (!empty($package_info)) {
2236
+						$payment_info['package_id'] = $package_info['pid'];
2237
+
2238
+						if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2239
+							$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2240
+						} else {
2241
+							$payment_info['expire_date'] = 'Never';
2242
+						}
2243
+
2244
+						$gd_post_info = array_merge($gd_post_info, $payment_info);
2245
+					}
2246
+
2247
+					$gd_post_info['post_location_id'] = $post_location_id;
2248
+
2249
+					$post_type = get_post_type($last_postid);
2250
+
2251
+					$table = $plugin_prefix . $post_type . '_detail';
2252
+
2253
+					geodir_save_post_info($last_postid, $gd_post_info);
2254
+
2255
+					if (!empty($image_names)) {
2256
+						$upload_files++;
2257
+						$menu_order = 1;
2258
+
2259
+						foreach ($image_names as $image_name) {
2260
+							$img_name_arr = explode('.', $image_name);
2261
+
2262
+							$uploads = wp_upload_dir();
2263
+							$sub_dir = $uploads['subdir'];
2264
+
2265
+							$arr_file_type = wp_check_filetype($image_name);
2266
+							$uploaded_file_type = $arr_file_type['type'];
2267
+
2268
+							$attachment = array();
2269
+							$attachment['post_id'] = $last_postid;
2270
+							$attachment['title'] = $img_name_arr[0];
2271
+							$attachment['content'] = '';
2272
+							$attachment['file'] = $sub_dir . '/' . $image_name;
2273
+							$attachment['mime_type'] = $uploaded_file_type;
2274
+							$attachment['menu_order'] = $menu_order;
2275
+							$attachment['is_featured'] = 0;
2276
+
2277
+							$attachment_set = '';
2278
+
2279
+							foreach ($attachment as $key => $val) {
2280
+								if ($val != '')
2281
+									$attachment_set .= $key . " = '" . $val . "', ";
2282
+							}
2283
+							$attachment_set = trim($attachment_set, ", ");
2284
+
2285
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2286
+
2287
+							if ($menu_order == 1) {
2288
+								$post_type = get_post_type($last_postid);
2289
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2290
+							}
2291
+							$menu_order++;
2292
+						}
2293
+					}
2294
+
2295
+					$gd_post_info['package_id'] = $package_id;
2296
+
2297
+					/** This action is documented in geodirectory-functions/post-functions.php */
2298
+					do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
2299
+
2300
+					if (!empty($buffer[5])) {
2301
+						if (in_array($buffer[5], geodir_get_posttypes())) {
2302
+							$taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2303
+							wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2304
+							wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2305
+
2306
+							$post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2307
+							$post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2308
+							geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2309
+						}
2310
+					}
2311
+				} else {
2312
+					$invalid_title++;
2313
+				}
2314
+			}
2315
+		}
2316
+	}
2317
+	$return['rowcount'] = $countpost;
2318
+	$return['invalidcount'] = $address_invalid;
2319
+	$return['blank_address'] = $blank_address;
2320
+	$return['upload_files'] = $upload_files;
2321
+	$return['invalid_post_type'] = $invalid_post_type;
2322
+	$return['invalid_title'] = $invalid_title;
2323
+	$return['total_records'] = $total_records;
2324
+
2325
+	echo json_encode($return);
2326
+	exit;
2327 2327
 }
2328 2328
 
2329 2329
 // Add the tab in left sidebar menu fro import & export page.
@@ -2343,9 +2343,9 @@  discard block
 block discarded – undo
2343 2343
  * @param $post object $post The post object of the post being saved.
2344 2344
  */
2345 2345
 function geodir_update_location_prefix($post_id,$post){
2346
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2347
-        update_option('geodir_location_prefix',$post->post_name);
2348
-    }
2346
+	if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2347
+		update_option('geodir_location_prefix',$post->post_name);
2348
+	}
2349 2349
 
2350 2350
 }
2351 2351
 
@@ -2356,50 +2356,50 @@  discard block
 block discarded – undo
2356 2356
 function geodir_ga_callback(){
2357 2357
 
2358 2358
 if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2359
-    $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2360
-    $code = "code=".$_REQUEST['code'];
2361
-    $grant_type = "&grant_type=authorization_code";
2362
-    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2363
-    $client_id = "&client_id=".get_option('geodir_ga_client_id');
2364
-    $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2359
+	$oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2360
+	$code = "code=".$_REQUEST['code'];
2361
+	$grant_type = "&grant_type=authorization_code";
2362
+	$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2363
+	$client_id = "&client_id=".get_option('geodir_ga_client_id');
2364
+	$client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2365 2365
 
2366
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2366
+	$auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2367 2367
 
2368
-    $response = wp_remote_post($auth_url, array('timeout' => 15));
2368
+	$response = wp_remote_post($auth_url, array('timeout' => 15));
2369 2369
 
2370
-    //print_r($response);
2370
+	//print_r($response);
2371 2371
 
2372
-    $error_msg =  __('Something went wrong','geodirectory');
2373
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2372
+	$error_msg =  __('Something went wrong','geodirectory');
2373
+	if(!empty($response['response']['code']) && $response['response']['code']==200){
2374 2374
 
2375
-        $parts = json_decode($response['body']);
2376
-        //print_r($parts);
2377
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2378
-        else{
2375
+		$parts = json_decode($response['body']);
2376
+		//print_r($parts);
2377
+		if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2378
+		else{
2379 2379
 
2380
-            update_option('gd_ga_access_token', $parts->access_token);
2381
-            update_option('gd_ga_refresh_token', $parts->refresh_token);
2382
-            ?><script>window.close();</script><?php
2383
-        }
2380
+			update_option('gd_ga_access_token', $parts->access_token);
2381
+			update_option('gd_ga_refresh_token', $parts->refresh_token);
2382
+			?><script>window.close();</script><?php
2383
+		}
2384 2384
 
2385 2385
 
2386
-    }
2387
-    elseif(!empty($response['response']['code'])) {
2388
-        $parts = json_decode($response['body']);
2386
+	}
2387
+	elseif(!empty($response['response']['code'])) {
2388
+		$parts = json_decode($response['body']);
2389 2389
 
2390
-        if(isset($parts->error)){
2391
-            echo $parts->error.": ".$parts->error_description;exit;
2392
-        }else{
2393
-            echo $error_msg." - #2";exit;
2394
-        }
2390
+		if(isset($parts->error)){
2391
+			echo $parts->error.": ".$parts->error_description;exit;
2392
+		}else{
2393
+			echo $error_msg." - #2";exit;
2394
+		}
2395 2395
 
2396
-    }else{
2396
+	}else{
2397 2397
 
2398
-        echo $error_msg." - #3";exit;
2398
+		echo $error_msg." - #3";exit;
2399 2399
 
2400
-    }
2400
+	}
2401 2401
 }
2402
-    exit;
2402
+	exit;
2403 2403
 }
2404 2404
 
2405 2405
 if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
@@ -2415,45 +2415,45 @@  discard block
 block discarded – undo
2415 2415
  * @return array Array of settings.
2416 2416
  */
2417 2417
 function geodir_uninstall_settings($general_settings) {
2418
-    $settings   = array();
2419
-    $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
2420
-    $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
2418
+	$settings   = array();
2419
+	$settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
2420
+	$settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
2421 2421
     
2422
-    $plugins    = get_plugins();
2423
-    $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
2422
+	$plugins    = get_plugins();
2423
+	$un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
2424 2424
     
2425
-    if (!empty($plugins) && !empty($un_plugins)) {
2426
-        foreach ($plugins as $plugin => $data) {
2427
-            $plugin_name = plugin_basename(dirname($plugin));
2425
+	if (!empty($plugins) && !empty($un_plugins)) {
2426
+		foreach ($plugins as $plugin => $data) {
2427
+			$plugin_name = plugin_basename(dirname($plugin));
2428 2428
             
2429
-            if (in_array($plugin_name, $un_plugins)) {
2430
-                $settings[] = array(
2431
-                    'type' => 'checkbox',
2432
-                    'id' => 'geodir_un_' . $plugin_name,
2433
-                    'name' => $data['Name'],
2434
-                    'desc' => __('Remove all data when deleted?', 'geodirectory'),
2435
-                    'std' => '0'
2436
-                );
2437
-            }
2438
-        }
2439
-    }
2429
+			if (in_array($plugin_name, $un_plugins)) {
2430
+				$settings[] = array(
2431
+					'type' => 'checkbox',
2432
+					'id' => 'geodir_un_' . $plugin_name,
2433
+					'name' => $data['Name'],
2434
+					'desc' => __('Remove all data when deleted?', 'geodirectory'),
2435
+					'std' => '0'
2436
+				);
2437
+			}
2438
+		}
2439
+	}
2440 2440
         
2441
-    $settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main');
2441
+	$settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main');
2442 2442
     
2443
-    /**
2444
-     * Filter the uninstall settings array.
2445
-     *
2446
-     * @since 1.6.9
2447
-     *
2448
-     * @param array $settings The settings array.
2449
-     */
2450
-    $settings = apply_filters('geodir_uninstall_settings', $settings);
2443
+	/**
2444
+	 * Filter the uninstall settings array.
2445
+	 *
2446
+	 * @since 1.6.9
2447
+	 *
2448
+	 * @param array $settings The settings array.
2449
+	 */
2450
+	$settings = apply_filters('geodir_uninstall_settings', $settings);
2451 2451
     
2452
-    if (!empty($settings) && count($settings) > 3) {
2453
-        return array_merge($general_settings, $settings);
2454
-    }
2452
+	if (!empty($settings) && count($settings) > 3) {
2453
+		return array_merge($general_settings, $settings);
2454
+	}
2455 2455
     
2456
-    return $general_settings;
2456
+	return $general_settings;
2457 2457
 }
2458 2458
 add_filter('geodir_general_settings', 'geodir_uninstall_settings', 100, 1);
2459 2459
 
@@ -2463,7 +2463,7 @@  discard block
 block discarded – undo
2463 2463
  * @since 1.6.9
2464 2464
  */
2465 2465
 function geodir_uninstall_settings_desc() {
2466
-    echo '<p class="gd-un-settings-desc">' . __('Select the plugin(s) for which all data should be completely removed when the plugin is deleted.', 'geodirectory') . '</p>';
2466
+	echo '<p class="gd-un-settings-desc">' . __('Select the plugin(s) for which all data should be completely removed when the plugin is deleted.', 'geodirectory') . '</p>';
2467 2467
 }
2468 2468
 add_action('geodir_settings_uninstall_settings_main_start', 'geodir_uninstall_settings_desc');
2469 2469
 
@@ -2479,18 +2479,18 @@  discard block
 block discarded – undo
2479 2479
  * @return array The settings array.
2480 2480
  */
2481 2481
 function geodir_resave_settings($settings = array()) {
2482
-    if (!empty($settings) && is_array($settings)) {
2483
-        $c = 0;
2482
+	if (!empty($settings) && is_array($settings)) {
2483
+		$c = 0;
2484 2484
         
2485
-        foreach ($settings as $setting) {
2486
-            if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) {
2487
-                $settings[$c]['std'] = $value;
2488
-            }
2489
-            $c++;
2490
-        }
2491
-    }
2492
-
2493
-    return $settings;
2485
+		foreach ($settings as $setting) {
2486
+			if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) {
2487
+				$settings[$c]['std'] = $value;
2488
+			}
2489
+			$c++;
2490
+		}
2491
+	}
2492
+
2493
+	return $settings;
2494 2494
 }
2495 2495
 
2496 2496
 /**
@@ -2502,9 +2502,9 @@  discard block
 block discarded – undo
2502 2502
  * @return array The modified settings.
2503 2503
  */
2504 2504
 function geodir_core_uninstall_settings($settings) {
2505
-    $settings[] = plugin_basename(dirname(dirname(__FILE__)));
2505
+	$settings[] = plugin_basename(dirname(dirname(__FILE__)));
2506 2506
     
2507
-    return $settings;
2507
+	return $settings;
2508 2508
 }
2509 2509
 add_filter('geodir_plugins_uninstall_settings', 'geodir_core_uninstall_settings', 10, 1);
2510 2510
 
@@ -2518,34 +2518,34 @@  discard block
 block discarded – undo
2518 2518
  */
2519 2519
 function geodir_diagnose_reload_db_countries()
2520 2520
 {
2521
-    global $wpdb, $plugin_prefix;
2522
-
2523
-    $is_error_during_diagnose = false;
2524
-    $output_str = '';
2525
-
2526
-    $delete = $wpdb->query("TRUNCATE TABLE ".GEODIR_COUNTRIES_TABLE);
2527
-
2528
-
2529
-    if ($delete) {
2530
-            $output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>";
2531
-        ob_start();
2532
-        geodir_diagnose_version_clear();
2533
-        ob_end_clean();
2534
-    }else{
2535
-        $output_str .= "<li><strong>" . __('Something went wrong.', 'geodirectory') . "</strong></li>";
2536
-    }
2537
-
2538
-    if ($is_error_during_diagnose) {
2539
-        $info_div_class = "geodir_problem_info";
2540
-        $fix_button_txt = "";
2541
-    } else {
2542
-        $info_div_class = "geodir_noproblem_info";
2543
-        $fix_button_txt = '';
2544
-    }
2545
-    echo "<ul class='$info_div_class'>";
2546
-    echo $output_str;
2547
-    echo $fix_button_txt;
2548
-    echo "</ul>";
2521
+	global $wpdb, $plugin_prefix;
2522
+
2523
+	$is_error_during_diagnose = false;
2524
+	$output_str = '';
2525
+
2526
+	$delete = $wpdb->query("TRUNCATE TABLE ".GEODIR_COUNTRIES_TABLE);
2527
+
2528
+
2529
+	if ($delete) {
2530
+			$output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>";
2531
+		ob_start();
2532
+		geodir_diagnose_version_clear();
2533
+		ob_end_clean();
2534
+	}else{
2535
+		$output_str .= "<li><strong>" . __('Something went wrong.', 'geodirectory') . "</strong></li>";
2536
+	}
2537
+
2538
+	if ($is_error_during_diagnose) {
2539
+		$info_div_class = "geodir_problem_info";
2540
+		$fix_button_txt = "";
2541
+	} else {
2542
+		$info_div_class = "geodir_noproblem_info";
2543
+		$fix_button_txt = '';
2544
+	}
2545
+	echo "<ul class='$info_div_class'>";
2546
+	echo $output_str;
2547
+	echo $fix_button_txt;
2548
+	echo "</ul>";
2549 2549
 }
2550 2550
 
2551 2551
 /**
@@ -2558,11 +2558,11 @@  discard block
 block discarded – undo
2558 2558
  * @return array Filtered actions.
2559 2559
  */
2560 2560
 function geodir_disable_quick_edit( $actions = array(), $row = null ) {
2561
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
2562
-        unset( $actions['inline hide-if-no-js'] );
2563
-    }
2561
+	if ( isset( $actions['inline hide-if-no-js'] ) ) {
2562
+		unset( $actions['inline hide-if-no-js'] );
2563
+	}
2564 2564
 
2565
-    return $actions;
2565
+	return $actions;
2566 2566
 }
2567 2567
 
2568 2568
 /**
@@ -2576,26 +2576,26 @@  discard block
 block discarded – undo
2576 2576
  * @global bool $gd_cpt_screen True if current scrrrn has GD post type.
2577 2577
  */
2578 2578
 function geodir_check_quick_edit() {
2579
-    global $pagenow, $current_screen, $gd_cpt_screen;
2580
-
2581
-    if ( ( $pagenow == 'edit.php' || $pagenow == 'edit-tags.php' ) && !empty( $current_screen->post_type ) ) {
2582
-        if ( empty( $gd_cpt_screen ) ) {
2583
-            if ( in_array( $current_screen->post_type, geodir_get_posttypes() ) ) {
2584
-                $gd_cpt_screen = 'y';
2585
-            } else {
2586
-                $gd_cpt_screen = 'n';
2587
-            }
2588
-        }
2589
-
2590
-        if ( $gd_cpt_screen == 'y' ) {
2591
-            if ( $pagenow == 'edit.php' ) {
2592
-                add_filter( 'post_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2593
-                add_filter( 'page_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2594
-            } elseif ( $pagenow == 'edit-tags.php' && !empty( $current_screen->taxonomy ) ) {
2595
-                add_filter( $current_screen->taxonomy . '_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2596
-            }
2597
-        }
2598
-    }
2579
+	global $pagenow, $current_screen, $gd_cpt_screen;
2580
+
2581
+	if ( ( $pagenow == 'edit.php' || $pagenow == 'edit-tags.php' ) && !empty( $current_screen->post_type ) ) {
2582
+		if ( empty( $gd_cpt_screen ) ) {
2583
+			if ( in_array( $current_screen->post_type, geodir_get_posttypes() ) ) {
2584
+				$gd_cpt_screen = 'y';
2585
+			} else {
2586
+				$gd_cpt_screen = 'n';
2587
+			}
2588
+		}
2589
+
2590
+		if ( $gd_cpt_screen == 'y' ) {
2591
+			if ( $pagenow == 'edit.php' ) {
2592
+				add_filter( 'post_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2593
+				add_filter( 'page_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2594
+			} elseif ( $pagenow == 'edit-tags.php' && !empty( $current_screen->taxonomy ) ) {
2595
+				add_filter( $current_screen->taxonomy . '_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2596
+			}
2597
+		}
2598
+	}
2599 2599
 }
2600 2600
 add_action( 'admin_head', 'geodir_check_quick_edit', 10 );
2601 2601
 
@@ -2609,11 +2609,11 @@  discard block
 block discarded – undo
2609 2609
  * @return array Filtered bulk actions.
2610 2610
  */
2611 2611
 function geodir_filter_bulk_actions( $actions ) {
2612
-    if ( isset( $actions['edit'] ) ) {
2613
-        unset( $actions['edit'] );
2614
-    }
2612
+	if ( isset( $actions['edit'] ) ) {
2613
+		unset( $actions['edit'] );
2614
+	}
2615 2615
     
2616
-    return $actions;
2616
+	return $actions;
2617 2617
 }
2618 2618
 
2619 2619
 /**
Please login to merge, or discard this patch.