Test Failed
Pull Request — master (#286)
by Kiran
09:42
created
geodirectory-functions/custom_taxonomy_hooks_actions.php 2 patches
Indentation   +474 added lines, -474 removed lines patch added patch discarded remove patch
@@ -13,29 +13,29 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function geodir_register_taxonomies()
15 15
 {
16
-    $taxonomies = array();
17
-    $taxonomies = get_option('geodir_taxonomies');
18
-    // If custom taxonomies are present, register them
19
-    if (is_array($taxonomies)) {
20
-        // Sort taxonomies
21
-        ksort($taxonomies);
22
-
23
-        // Register taxonomies
24
-        foreach ($taxonomies as $taxonomy => $args) {
25
-            // Allow taxonomy names to be translated
26
-            if (!empty($args['args']['labels'])) {
27
-                foreach ($args['args']['labels'] as $key => $tax_label) {
28
-                    $args['args']['labels'][$key] = __($tax_label, 'geodirectory');
29
-                }
30
-            }
31
-
32
-            $tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']);
33
-
34
-            if (taxonomy_exists($taxonomy)) {
35
-                $tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']);
36
-            }
37
-        }
38
-    }
16
+	$taxonomies = array();
17
+	$taxonomies = get_option('geodir_taxonomies');
18
+	// If custom taxonomies are present, register them
19
+	if (is_array($taxonomies)) {
20
+		// Sort taxonomies
21
+		ksort($taxonomies);
22
+
23
+		// Register taxonomies
24
+		foreach ($taxonomies as $taxonomy => $args) {
25
+			// Allow taxonomy names to be translated
26
+			if (!empty($args['args']['labels'])) {
27
+				foreach ($args['args']['labels'] as $key => $tax_label) {
28
+					$args['args']['labels'][$key] = __($tax_label, 'geodirectory');
29
+				}
30
+			}
31
+
32
+			$tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']);
33
+
34
+			if (taxonomy_exists($taxonomy)) {
35
+				$tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']);
36
+			}
37
+		}
38
+	}
39 39
 }
40 40
 
41 41
 
@@ -53,40 +53,40 @@  discard block
 block discarded – undo
53 53
  */
54 54
 function geodir_register_post_types() 
55 55
 {
56
-    global $wp_post_types;
56
+	global $wp_post_types;
57 57
 
58
-    $post_types = array();
59
-    $post_types = get_option('geodir_post_types');
58
+	$post_types = array();
59
+	$post_types = get_option('geodir_post_types');
60 60
 
61
-    // Register each post type if array of data is returned
62
-    if (is_array($post_types)):
61
+	// Register each post type if array of data is returned
62
+	if (is_array($post_types)):
63 63
 
64
-        foreach ($post_types as $post_type => $args):
64
+		foreach ($post_types as $post_type => $args):
65 65
 
66
-            if (!empty($args['rewrite']['slug'])) {
67
-                $args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory');
68
-            }
69
-            $args = stripslashes_deep($args);
66
+			if (!empty($args['rewrite']['slug'])) {
67
+				$args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory');
68
+			}
69
+			$args = stripslashes_deep($args);
70 70
 
71
-            if (!empty($args['labels'])) {
72
-                foreach ($args['labels'] as $key => $val) {
73
-                    $args['labels'][$key] = __($val, 'geodirectory');// allow translation
74
-                }
75
-            }
71
+			if (!empty($args['labels'])) {
72
+				foreach ($args['labels'] as $key => $val) {
73
+					$args['labels'][$key] = __($val, 'geodirectory');// allow translation
74
+				}
75
+			}
76 76
 
77
-            /**
78
-             * Filter post type args.
79
-             *
80
-             * @since 1.0.0
81
-             * @param string $args Post type args.
82
-             * @param string $post_type The post type.
83
-             */
84
-            $args = apply_filters('geodir_post_type_args', $args, $post_type);
77
+			/**
78
+			 * Filter post type args.
79
+			 *
80
+			 * @since 1.0.0
81
+			 * @param string $args Post type args.
82
+			 * @param string $post_type The post type.
83
+			 */
84
+			$args = apply_filters('geodir_post_type_args', $args, $post_type);
85 85
 
86
-            $post_type = register_post_type($post_type, $args);
86
+			$post_type = register_post_type($post_type, $args);
87 87
 
88
-        endforeach;
89
-    endif;
88
+		endforeach;
89
+	endif;
90 90
 }
91 91
 
92 92
 /**
@@ -100,72 +100,72 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function geodir_post_type_args_modify($args, $post_type)
102 102
 {
103
-    $geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
103
+	$geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
104 104
 	if (isset($_REQUEST['geodir_listing_prefix']) && $_REQUEST['geodir_listing_prefix'] != '' && geodir_strtolower($_REQUEST['geodir_listing_prefix']) != geodir_strtolower($geodir_location_prefix)) {
105 105
 
106
-        $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix']));
106
+		$listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix']));
107 107
 
108
-        if ($post_type == 'gd_place') {
109
-            if (array_key_exists('has_archive', $args))
110
-                $args['has_archive'] = $listing_slug;
108
+		if ($post_type == 'gd_place') {
109
+			if (array_key_exists('has_archive', $args))
110
+				$args['has_archive'] = $listing_slug;
111 111
 
112
-            if (array_key_exists('rewrite', $args)) {
113
-                if (array_key_exists('slug', $args['rewrite']))
114
-                    $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
115
-            }
112
+			if (array_key_exists('rewrite', $args)) {
113
+				if (array_key_exists('slug', $args['rewrite']))
114
+					$args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
115
+			}
116 116
 
117
-            $geodir_post_types = get_option('geodir_post_types');
117
+			$geodir_post_types = get_option('geodir_post_types');
118 118
 
119
-            if (array_key_exists($post_type, $geodir_post_types)) {
119
+			if (array_key_exists($post_type, $geodir_post_types)) {
120 120
 
121
-                if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
122
-                    $geodir_post_types[$post_type]['has_archive'] = $listing_slug;
121
+				if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
122
+					$geodir_post_types[$post_type]['has_archive'] = $listing_slug;
123 123
 
124
-                if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125
-                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
-                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
124
+				if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125
+					if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
+						$geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
127 127
 
128
-                update_option('geodir_post_types', $geodir_post_types);
128
+				update_option('geodir_post_types', $geodir_post_types);
129 129
 
130
-            }
130
+			}
131 131
 
132
-            $geodir_post_types = get_option('geodir_post_types');
132
+			$geodir_post_types = get_option('geodir_post_types');
133 133
 
134
-            /* --- update taxonomies (category) --- */
134
+			/* --- update taxonomies (category) --- */
135 135
 
136
-            $geodir_taxonomies = get_option('geodir_taxonomies');
136
+			$geodir_taxonomies = get_option('geodir_taxonomies');
137 137
 
138
-            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
139
-                $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
138
+			if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
139
+				$geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
140 140
 
141
-                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
142
-                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
143
-                        if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
144
-                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
141
+				if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
142
+					if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
143
+						if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
144
+							$geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
145 145
 
146
-                update_option('geodir_taxonomies', $geodir_taxonomies);
146
+				update_option('geodir_taxonomies', $geodir_taxonomies);
147 147
 
148
-            }
148
+			}
149 149
 
150
-            /* --- update taxonomies (tags) --- */
151
-            $geodir_taxonomies_tag = get_option('geodir_taxonomies');
152
-            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
153
-                $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
150
+			/* --- update taxonomies (tags) --- */
151
+			$geodir_taxonomies_tag = get_option('geodir_taxonomies');
152
+			if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
153
+				$geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
154 154
 
155
-                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
156
-                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
157
-                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
158
-                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
155
+				if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
156
+					if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
157
+						if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
158
+							$geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
159 159
 
160
-                update_option('geodir_taxonomies', $geodir_taxonomies_tag);
160
+				update_option('geodir_taxonomies', $geodir_taxonomies_tag);
161 161
 
162
-            }
162
+			}
163 163
 
164
-        }
164
+		}
165 165
 
166
-    }
166
+	}
167 167
 
168
-    return $args;
168
+	return $args;
169 169
 }
170 170
 
171 171
 /**
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
  */
179 179
 function geodir_flush_rewrite_rules()
180 180
 {
181
-    global $wp_rewrite;
182
-    $wp_rewrite->flush_rules(false);
181
+	global $wp_rewrite;
182
+	$wp_rewrite->flush_rules(false);
183 183
 }
184 184
 
185 185
 /**
@@ -194,35 +194,35 @@  discard block
 block discarded – undo
194 194
  * @return array Rewrite rules.
195 195
  */
196 196
 function geodir_listing_rewrite_rules($rules) {
197
-    $newrules = array();
198
-    $taxonomies = get_option('geodir_taxonomies');
199
-    $detail_url_seprator = get_option('geodir_detailurl_separator');
197
+	$newrules = array();
198
+	$taxonomies = get_option('geodir_taxonomies');
199
+	$detail_url_seprator = get_option('geodir_detailurl_separator');
200 200
     
201 201
 	// create rules for post listing
202
-    if (is_array($taxonomies)):
203
-        foreach ($taxonomies as $taxonomy => $args):
204
-            $post_type = $args['object_type'];
205
-            $listing_slug = $args['listing_slug'];
206
-
207
-            if (strpos($taxonomy, 'tags')) {
208
-                $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
209
-                $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
210
-            } else {
211
-                // use this loop to add paging for details page comments paging
212
-                $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
213
-            }
214
-        endforeach;
215
-    endif;
216
-
217
-    // create rules for location listing
218
-    $location_page = get_option('geodir_location_page');
202
+	if (is_array($taxonomies)):
203
+		foreach ($taxonomies as $taxonomy => $args):
204
+			$post_type = $args['object_type'];
205
+			$listing_slug = $args['listing_slug'];
206
+
207
+			if (strpos($taxonomy, 'tags')) {
208
+				$newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
209
+				$newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
210
+			} else {
211
+				// use this loop to add paging for details page comments paging
212
+				$newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
213
+			}
214
+		endforeach;
215
+	endif;
216
+
217
+	// create rules for location listing
218
+	$location_page = get_option('geodir_location_page');
219 219
 	
220
-    if($location_page) {
221
-        global $wpdb;
222
-        $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223
-    }
224
-    if (!isset($location_prefix))
225
-        $location_prefix = 'location';
220
+	if($location_page) {
221
+		global $wpdb;
222
+		$location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223
+	}
224
+	if (!isset($location_prefix))
225
+		$location_prefix = 'location';
226 226
 
227 227
 	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
228 228
 	if ($location_manager) {
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
 		$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]';
267 267
 	}
268 268
 
269
-    if ($location_page && function_exists('icl_object_id')) {
270
-        foreach(icl_get_languages('skip_missing=N') as $lang){
271
-            $alt_page_id = '';
272
-            $alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']);
273
-            if($alt_page_id){
274
-                $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
269
+	if ($location_page && function_exists('icl_object_id')) {
270
+		foreach(icl_get_languages('skip_missing=N') as $lang){
271
+			$alt_page_id = '';
272
+			$alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']);
273
+			if($alt_page_id){
274
+				$location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
275 275
 
276 276
 				if ($location_manager && ($hide_country_part || $hide_region_part)) {
277 277
 					$matches2 = '';
@@ -307,14 +307,14 @@  discard block
 block discarded – undo
307 307
 					$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]';
308 308
 					$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]';
309 309
 				}
310
-            }
311
-        }
312
-    }
310
+			}
311
+		}
312
+	}
313 313
 
314
-    $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page;
314
+	$newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page;
315 315
 
316
-    $rules = array_merge($newrules, $rules);
317
-    return $rules;
316
+	$rules = array_merge($newrules, $rules);
317
+	return $rules;
318 318
 }
319 319
 
320 320
 /**
@@ -329,18 +329,18 @@  discard block
 block discarded – undo
329 329
  */
330 330
 function geodir_htaccess_contents($rules)
331 331
 {
332
-    global $wpdb;
333
-    $location_prefix = get_option('geodir_location_prefix');
334
-    // if location page slug changed then add redirect
335
-    if ($location_prefix == 'location') {
336
-        return $rules;
337
-    }
338
-    $my_content = <<<EOD
332
+	global $wpdb;
333
+	$location_prefix = get_option('geodir_location_prefix');
334
+	// if location page slug changed then add redirect
335
+	if ($location_prefix == 'location') {
336
+		return $rules;
337
+	}
338
+	$my_content = <<<EOD
339 339
 \n# BEGIN GeoDirectory Rules
340 340
 #Redirect 301 /location/ /$location_prefix/
341 341
 # END GeoDirectory Rules\n\n
342 342
 EOD;
343
-    return $my_content . $rules;
343
+	return $my_content . $rules;
344 344
 }
345 345
 //add_filter('mod_rewrite_rules', 'geodir_htaccess_contents');
346 346
 
@@ -354,10 +354,10 @@  discard block
 block discarded – undo
354 354
  */
355 355
 function geodir_add_location_var($public_query_vars)
356 356
 {
357
-    $public_query_vars[] = 'gd_country';
358
-    $public_query_vars[] = 'gd_region';
359
-    $public_query_vars[] = 'gd_city';
360
-    return $public_query_vars;
357
+	$public_query_vars[] = 'gd_country';
358
+	$public_query_vars[] = 'gd_region';
359
+	$public_query_vars[] = 'gd_city';
360
+	return $public_query_vars;
361 361
 }
362 362
 
363 363
 /**
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
  */
371 371
 function geodir_add_geodir_page_var($public_query_vars)
372 372
 {
373
-    $public_query_vars[] = 'gd_is_geodir_page';
374
-    return $public_query_vars;
373
+	$public_query_vars[] = 'gd_is_geodir_page';
374
+	return $public_query_vars;
375 375
 }
376 376
 
377 377
 /**
@@ -383,20 +383,20 @@  discard block
 block discarded – undo
383 383
  */
384 384
 function geodir_add_page_id_in_query_var()
385 385
 {
386
-    global $wp_query;
386
+	global $wp_query;
387 387
 
388
-    $page_id = $wp_query->get_queried_object_id();
388
+	$page_id = $wp_query->get_queried_object_id();
389 389
 
390
-    if (!get_query_var('page_id')) {
391
-        // fix for WP tags conflict with enfold theme
392
-        $theme_name = geodir_strtolower(wp_get_theme());
393
-        if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
394
-            return $wp_query;
395
-        }
396
-        $wp_query->set('page_id', $page_id);
397
-    }
390
+	if (!get_query_var('page_id')) {
391
+		// fix for WP tags conflict with enfold theme
392
+		$theme_name = geodir_strtolower(wp_get_theme());
393
+		if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
394
+			return $wp_query;
395
+		}
396
+		$wp_query->set('page_id', $page_id);
397
+	}
398 398
 
399
-    return $wp_query;
399
+	return $wp_query;
400 400
 }
401 401
 
402 402
 /**
@@ -411,24 +411,24 @@  discard block
 block discarded – undo
411 411
 function geodir_set_location_var_in_session_in_core($wp) {
412 412
 	global $gd_session;
413 413
 	
414
-    // Fix for WPML removing page_id query var:
415
-    if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
416
-        global $wpdb;
417
-
418
-        $page_for_posts = get_option('page_for_posts');
419
-        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
420
-
421
-        if (function_exists('icl_object_id')) {
422
-            $real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
423
-        }
424
-        if ($real_page_id && $real_page_id!=$page_for_posts) {
425
-            $wp->query_vars['page_id'] = $real_page_id;
426
-        }
427
-    }
414
+	// Fix for WPML removing page_id query var:
415
+	if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
416
+		global $wpdb;
417
+
418
+		$page_for_posts = get_option('page_for_posts');
419
+		$real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
420
+
421
+		if (function_exists('icl_object_id')) {
422
+			$real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
423
+		}
424
+		if ($real_page_id && $real_page_id!=$page_for_posts) {
425
+			$wp->query_vars['page_id'] = $real_page_id;
426
+		}
427
+	}
428 428
 	
429 429
 	// Query Vars will have page_id parameter
430 430
 	// check if query var has page_id and that page id is location page
431
-    geodir_set_is_geodir_page($wp);
431
+	geodir_set_is_geodir_page($wp);
432 432
 	// if is GD homepage set the page ID
433 433
 	if (geodir_is_page('home')) {
434 434
 		$wp->query_vars['page_id'] = get_option('page_on_front');
@@ -437,118 +437,118 @@  discard block
 block discarded – undo
437 437
 	// The location url format (all or country_city or region_city or city).
438 438
 	$geodir_show_location_url = get_option('geodir_show_location_url');
439 439
 
440
-    if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
441
-        $gd_country = '';
442
-        $gd_region = '';
443
-        $gd_city = '';
444
-        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '')
445
-            $gd_country = urldecode($wp->query_vars['gd_country']);
446
-
447
-        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '')
448
-            $gd_region = urldecode($wp->query_vars['gd_region']);
449
-
450
-        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '')
451
-            $gd_city = urldecode($wp->query_vars['gd_city']);
452
-
453
-        if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
454
-            $default_location = geodir_get_default_location();
455
-
456
-            if (get_option('geodir_add_location_url')) {
457
-                if ($geodir_show_location_url != 'all') {
458
-                    if ($gd_region == '') {
459
-                        if ($gd_ses_region = $gd_session->get('gd_region'))
460
-                            $gd_region = $gd_ses_region;
461
-                        else
462
-                            $gd_region = $default_location->region_slug;
463
-                    }
464
-
465
-                    if ($gd_city == '') {
466
-                        if ($gd_ses_city = $gd_session->get('gd_city'))
467
-                            $gd_city = $gd_ses_city;
468
-                        else
469
-                            $gd_city = $default_location->city_slug;
470
-
471
-                        $base_location_link = geodir_get_location_link('base');
472
-                        wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
473
-                        exit();
474
-                    }
475
-                }
476
-            }
477
-
478
-            $args = array(
479
-                'what' => 'city',
480
-                'city_val' => $gd_city,
481
-                'region_val' => $gd_region,
482
-                'country_val' => $gd_country,
483
-                'country_column_name' => 'country_slug',
484
-                'region_column_name' => 'region_slug',
485
-                'city_column_name' => 'city_slug',
486
-                'location_link_part' => false,
487
-                'compare_operator' => ''
488
-            );
489
-
490
-            $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
491
-            if (!empty($location_array)) {
492
-                $gd_session->set('gd_multi_location', 1);
493
-                $gd_session->set('gd_country', $gd_country);
494
-                $gd_session->set('gd_region', $gd_region);
495
-                $gd_session->set('gd_city', $gd_city);
440
+	if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
441
+		$gd_country = '';
442
+		$gd_region = '';
443
+		$gd_city = '';
444
+		if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '')
445
+			$gd_country = urldecode($wp->query_vars['gd_country']);
446
+
447
+		if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '')
448
+			$gd_region = urldecode($wp->query_vars['gd_region']);
449
+
450
+		if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '')
451
+			$gd_city = urldecode($wp->query_vars['gd_city']);
452
+
453
+		if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
454
+			$default_location = geodir_get_default_location();
455
+
456
+			if (get_option('geodir_add_location_url')) {
457
+				if ($geodir_show_location_url != 'all') {
458
+					if ($gd_region == '') {
459
+						if ($gd_ses_region = $gd_session->get('gd_region'))
460
+							$gd_region = $gd_ses_region;
461
+						else
462
+							$gd_region = $default_location->region_slug;
463
+					}
464
+
465
+					if ($gd_city == '') {
466
+						if ($gd_ses_city = $gd_session->get('gd_city'))
467
+							$gd_city = $gd_ses_city;
468
+						else
469
+							$gd_city = $default_location->city_slug;
470
+
471
+						$base_location_link = geodir_get_location_link('base');
472
+						wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
473
+						exit();
474
+					}
475
+				}
476
+			}
477
+
478
+			$args = array(
479
+				'what' => 'city',
480
+				'city_val' => $gd_city,
481
+				'region_val' => $gd_region,
482
+				'country_val' => $gd_country,
483
+				'country_column_name' => 'country_slug',
484
+				'region_column_name' => 'region_slug',
485
+				'city_column_name' => 'city_slug',
486
+				'location_link_part' => false,
487
+				'compare_operator' => ''
488
+			);
489
+
490
+			$location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
491
+			if (!empty($location_array)) {
492
+				$gd_session->set('gd_multi_location', 1);
493
+				$gd_session->set('gd_country', $gd_country);
494
+				$gd_session->set('gd_region', $gd_region);
495
+				$gd_session->set('gd_city', $gd_city);
496 496
                 
497 497
 				$wp->query_vars['gd_country'] = $gd_country;
498
-                $wp->query_vars['gd_region'] = $gd_region;
499
-                $wp->query_vars['gd_city'] = $gd_city;
500
-            } else {
501
-                $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
502
-            }
503
-        } else {
504
-            $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
505
-        }
506
-
507
-    } else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
508
-        if (!is_admin()) {
509
-            $requested_post_type = $wp->query_vars['post_type'];
510
-            // check if this post type is geodirectory post types
511
-            $post_type_array = geodir_get_posttypes();
498
+				$wp->query_vars['gd_region'] = $gd_region;
499
+				$wp->query_vars['gd_city'] = $gd_city;
500
+			} else {
501
+				$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
502
+			}
503
+		} else {
504
+			$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
505
+		}
506
+
507
+	} else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
508
+		if (!is_admin()) {
509
+			$requested_post_type = $wp->query_vars['post_type'];
510
+			// check if this post type is geodirectory post types
511
+			$post_type_array = geodir_get_posttypes();
512 512
             
513 513
 			if (in_array($requested_post_type, $post_type_array)) {
514
-                // now u can apply geodirectory related manipulation.
515
-            }
516
-        }
517
-    } else {
518
-        // check if a geodirectory taxonomy is set
519
-        $gd_country = '';
520
-        $gd_region = '';
521
-        $gd_city = '';
514
+				// now u can apply geodirectory related manipulation.
515
+			}
516
+		}
517
+	} else {
518
+		// check if a geodirectory taxonomy is set
519
+		$gd_country = '';
520
+		$gd_region = '';
521
+		$gd_city = '';
522 522
         
523 523
 		$is_geodir_taxonomy = false;
524
-        $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not
525
-        $is_geodir_location_found = false;
524
+		$is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not
525
+		$is_geodir_location_found = false;
526 526
 		
527 527
 		$geodir_taxonomy = '';
528
-        $geodir_post_type = '';
529
-        $geodir_term = '';
530
-        $geodir_set_location_session = true;
531
-        $geodir_taxonomis = geodir_get_taxonomies('', true);
532
-
533
-        if(!empty($geodir_taxonomis)){
534
-            foreach ($geodir_taxonomis as $taxonomy) {
535
-                if (array_key_exists($taxonomy, $wp->query_vars)) {
536
-                    $is_geodir_taxonomy = true;
537
-                    $geodir_taxonomy = $taxonomy;
538
-                    $geodir_post_type = str_replace('category', '', $taxonomy);
539
-                    $geodir_post_type = str_replace('_tags', '', $geodir_post_type);
540
-                    $geodir_term = $wp->query_vars[$geodir_taxonomy];
541
-                    break;
542
-                }
543
-            }
544
-        }
545
-
546
-        // now get an array of all terms seperated by '/'
547
-        $geodir_terms = explode('/', $geodir_term);
548
-        $geodir_last_term = end($geodir_terms);
549
-
550
-        if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
551
-            $wp->query_vars['post_type'] = $geodir_post_type;
528
+		$geodir_post_type = '';
529
+		$geodir_term = '';
530
+		$geodir_set_location_session = true;
531
+		$geodir_taxonomis = geodir_get_taxonomies('', true);
532
+
533
+		if(!empty($geodir_taxonomis)){
534
+			foreach ($geodir_taxonomis as $taxonomy) {
535
+				if (array_key_exists($taxonomy, $wp->query_vars)) {
536
+					$is_geodir_taxonomy = true;
537
+					$geodir_taxonomy = $taxonomy;
538
+					$geodir_post_type = str_replace('category', '', $taxonomy);
539
+					$geodir_post_type = str_replace('_tags', '', $geodir_post_type);
540
+					$geodir_term = $wp->query_vars[$geodir_taxonomy];
541
+					break;
542
+				}
543
+			}
544
+		}
545
+
546
+		// now get an array of all terms seperated by '/'
547
+		$geodir_terms = explode('/', $geodir_term);
548
+		$geodir_last_term = end($geodir_terms);
549
+
550
+		if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
551
+			$wp->query_vars['post_type'] = $geodir_post_type;
552 552
 
553 553
 			// now check if last term is a post of geodirectory post types
554 554
 			$geodir_post = get_posts(array(
@@ -597,196 +597,196 @@  discard block
 block discarded – undo
597 597
 				//return ;
598 598
 			}
599 599
 
600
-            $geodir_location_terms = '';
601
-            // if last term is not a post then check if last term is a term of the specific texonomy or not
602
-            if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
603
-                $is_geodir_taxonomy_term = true;
600
+			$geodir_location_terms = '';
601
+			// if last term is not a post then check if last term is a term of the specific texonomy or not
602
+			if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
603
+				$is_geodir_taxonomy_term = true;
604 604
 
605
-                $geodir_set_location_session = false;
606
-            }
605
+				$geodir_set_location_session = false;
606
+			}
607 607
 
608 608
 
609
-            // now check if there is location parts in the url or not
610
-            if (get_option('geodir_add_location_url')) {				
609
+			// now check if there is location parts in the url or not
610
+			if (get_option('geodir_add_location_url')) {				
611 611
 				$default_location = geodir_get_default_location();
612 612
                 
613 613
 				if ($geodir_show_location_url == 'all') {
614
-                    if (count($geodir_terms) >= 3) {
615
-                        $gd_country = urldecode($geodir_terms[0]);
616
-                        $gd_region = urldecode($geodir_terms[1]);
617
-                        $gd_city = urldecode($geodir_terms[2]);
618
-                    } else if (count($geodir_terms) >= 2) {
619
-                        $gd_country = urldecode($geodir_terms[0]);
620
-                        $gd_region = urldecode($geodir_terms[1]);
621
-                    } else if (count($geodir_terms) >= 1) {
622
-                        $gd_country = urldecode($geodir_terms[0]);
623
-                    }
624
-
625
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
626
-                        geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
627
-                        geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
628
-                    )
629
-                        $is_geodir_location_found = true;
630
-
631
-                    // if location has not been found for country , region and city then search for country and region only
632
-
633
-                    if (!$is_geodir_location_found) {
634
-                        $gd_city = '';
635
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
636
-                            geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
637
-                        )
638
-                            $is_geodir_location_found = true;
639
-
640
-                    }
641
-
642
-                    // if location has not been found for country , region  then search for country only
643
-                    if (!$is_geodir_location_found) {
644
-                        $gd_city = '';
645
-                        $gd_region = '';
646
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
647
-                            $is_geodir_location_found = true;
648
-                    }
649
-                } else if ($geodir_show_location_url == 'country_city') {
650
-                    if (count($geodir_terms) >= 2) {
651
-                        $gd_country = urldecode($geodir_terms[0]);
652
-                        $gd_city = urldecode($geodir_terms[1]);
653
-                    } else if (count($geodir_terms) >= 1) {
654
-                        $gd_country = urldecode($geodir_terms[0]);
655
-                    }
656
-
657
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
658
-                        $is_geodir_location_found = true;
659
-
660
-                    // if location has not been found for country and city  then search for country only
661
-                    if (!$is_geodir_location_found) {
662
-                        $gd_city = '';
614
+					if (count($geodir_terms) >= 3) {
615
+						$gd_country = urldecode($geodir_terms[0]);
616
+						$gd_region = urldecode($geodir_terms[1]);
617
+						$gd_city = urldecode($geodir_terms[2]);
618
+					} else if (count($geodir_terms) >= 2) {
619
+						$gd_country = urldecode($geodir_terms[0]);
620
+						$gd_region = urldecode($geodir_terms[1]);
621
+					} else if (count($geodir_terms) >= 1) {
622
+						$gd_country = urldecode($geodir_terms[0]);
623
+					}
624
+
625
+					if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
626
+						geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
627
+						geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
628
+					)
629
+						$is_geodir_location_found = true;
630
+
631
+					// if location has not been found for country , region and city then search for country and region only
632
+
633
+					if (!$is_geodir_location_found) {
634
+						$gd_city = '';
635
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
636
+							geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
637
+						)
638
+							$is_geodir_location_found = true;
639
+
640
+					}
641
+
642
+					// if location has not been found for country , region  then search for country only
643
+					if (!$is_geodir_location_found) {
644
+						$gd_city = '';
645
+						$gd_region = '';
646
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
647
+							$is_geodir_location_found = true;
648
+					}
649
+				} else if ($geodir_show_location_url == 'country_city') {
650
+					if (count($geodir_terms) >= 2) {
651
+						$gd_country = urldecode($geodir_terms[0]);
652
+						$gd_city = urldecode($geodir_terms[1]);
653
+					} else if (count($geodir_terms) >= 1) {
654
+						$gd_country = urldecode($geodir_terms[0]);
655
+					}
656
+
657
+					if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
658
+						$is_geodir_location_found = true;
659
+
660
+					// if location has not been found for country and city  then search for country only
661
+					if (!$is_geodir_location_found) {
662
+						$gd_city = '';
663 663
                         
664 664
 						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
665
-                            $is_geodir_location_found = true;
666
-                    }
667
-                }  else if ($geodir_show_location_url == 'region_city') {
668
-                    if (count($geodir_terms) >= 2) {
669
-                        $gd_region = urldecode($geodir_terms[0]);
670
-                        $gd_city = urldecode($geodir_terms[1]);
671
-                    } else if (count($geodir_terms) >= 1) {
672
-                        $gd_region = urldecode($geodir_terms[0]);
673
-                    }
674
-
675
-                    if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
676
-                        $is_geodir_location_found = true;
677
-
678
-                    // if location has not been found for region and city  then search for region only
679
-                    if (!$is_geodir_location_found) {
680
-                        $gd_city = '';
665
+							$is_geodir_location_found = true;
666
+					}
667
+				}  else if ($geodir_show_location_url == 'region_city') {
668
+					if (count($geodir_terms) >= 2) {
669
+						$gd_region = urldecode($geodir_terms[0]);
670
+						$gd_city = urldecode($geodir_terms[1]);
671
+					} else if (count($geodir_terms) >= 1) {
672
+						$gd_region = urldecode($geodir_terms[0]);
673
+					}
674
+
675
+					if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
676
+						$is_geodir_location_found = true;
677
+
678
+					// if location has not been found for region and city  then search for region only
679
+					if (!$is_geodir_location_found) {
680
+						$gd_city = '';
681 681
                         
682 682
 						if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region))
683
-                            $is_geodir_location_found = true;
684
-                    }
685
-                } else {
686
-                    $gd_city = $geodir_terms[0];
687
-
688
-                    if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
689
-                        $is_geodir_location_found = true;
690
-                        $gd_region = $default_location->region_slug;
691
-                        $gd_country = $default_location->country_slug;
692
-                    }
693
-                }
694
-                // if location still not found then clear location related session variables
695
-                if ($is_geodir_location_found && $geodir_set_location_session) {
696
-                    $gd_session->set('gd_multi_location', 1);
697
-                    $gd_session->set('gd_country', $gd_country);
698
-                    $gd_session->set('gd_region', $gd_region);
699
-                    $gd_session->set('gd_city', $gd_city);
700
-                }
701
-
702
-                if ($geodir_show_location_url == 'all') {
683
+							$is_geodir_location_found = true;
684
+					}
685
+				} else {
686
+					$gd_city = $geodir_terms[0];
687
+
688
+					if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
689
+						$is_geodir_location_found = true;
690
+						$gd_region = $default_location->region_slug;
691
+						$gd_country = $default_location->country_slug;
692
+					}
693
+				}
694
+				// if location still not found then clear location related session variables
695
+				if ($is_geodir_location_found && $geodir_set_location_session) {
696
+					$gd_session->set('gd_multi_location', 1);
697
+					$gd_session->set('gd_country', $gd_country);
698
+					$gd_session->set('gd_region', $gd_region);
699
+					$gd_session->set('gd_city', $gd_city);
700
+				}
701
+
702
+				if ($geodir_show_location_url == 'all') {
703 703
 				} else if ($geodir_show_location_url == 'country_city') {
704 704
 					$gd_region = '';
705 705
 				} else if ($geodir_show_location_url == 'region_city') {
706 706
 					$gd_country = '';
707 707
 				} else {
708 708
 					$gd_country = '';
709
-                    $gd_region = '';
709
+					$gd_region = '';
710 710
 				}
711 711
 
712
-                if ($is_geodir_location_found) {
713
-                    $wp->query_vars['gd_country'] = $gd_country;
714
-                    $wp->query_vars['gd_region'] = $gd_region;
715
-                    $wp->query_vars['gd_city'] = $gd_city;
716
-                } else {
717
-                    $gd_country = '';
718
-                    $gd_region = '';
719
-                    $gd_city = '';
720
-                }
721
-            }
722
-
723
-            $wp->query_vars[$geodir_taxonomy] = $geodir_term;
724
-            // eliminate location related terms from taxonomy term
725
-            if ($gd_country != '')
726
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
727
-
728
-            if ($gd_region != '')
729
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
730
-
731
-            if ($gd_city != '')
732
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
733
-
734
-
735
-            $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
736
-            $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
737
-
738
-            $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
739
-
740
-            if ($wp->query_vars[$geodir_taxonomy] == '') {
741
-                unset($wp->query_vars[$geodir_taxonomy]);
742
-            } else {
743
-                if (!$is_geodir_taxonomy_term) {
744
-                    foreach ($wp->query_vars as $key => $vars) {
745
-                        unset($wp->query_vars[$key]);
746
-                    }
747
-                    $wp->query_vars['error'] = '404';
748
-                }
749
-            }
750
-        }
751
-    }
712
+				if ($is_geodir_location_found) {
713
+					$wp->query_vars['gd_country'] = $gd_country;
714
+					$wp->query_vars['gd_region'] = $gd_region;
715
+					$wp->query_vars['gd_city'] = $gd_city;
716
+				} else {
717
+					$gd_country = '';
718
+					$gd_region = '';
719
+					$gd_city = '';
720
+				}
721
+			}
722
+
723
+			$wp->query_vars[$geodir_taxonomy] = $geodir_term;
724
+			// eliminate location related terms from taxonomy term
725
+			if ($gd_country != '')
726
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
727
+
728
+			if ($gd_region != '')
729
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
730
+
731
+			if ($gd_city != '')
732
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
733
+
734
+
735
+			$wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
736
+			$wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
737
+
738
+			$wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
739
+
740
+			if ($wp->query_vars[$geodir_taxonomy] == '') {
741
+				unset($wp->query_vars[$geodir_taxonomy]);
742
+			} else {
743
+				if (!$is_geodir_taxonomy_term) {
744
+					foreach ($wp->query_vars as $key => $vars) {
745
+						unset($wp->query_vars[$key]);
746
+					}
747
+					$wp->query_vars['error'] = '404';
748
+				}
749
+			}
750
+		}
751
+	}
752 752
 	
753 753
 	// Unset location session if gd page and location not set.
754 754
 	if (isset($wp->query_vars['gd_is_geodir_page']) && !isset($wp->query_vars['gd_country'])) {
755 755
 		$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
756 756
 	}
757 757
 
758
-    if ($gd_session->get('gd_multi_location') == 1) {
759
-        $wp->query_vars['gd_country'] = $gd_session->get('gd_country');
760
-        $wp->query_vars['gd_region'] = $gd_session->get('gd_region');
761
-        $wp->query_vars['gd_city'] = $gd_session->get('gd_city');
762
-    }
758
+	if ($gd_session->get('gd_multi_location') == 1) {
759
+		$wp->query_vars['gd_country'] = $gd_session->get('gd_country');
760
+		$wp->query_vars['gd_region'] = $gd_session->get('gd_region');
761
+		$wp->query_vars['gd_city'] = $gd_session->get('gd_city');
762
+	}
763 763
 
764
-    // now check if there is location parts in the url or not
765
-    if (get_option('geodir_add_location_url')) {        
764
+	// now check if there is location parts in the url or not
765
+	if (get_option('geodir_add_location_url')) {        
766 766
 		if ($geodir_show_location_url == 'all') {
767 767
 		} else if ($geodir_show_location_url == 'country_city') {
768 768
 			 if (isset($wp->query_vars['gd_region']))
769
-                $wp->query_vars['gd_region'] = '';
769
+				$wp->query_vars['gd_region'] = '';
770 770
 		} else if ($geodir_show_location_url == 'region_city') {
771 771
 			if (isset($wp->query_vars['gd_country']))
772
-                $wp->query_vars['gd_country'] = '';
772
+				$wp->query_vars['gd_country'] = '';
773 773
 		} else {
774 774
 			if (isset($wp->query_vars['gd_country']))
775
-                $wp->query_vars['gd_country'] = '';
775
+				$wp->query_vars['gd_country'] = '';
776 776
 
777
-            if (isset($wp->query_vars['gd_region']))
778
-                $wp->query_vars['gd_region'] = '';
777
+			if (isset($wp->query_vars['gd_region']))
778
+				$wp->query_vars['gd_region'] = '';
779 779
 		}
780
-    } else {
781
-        if (isset($wp->query_vars['gd_country']))
782
-            $wp->query_vars['gd_country'] = '';
780
+	} else {
781
+		if (isset($wp->query_vars['gd_country']))
782
+			$wp->query_vars['gd_country'] = '';
783 783
 
784
-        if (isset($wp->query_vars['gd_region']))
785
-            $wp->query_vars['gd_region'] = '';
784
+		if (isset($wp->query_vars['gd_region']))
785
+			$wp->query_vars['gd_region'] = '';
786 786
 
787
-        if (isset($wp->query_vars['gd_city']))
788
-            $wp->query_vars['gd_city'] = '';
789
-    }
787
+		if (isset($wp->query_vars['gd_city']))
788
+			$wp->query_vars['gd_city'] = '';
789
+	}
790 790
 }
791 791
 
792 792
 /**
@@ -800,24 +800,24 @@  discard block
 block discarded – undo
800 800
  */
801 801
 function geodir_custom_post_status()
802 802
 {
803
-    // Virtual Page Status
804
-    register_post_status('virtual', array(
805
-        'label' => _x('Virtual', 'page', 'geodirectory'),
806
-        'public' => true,
807
-        'exclude_from_search' => true,
808
-        'show_in_admin_all_list' => true,
809
-        'show_in_admin_status_list' => true,
810
-        'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
811
-    ));
812
-
813
-    /**
814
-     * Called after we register the custom post status 'Virtual'.
815
-     *
816
-     * Can be use to add more post statuses.
817
-     *
818
-     * @since 1.0.0
819
-     */
820
-    do_action('geodir_custom_post_status');
803
+	// Virtual Page Status
804
+	register_post_status('virtual', array(
805
+		'label' => _x('Virtual', 'page', 'geodirectory'),
806
+		'public' => true,
807
+		'exclude_from_search' => true,
808
+		'show_in_admin_all_list' => true,
809
+		'show_in_admin_status_list' => true,
810
+		'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
811
+	));
812
+
813
+	/**
814
+	 * Called after we register the custom post status 'Virtual'.
815
+	 *
816
+	 * Can be use to add more post statuses.
817
+	 *
818
+	 * @since 1.0.0
819
+	 */
820
+	do_action('geodir_custom_post_status');
821 821
 }
822 822
 
823 823
 /**
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
  */
833 833
 function geodir_get_term_link($termlink, $term, $taxonomy)
834 834
 {
835
-    return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php
835
+	return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php
836 836
 }
837 837
 
838 838
 /**
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
  */
847 847
 function geodir_get_posttype_link($link, $post_type)
848 848
 {
849
-    return geodir_posttype_link($link, $post_type); // taxonomy_functions.php
849
+	return geodir_posttype_link($link, $post_type); // taxonomy_functions.php
850 850
 }
851 851
 
852 852
 /**
@@ -861,13 +861,13 @@  discard block
 block discarded – undo
861 861
  */
862 862
 function exclude_from_wp_list_pages($exclude_array)
863 863
 {
864
-    $pages_ids = array();
865
-    $pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
866
-    foreach ($pages_array as $page) {
867
-        $pages_ids[] = $page->ID;
868
-    }
869
-    $exclude_array = $exclude_array + $pages_ids;
870
-    return $exclude_array;
864
+	$pages_ids = array();
865
+	$pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
866
+	foreach ($pages_array as $page) {
867
+		$pages_ids[] = $page->ID;
868
+	}
869
+	$exclude_array = $exclude_array + $pages_ids;
870
+	return $exclude_array;
871 871
 }
872 872
 
873 873
 /**
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
  */
881 881
 function geodir_exclude_page($query)
882 882
 {
883
-    add_filter('posts_where', 'geodir_exclude_page_where', 100);
884
-    return $query;
883
+	add_filter('posts_where', 'geodir_exclude_page_where', 100);
884
+	return $query;
885 885
 }
886 886
 
887 887
 /**
@@ -896,11 +896,11 @@  discard block
 block discarded – undo
896 896
  */
897 897
 function geodir_exclude_page_where($where)
898 898
 {
899
-    global $wpdb;
900
-    if (is_admin())
901
-        $where .= " AND $wpdb->posts.post_status != 'virtual'";
899
+	global $wpdb;
900
+	if (is_admin())
901
+		$where .= " AND $wpdb->posts.post_status != 'virtual'";
902 902
 
903
-    return $where;
903
+	return $where;
904 904
 }
905 905
 
906 906
 /**
@@ -915,20 +915,20 @@  discard block
 block discarded – undo
915 915
  * @return mixed The taxonomy option value.
916 916
  */
917 917
 function geodir_wpseo_taxonomy_meta( $value, $option = '' ) {
918
-    global $wp_query;
918
+	global $wp_query;
919 919
     
920
-    if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
921
-        $term = $wp_query->get_queried_object();
920
+	if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
921
+		$term = $wp_query->get_queried_object();
922 922
         
923
-        if ( !empty( $term->term_id ) && !empty( $term->taxonomy ) && isset( $value[$term->taxonomy][$term->term_id] ) && in_array( str_replace( 'category', '', $term->taxonomy ), geodir_get_posttypes() ) ) {
924
-            $image  = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) );
923
+		if ( !empty( $term->term_id ) && !empty( $term->taxonomy ) && isset( $value[$term->taxonomy][$term->term_id] ) && in_array( str_replace( 'category', '', $term->taxonomy ), geodir_get_posttypes() ) ) {
924
+			$image  = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) );
925 925
             
926
-            if ( !empty( $image['src'] ) ) {
927
-                $value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src'];
928
-                $value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src'];
929
-            }
930
-        }
931
-    }
932
-    return $value;
926
+			if ( !empty( $image['src'] ) ) {
927
+				$value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src'];
928
+				$value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src'];
929
+			}
930
+		}
931
+	}
932
+	return $value;
933 933
 }
934 934
 add_filter( 'option_wpseo_taxonomy_meta', 'geodir_wpseo_taxonomy_meta', 10, 2 );
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
             if (!empty($args['labels'])) {
72 72
                 foreach ($args['labels'] as $key => $val) {
73
-                    $args['labels'][$key] = __($val, 'geodirectory');// allow translation
73
+                    $args['labels'][$key] = __($val, 'geodirectory'); // allow translation
74 74
                 }
75 75
             }
76 76
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
             if (array_key_exists('rewrite', $args)) {
113 113
                 if (array_key_exists('slug', $args['rewrite']))
114
-                    $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
114
+                    $args['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%';
115 115
             }
116 116
 
117 117
             $geodir_post_types = get_option('geodir_post_types');
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
                 if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125 125
                     if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
-                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
126
+                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%';
127 127
 
128 128
                 update_option('geodir_post_types', $geodir_post_types);
129 129
 
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
 
136 136
             $geodir_taxonomies = get_option('geodir_taxonomies');
137 137
 
138
-            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
139
-                $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
138
+            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type.'category'])) {
139
+                $geodir_taxonomies[$post_type.'category']['listing_slug'] = $listing_slug;
140 140
 
141
-                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
142
-                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
143
-                        if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
144
-                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
141
+                if (array_key_exists('args', $geodir_taxonomies[$post_type.'category']))
142
+                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type.'category']['args']))
143
+                        if (array_key_exists('slug', $geodir_taxonomies[$post_type.'category']['args']['rewrite']))
144
+                            $geodir_taxonomies[$post_type.'category']['args']['rewrite']['slug'] = $listing_slug;
145 145
 
146 146
                 update_option('geodir_taxonomies', $geodir_taxonomies);
147 147
 
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 
150 150
             /* --- update taxonomies (tags) --- */
151 151
             $geodir_taxonomies_tag = get_option('geodir_taxonomies');
152
-            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
153
-                $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
152
+            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type.'_tags'])) {
153
+                $geodir_taxonomies_tag[$post_type.'_tags']['listing_slug'] = $listing_slug.'/tags';
154 154
 
155
-                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
156
-                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
157
-                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
158
-                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
155
+                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type.'_tags']))
156
+                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type.'_tags']['args']))
157
+                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type.'_tags']['args']['rewrite']))
158
+                            $geodir_taxonomies_tag[$post_type.'_tags']['args']['rewrite']['slug'] = $listing_slug.'/tags';
159 159
 
160 160
                 update_option('geodir_taxonomies', $geodir_taxonomies_tag);
161 161
 
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
             $listing_slug = $args['listing_slug'];
206 206
 
207 207
             if (strpos($taxonomy, 'tags')) {
208
-                $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
209
-                $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
208
+                $newrules[$listing_slug.'/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?'.$taxonomy.'=$matches[1]&paged=$matches[2]';
209
+                $newrules[$listing_slug.'/(.+?)/?$'] = 'index.php?'.$taxonomy.'=$matches[1]';
210 210
             } else {
211 211
                 // use this loop to add paging for details page comments paging
212
-                $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
212
+                $newrules[str_replace("/tags", "", $listing_slug).'/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?'.$taxonomy.'=$matches[1]&cpage=$matches[2]';
213 213
             }
214 214
         endforeach;
215 215
     endif;
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     // create rules for location listing
218 218
     $location_page = get_option('geodir_location_page');
219 219
 	
220
-    if($location_page) {
220
+    if ($location_page) {
221 221
         global $wpdb;
222 222
         $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223 223
     }
@@ -247,30 +247,30 @@  discard block
 block discarded – undo
247 247
 		
248 248
 		if ($matches2) {
249 249
 			if ($neighbourhood_active) {
250
-				$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]';
250
+				$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]&gd_neighbourhood=$matches[3]';
251 251
 			}
252
-			$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]';
252
+			$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]';
253 253
 		} else {
254 254
 			if ($neighbourhood_active) {
255
-				$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]';
255
+				$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&gd_neighbourhood=$matches[2]';
256 256
 			}
257 257
 		}
258 258
 		
259
-		$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]';
259
+		$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]';
260 260
 	} else { // country/region/city
261 261
 		if ($neighbourhood_active) {
262
-			$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]';
262
+			$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]';
263 263
 		}
264
-		$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
265
-		$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]';
266
-		$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]';
264
+		$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
265
+		$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]';
266
+		$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]';
267 267
 	}
268 268
 
269 269
     if ($location_page && function_exists('icl_object_id')) {
270
-        foreach(icl_get_languages('skip_missing=N') as $lang){
270
+        foreach (icl_get_languages('skip_missing=N') as $lang) {
271 271
             $alt_page_id = '';
272
-            $alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']);
273
-            if($alt_page_id){
272
+            $alt_page_id = icl_object_id($location_page, 'page', false, $lang['language_code']);
273
+            if ($alt_page_id) {
274 274
                 $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
275 275
 
276 276
 				if ($location_manager && ($hide_country_part || $hide_region_part)) {
@@ -289,29 +289,29 @@  discard block
 block discarded – undo
289 289
 					
290 290
 					if ($matches2) {
291 291
 						if ($neighbourhood_active) {
292
-							$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]';
292
+							$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]&gd_neighbourhood=$matches[3]';
293 293
 						}
294
-						$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]';
294
+						$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]';
295 295
 					} else {
296 296
 						if ($neighbourhood_active) {
297
-							$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]';
297
+							$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&gd_neighbourhood=$matches[2]';
298 298
 						}
299 299
 					}
300 300
 					
301
-					$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]';
301
+					$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]';
302 302
 				} else { // country/region/city
303 303
 					if ($neighbourhood_active) {
304
-						$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]';
304
+						$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]';
305 305
 					}
306
-					$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
307
-					$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]';
308
-					$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]';
306
+					$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
307
+					$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]';
308
+					$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]';
309 309
 				}
310 310
             }
311 311
         }
312 312
     }
313 313
 
314
-    $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page;
314
+    $newrules[$location_prefix.'/?$'] = 'index.php?page_id='.$location_page;
315 315
 
316 316
     $rules = array_merge($newrules, $rules);
317 317
     return $rules;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 #Redirect 301 /location/ /$location_prefix/
341 341
 # END GeoDirectory Rules\n\n
342 342
 EOD;
343
-    return $my_content . $rules;
343
+    return $my_content.$rules;
344 344
 }
345 345
 //add_filter('mod_rewrite_rules', 'geodir_htaccess_contents');
346 346
 
@@ -416,12 +416,12 @@  discard block
 block discarded – undo
416 416
         global $wpdb;
417 417
 
418 418
         $page_for_posts = get_option('page_for_posts');
419
-        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
419
+        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s", $wp->query_vars['pagename']));
420 420
 
421 421
         if (function_exists('icl_object_id')) {
422 422
             $real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
423 423
         }
424
-        if ($real_page_id && $real_page_id!=$page_for_posts) {
424
+        if ($real_page_id && $real_page_id != $page_for_posts) {
425 425
             $wp->query_vars['page_id'] = $real_page_id;
426 426
         }
427 427
     }
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
                             $gd_city = $default_location->city_slug;
470 470
 
471 471
                         $base_location_link = geodir_get_location_link('base');
472
-                        wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
472
+                        wp_redirect($base_location_link.'/'.$gd_country.'/'.$gd_region.'/'.$gd_city);
473 473
                         exit();
474 474
                     }
475 475
                 }
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
         $geodir_set_location_session = true;
531 531
         $geodir_taxonomis = geodir_get_taxonomies('', true);
532 532
 
533
-        if(!empty($geodir_taxonomis)){
533
+        if (!empty($geodir_taxonomis)) {
534 534
             foreach ($geodir_taxonomis as $taxonomy) {
535 535
                 if (array_key_exists($taxonomy, $wp->query_vars)) {
536 536
                     $is_geodir_taxonomy = true;
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 				}
588 588
 
589 589
 
590
-				$geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
590
+				$geodir_term = str_replace('/'.$geodir_last_term, '', $geodir_term, $post_title_replace_count);
591 591
 				if (!$post_title_replace_count)
592 592
 					$geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count);
593 593
 				$geodir_terms = explode('/', $geodir_term);
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
665 665
                             $is_geodir_location_found = true;
666 666
                     }
667
-                }  else if ($geodir_show_location_url == 'region_city') {
667
+                } else if ($geodir_show_location_url == 'region_city') {
668 668
                     if (count($geodir_terms) >= 2) {
669 669
                         $gd_region = urldecode($geodir_terms[0]);
670 670
                         $gd_city = urldecode($geodir_terms[1]);
@@ -723,13 +723,13 @@  discard block
 block discarded – undo
723 723
             $wp->query_vars[$geodir_taxonomy] = $geodir_term;
724 724
             // eliminate location related terms from taxonomy term
725 725
             if ($gd_country != '')
726
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
726
+                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_country).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
727 727
 
728 728
             if ($gd_region != '')
729
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
729
+                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_region).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
730 730
 
731 731
             if ($gd_city != '')
732
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
732
+                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_city).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
733 733
 
734 734
 
735 735
             $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
@@ -914,16 +914,16 @@  discard block
 block discarded – undo
914 914
  * @param string $option Option name.
915 915
  * @return mixed The taxonomy option value.
916 916
  */
917
-function geodir_wpseo_taxonomy_meta( $value, $option = '' ) {
917
+function geodir_wpseo_taxonomy_meta($value, $option = '') {
918 918
     global $wp_query;
919 919
     
920
-    if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
920
+    if (!empty($value) && (is_category() || is_tax())) {
921 921
         $term = $wp_query->get_queried_object();
922 922
         
923
-        if ( !empty( $term->term_id ) && !empty( $term->taxonomy ) && isset( $value[$term->taxonomy][$term->term_id] ) && in_array( str_replace( 'category', '', $term->taxonomy ), geodir_get_posttypes() ) ) {
924
-            $image  = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) );
923
+        if (!empty($term->term_id) && !empty($term->taxonomy) && isset($value[$term->taxonomy][$term->term_id]) && in_array(str_replace('category', '', $term->taxonomy), geodir_get_posttypes())) {
924
+            $image = geodir_get_default_catimage($term->term_id, str_replace('category', '', $term->taxonomy));
925 925
             
926
-            if ( !empty( $image['src'] ) ) {
926
+            if (!empty($image['src'])) {
927 927
                 $value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src'];
928 928
                 $value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src'];
929 929
             }
@@ -931,4 +931,4 @@  discard block
 block discarded – undo
931 931
     }
932 932
     return $value;
933 933
 }
934
-add_filter( 'option_wpseo_taxonomy_meta', 'geodir_wpseo_taxonomy_meta', 10, 2 );
934
+add_filter('option_wpseo_taxonomy_meta', 'geodir_wpseo_taxonomy_meta', 10, 2);
Please login to merge, or discard this patch.
geodirectory-admin/admin_hooks_actions.php 2 patches
Indentation   +1524 added lines, -1524 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
 
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
  */
86 86
 function geodir_conditional_admin_script_load()
87 87
 {
88
-    global $pagenow;
88
+	global $pagenow;
89 89
 	
90 90
 	// Get the current post type
91 91
 	$post_type = geodir_admin_current_post_type();
92 92
 	$geodir_post_types = geodir_get_posttypes();
93 93
     
94 94
 	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')) {
95
-        add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
96
-        add_action('admin_enqueue_scripts', 'geodir_admin_styles');
97
-        add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
98
-    }
95
+		add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
96
+		add_action('admin_enqueue_scripts', 'geodir_admin_styles');
97
+		add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
98
+	}
99 99
 
100
-    add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
100
+	add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
101 101
 
102 102
 }
103 103
 
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function create_default_admin_main_nav()
133 133
 {
134
-    add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
135
-    add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
136
-    add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
137
-    add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
138
-    add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
139
-    //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
134
+	add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
135
+	add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
136
+	add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
137
+	add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
138
+	add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
139
+	//add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
140 140
 
141 141
 }
142 142
 
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
  */
150 150
 function geodir_admin_list_columns()
151 151
 {
152
-    if ($post_types = geodir_get_posttypes()) {
152
+	if ($post_types = geodir_get_posttypes()) {
153 153
 
154
-        foreach ($post_types as $post_type):
155
-            add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
156
-            //Filter-Payment-Manager to show Package
157
-            add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
154
+		foreach ($post_types as $post_type):
155
+			add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
156
+			//Filter-Payment-Manager to show Package
157
+			add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
158 158
 
159
-            add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
160
-        endforeach;
161
-    }
159
+			add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
160
+		endforeach;
161
+	}
162 162
 }
163 163
 
164 164
 /**
@@ -171,15 +171,15 @@  discard block
 block discarded – undo
171 171
  */
172 172
 function geodir_default_admin_main_tabs($tabs)
173 173
 {
174
-    return $tabs = array(
175
-        'general_settings' => array('label' => __('General', 'geodirectory')),
176
-        'design_settings' => array('label' => __('Design', 'geodirectory')),
177
-        'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
178
-        'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
179
-        'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
180
-        'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
181
-
182
-    );
174
+	return $tabs = array(
175
+		'general_settings' => array('label' => __('General', 'geodirectory')),
176
+		'design_settings' => array('label' => __('Design', 'geodirectory')),
177
+		'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
178
+		'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
179
+		'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
180
+		'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
181
+
182
+	);
183 183
 }
184 184
 
185 185
 add_action('do_meta_boxes', 'geodir_remove_image_box');
@@ -192,16 +192,16 @@  discard block
 block discarded – undo
192 192
  */
193 193
 function geodir_remove_image_box()
194 194
 {
195
-    global $post;
195
+	global $post;
196 196
 
197
-    $geodir_posttypes = geodir_get_posttypes();
197
+	$geodir_posttypes = geodir_get_posttypes();
198 198
 
199
-    if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
199
+	if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
200 200
 
201
-        remove_meta_box('postimagediv', $post->post_type, 'side');
202
-        remove_meta_box('revisionsdiv', $post->post_type, 'normal');
201
+		remove_meta_box('postimagediv', $post->post_type, 'side');
202
+		remove_meta_box('revisionsdiv', $post->post_type, 'normal');
203 203
 
204
-    endif;
204
+	endif;
205 205
 
206 206
 }
207 207
 
@@ -216,26 +216,26 @@  discard block
 block discarded – undo
216 216
  */
217 217
 function geodir_meta_box_add()
218 218
 {
219
-    global $post;
219
+	global $post;
220 220
 
221
-    $geodir_post_types = geodir_get_posttypes('array');
222
-    $geodir_posttypes = array_keys($geodir_post_types);
221
+	$geodir_post_types = geodir_get_posttypes('array');
222
+	$geodir_posttypes = array_keys($geodir_post_types);
223 223
 
224
-    if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
224
+	if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
225 225
 
226
-        $geodir_posttype = $post->post_type;
227
-        $post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']);
226
+		$geodir_posttype = $post->post_type;
227
+		$post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']);
228 228
 
229
-        // Filter-Payment-Manager
229
+		// Filter-Payment-Manager
230 230
 
231
-        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
231
+		add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
232 232
 
233
-        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
233
+		add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
234 234
 
235
-        // no need of this box as all fields moved to main information box
236
-        //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
235
+		// no need of this box as all fields moved to main information box
236
+		//add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
237 237
 
238
-    endif;
238
+	endif;
239 239
 
240 240
 }
241 241
 
@@ -259,23 +259,23 @@  discard block
 block discarded – undo
259 259
 function geodir_hide_post_taxonomy_meta_boxes()
260 260
 {
261 261
 
262
-    $geodir_post_types = get_option('geodir_post_types');
262
+	$geodir_post_types = get_option('geodir_post_types');
263 263
 
264
-    if (!empty($geodir_post_types)) {
265
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
264
+	if (!empty($geodir_post_types)) {
265
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
266 266
 
267
-            $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
267
+			$gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
268 268
 
269
-            if(!empty($gd_taxonomy)) {
270
-                foreach ($gd_taxonomy as $tax) {
269
+			if(!empty($gd_taxonomy)) {
270
+				foreach ($gd_taxonomy as $tax) {
271 271
 
272
-                    remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
272
+					remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
273 273
 
274
-                }
275
-            }
274
+				}
275
+			}
276 276
 
277
-        }
278
-    }
277
+		}
278
+	}
279 279
 }
280 280
 
281 281
 add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict');
@@ -289,12 +289,12 @@  discard block
 block discarded – undo
289 289
  */
290 290
 function geodir_add_listing_map_restrict($map_restirct)
291 291
 {
292
-    if (is_admin()) {
293
-        if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
294
-            $map_restirct = false;
295
-        }
296
-    }
297
-    return $map_restirct;
292
+	if (is_admin()) {
293
+		if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
294
+			$map_restirct = false;
295
+		}
296
+	}
297
+	return $map_restirct;
298 298
 }
299 299
 
300 300
 
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
 function geodir_enable_editor_on_notifications($notification)
314 314
 {
315 315
 
316
-    if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
316
+	if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
317 317
 
318
-        foreach ($notification as $key => $value) {
319
-            if ($value['type'] == 'textarea')
320
-                $notification[$key]['type'] = 'editor';
321
-        }
318
+		foreach ($notification as $key => $value) {
319
+			if ($value['type'] == 'textarea')
320
+				$notification[$key]['type'] = 'editor';
321
+		}
322 322
 
323
-    }
323
+	}
324 324
 
325
-    return $notification;
325
+	return $notification;
326 326
 }
327 327
 
328 328
 
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
 function geodir_enable_editor_on_design_settings($design_setting)
340 340
 {
341 341
 
342
-    if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
342
+	if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
343 343
 
344
-        foreach ($design_setting as $key => $value) {
345
-            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
346
-                $design_setting[$key]['type'] = 'editor';
347
-        }
344
+		foreach ($design_setting as $key => $value) {
345
+			if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
346
+				$design_setting[$key]['type'] = 'editor';
347
+		}
348 348
 
349
-    }
349
+	}
350 350
 
351
-    return $design_setting;
351
+	return $design_setting;
352 352
 }
353 353
 
354 354
 /* ----------- START MANAGE CUSTOM FIELDS ---------------- */
@@ -356,15 +356,15 @@  discard block
 block discarded – undo
356 356
 add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom');
357 357
 
358 358
 function geodir_manage_available_fields_predefined($sub_tab){
359
-    if($sub_tab=='custom_fields'){
360
-        geodir_custom_available_fields('predefined');
361
-    }
359
+	if($sub_tab=='custom_fields'){
360
+		geodir_custom_available_fields('predefined');
361
+	}
362 362
 }
363 363
 
364 364
 function geodir_manage_available_fields_custom($sub_tab){
365
-    if($sub_tab=='custom_fields'){
366
-        geodir_custom_available_fields('custom');
367
-    }
365
+	if($sub_tab=='custom_fields'){
366
+		geodir_custom_available_fields('custom');
367
+	}
368 368
 }
369 369
 
370 370
 
@@ -383,16 +383,16 @@  discard block
 block discarded – undo
383 383
 function geodir_manage_available_fields($sub_tab)
384 384
 {
385 385
 
386
-    switch ($sub_tab) {
387
-        case 'custom_fields':
388
-            geodir_custom_available_fields();
389
-            break;
386
+	switch ($sub_tab) {
387
+		case 'custom_fields':
388
+			geodir_custom_available_fields();
389
+			break;
390 390
 
391
-        case 'sorting_options':
392
-            geodir_sorting_options_available_fields();
393
-            break;
391
+		case 'sorting_options':
392
+			geodir_sorting_options_available_fields();
393
+			break;
394 394
 
395
-    }
395
+	}
396 396
 }
397 397
 
398 398
 
@@ -408,16 +408,16 @@  discard block
 block discarded – undo
408 408
 function geodir_manage_selected_fields($sub_tab)
409 409
 {
410 410
 
411
-    switch ($sub_tab) {
412
-        case 'custom_fields':
413
-            geodir_custom_selected_fields();
414
-            break;
411
+	switch ($sub_tab) {
412
+		case 'custom_fields':
413
+			geodir_custom_selected_fields();
414
+			break;
415 415
 
416
-        case 'sorting_options':
417
-            geodir_sorting_options_selected_fields();
418
-            break;
416
+		case 'sorting_options':
417
+			geodir_sorting_options_selected_fields();
418
+			break;
419 419
 
420
-    }
420
+	}
421 421
 }
422 422
 
423 423
 /**
@@ -429,52 +429,52 @@  discard block
 block discarded – undo
429 429
  */
430 430
 function geodir_sorting_options_available_fields()
431 431
 {
432
-    global $wpdb;
433
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
434
-    ?>
432
+	global $wpdb;
433
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
434
+	?>
435 435
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
436 436
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
437 437
     <ul>
438 438
     <?php
439
-        $sort_options = geodir_get_custom_sort_options($listing_type);
439
+		$sort_options = geodir_get_custom_sort_options($listing_type);
440 440
         
441
-        foreach ($sort_options as $key => $val) {
442
-            $val = stripslashes_deep($val); // strip slashes
443
-
444
-            $check_html_variable = $wpdb->get_var(
445
-                $wpdb->prepare(
446
-                    "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
447
-                    array($val['htmlvar_name'], $listing_type, $val['field_type'])
448
-                )
449
-            );
441
+		foreach ($sort_options as $key => $val) {
442
+			$val = stripslashes_deep($val); // strip slashes
443
+
444
+			$check_html_variable = $wpdb->get_var(
445
+				$wpdb->prepare(
446
+					"SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
447
+					array($val['htmlvar_name'], $listing_type, $val['field_type'])
448
+				)
449
+			);
450 450
             
451
-            $display = $check_html_variable ? ' style="display:none;"' : '';
452
-           ?>
451
+			$display = $check_html_variable ? ' style="display:none;"' : '';
452
+		   ?>
453 453
 
454 454
             <li   class="gd-cf-tooltip-wrap" <?php echo $display;?>>
455 455
                 <?php
456
-                if(isset($val['description']) && $val['description']){
457
-                    echo '<div class="gdcf-tooltip">'.$val['description'].'</div>';
458
-                }?>
456
+				if(isset($val['description']) && $val['description']){
457
+					echo '<div class="gdcf-tooltip">'.$val['description'].'</div>';
458
+				}?>
459 459
 
460 460
                 <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'];?>"
461 461
                    title="<?php echo $val['site_title'];?>"
462 462
                    class="gd-draggable-form-items  gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);">
463 463
                     <?php if (isset($val['field_icon']) && strpos($val['field_icon'], 'fa fa-') !== false) {
464
-                        echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>';
465
-                    }elseif(isset($val['field_icon']) && $val['field_icon'] ){
466
-                        echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>';
467
-                    }else{
468
-                        echo '<i class="fa fa-cog" aria-hidden="true"></i>';
469
-                    }?>
464
+						echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>';
465
+					}elseif(isset($val['field_icon']) && $val['field_icon'] ){
466
+						echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>';
467
+					}else{
468
+						echo '<i class="fa fa-cog" aria-hidden="true"></i>';
469
+					}?>
470 470
                     <?php echo $val['site_title'];?>
471 471
                 </a>
472 472
             </li>
473 473
 
474 474
 
475 475
             <?php
476
-        }
477
-    ?>
476
+		}
477
+	?>
478 478
     </ul>
479 479
     <?php
480 480
 }
@@ -488,28 +488,28 @@  discard block
 block discarded – undo
488 488
  */
489 489
 function geodir_sorting_options_selected_fields()
490 490
 {
491
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
492
-    ?>
491
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
492
+	?>
493 493
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
494 494
     <ul class="core">
495 495
     <?php 
496
-        global $wpdb;
496
+		global $wpdb;
497 497
         
498
-        $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)));
498
+		$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)));
499 499
 
500
-        if (!empty($fields)) {
501
-            foreach ($fields as $field) {
502
-                //$result_str = $field->id;
503
-                $result_str = $field;
504
-                $field_type = $field->field_type;
505
-                $field_ins_upd = 'display';
500
+		if (!empty($fields)) {
501
+			foreach ($fields as $field) {
502
+				//$result_str = $field->id;
503
+				$result_str = $field;
504
+				$field_type = $field->field_type;
505
+				$field_ins_upd = 'display';
506 506
 
507
-                $default = false;
507
+				$default = false;
508 508
 
509
-                geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
510
-            }
511
-        }
512
-    ?>
509
+				geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
510
+			}
511
+		}
512
+	?>
513 513
     </ul>
514 514
     <?php
515 515
 }
@@ -522,12 +522,12 @@  discard block
 block discarded – undo
522 522
  */
523 523
 function geodir_custom_fields_custom($post_type=''){
524 524
 
525
-    $custom_fields = array();
525
+	$custom_fields = array();
526 526
 
527
-    /**
528
-     * @see `geodir_custom_fields`
529
-     */
530
-    return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
527
+	/**
528
+	 * @see `geodir_custom_fields`
529
+	 */
530
+	return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
531 531
 }
532 532
 
533 533
 
@@ -540,140 +540,140 @@  discard block
 block discarded – undo
540 540
  */
541 541
 function geodir_custom_fields($post_type=''){
542 542
     
543
-    $custom_fields = array(
544
-        'text' => array(
545
-            'field_type'  =>  'text',
546
-            'class' =>  'gd-text',
547
-            'icon'  =>  'fa fa-minus',
548
-            'name'  =>  __('Text', 'geodirectory'),
549
-            'description' =>  __('Add any sort of text field, text or numbers', 'geodirectory')
550
-        ),
551
-        'datepicker' => array(
552
-            'field_type'  =>  'datepicker',
553
-            'class' =>  'gd-datepicker',
554
-            'icon'  =>  'fa fa-calendar',
555
-            'name'  =>  __('Date', 'geodirectory'),
556
-            'description' =>  __('Adds a date picker.', 'geodirectory')
557
-        ),
558
-        'textarea' => array(
559
-            'field_type'  =>  'textarea',
560
-            'class' =>  'gd-textarea',
561
-            'icon'  =>  'fa fa-bars',
562
-            'name'  =>  __('Textarea', 'geodirectory'),
563
-            'description' =>  __('Adds a textarea', 'geodirectory')
564
-        ),
565
-        'time' => array(
566
-            'field_type'  =>  'time',
567
-            'class' =>  'gd-time',
568
-            'icon' =>  'fa fa-clock-o',
569
-            'name'  =>  __('Time', 'geodirectory'),
570
-            'description' =>  __('Adds a time picker', 'geodirectory')
571
-        ),
572
-        'checkbox' => array(
573
-            'field_type'  =>  'checkbox',
574
-            'class' =>  'gd-checkbox',
575
-            'icon' =>  'fa fa-check-square-o',
576
-            'name'  =>  __('Checkbox', 'geodirectory'),
577
-            'description' =>  __('Adds a checkbox', 'geodirectory')
578
-        ),
579
-        'phone' => array(
580
-            'field_type'  =>  'phone',
581
-            'class' =>  'gd-phone',
582
-            'icon' =>  'fa fa-phone',
583
-            'name'  =>  __('Phone', 'geodirectory'),
584
-            'description' =>  __('Adds a phone input', 'geodirectory')
585
-        ),
586
-        'radio' => array(
587
-            'field_type'  =>  'radio',
588
-            'class' =>  'gd-radio',
589
-            'icon' =>  'fa fa-dot-circle-o',
590
-            'name'  =>  __('Radio', 'geodirectory'),
591
-            'description' =>  __('Adds a radio input', 'geodirectory')
592
-        ),
593
-        'email' => array(
594
-            'field_type'  =>  'email',
595
-            'class' =>  'gd-email',
596
-            'icon' =>  'fa fa-envelope-o',
597
-            'name'  =>  __('Email', 'geodirectory'),
598
-            'description' =>  __('Adds a email input', 'geodirectory')
599
-        ),
600
-        'select' => array(
601
-            'field_type'  =>  'select',
602
-            'class' =>  'gd-select',
603
-            'icon' =>  'fa fa-caret-square-o-down',
604
-            'name'  =>  __('Select', 'geodirectory'),
605
-            'description' =>  __('Adds a select input', 'geodirectory')
606
-        ),
607
-        'multiselect' => array(
608
-            'field_type'  =>  'multiselect',
609
-            'class' =>  'gd-multiselect',
610
-            'icon' =>  'fa fa-caret-square-o-down',
611
-            'name'  =>  __('Multi Select', 'geodirectory'),
612
-            'description' =>  __('Adds a multiselect input', 'geodirectory')
613
-        ),
614
-        'url' => array(
615
-            'field_type'  =>  'url',
616
-            'class' =>  'gd-url',
617
-            'icon' =>  'fa fa-link',
618
-            'name'  =>  __('URL', 'geodirectory'),
619
-            'description' =>  __('Adds a url input', 'geodirectory')
620
-        ),
621
-        'html' => array(
622
-            'field_type'  =>  'html',
623
-            'class' =>  'gd-html',
624
-            'icon' =>  'fa fa-code',
625
-            'name'  =>  __('HTML', 'geodirectory'),
626
-            'description' =>  __('Adds a html input textarea', 'geodirectory')
627
-        ),
628
-        'file' => array(
629
-            'field_type'  =>  'file',
630
-            'class' =>  'gd-file',
631
-            'icon' =>  'fa fa-file',
632
-            'name'  =>  __('File Upload', 'geodirectory'),
633
-            'description' =>  __('Adds a file input', 'geodirectory')
634
-        )
635
-    );
636
-
637
-    /**
638
-     * Filter the custom fields array to be able to add or remove items.
639
-     * 
640
-     * @since 1.6.6
641
-     *
642
-     * @param array $custom_fields {
643
-     *     The custom fields array to be filtered.
644
-     *
645
-     *     @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file.
646
-     *     @type string $class The class for the field in backend.
647
-     *     @type string $icon Can be font-awesome class name or icon image url.
648
-     *     @type string $name The name of the field.
649
-     *     @type string $description A short description about the field.
650
-     *     @type array $defaults {
651
-     *                    Optional. Used to set the default value of the field.
652
-     *
653
-     *                    @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE
654
-     *                    @type int decimal_point limit if using FLOAT data_type
655
-     *                    @type string admin_title The admin title for the field.
656
-     *                    @type string site_title This will be the title for the field on the frontend.
657
-     *                    @type string admin_desc This will be shown below the field on the add listing form.
658
-     *                    @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.
659
-     *                    @type bool is_active If false the field will not be displayed anywhere.
660
-     *                    @type bool for_admin_use If true then only site admin can see and edit this field.
661
-     *                    @type string default_value The default value for the input on the add listing page.
662
-     *                    @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble]
663
-     *                    @type bool is_required If true the field will be required on the add listing page.
664
-     *                    @type string option_values The option values for select and multiselect only
665
-     *                    @type string validation_pattern HTML5 validation pattern (text input only by default).
666
-     *                    @type string validation_msg HTML5 validation message (text input only by default).
667
-     *                    @type string required_msg Required warning message.
668
-     *                    @type string field_icon Icon url or font awesome class.
669
-     *                    @type string css_class Field custom css class for field custom style.
670
-     *                    @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.
671
-     *                    @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)
672
-     *     }
673
-     * }
674
-     * @param string $post_type The post type requested.
675
-     */
676
-    return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
543
+	$custom_fields = array(
544
+		'text' => array(
545
+			'field_type'  =>  'text',
546
+			'class' =>  'gd-text',
547
+			'icon'  =>  'fa fa-minus',
548
+			'name'  =>  __('Text', 'geodirectory'),
549
+			'description' =>  __('Add any sort of text field, text or numbers', 'geodirectory')
550
+		),
551
+		'datepicker' => array(
552
+			'field_type'  =>  'datepicker',
553
+			'class' =>  'gd-datepicker',
554
+			'icon'  =>  'fa fa-calendar',
555
+			'name'  =>  __('Date', 'geodirectory'),
556
+			'description' =>  __('Adds a date picker.', 'geodirectory')
557
+		),
558
+		'textarea' => array(
559
+			'field_type'  =>  'textarea',
560
+			'class' =>  'gd-textarea',
561
+			'icon'  =>  'fa fa-bars',
562
+			'name'  =>  __('Textarea', 'geodirectory'),
563
+			'description' =>  __('Adds a textarea', 'geodirectory')
564
+		),
565
+		'time' => array(
566
+			'field_type'  =>  'time',
567
+			'class' =>  'gd-time',
568
+			'icon' =>  'fa fa-clock-o',
569
+			'name'  =>  __('Time', 'geodirectory'),
570
+			'description' =>  __('Adds a time picker', 'geodirectory')
571
+		),
572
+		'checkbox' => array(
573
+			'field_type'  =>  'checkbox',
574
+			'class' =>  'gd-checkbox',
575
+			'icon' =>  'fa fa-check-square-o',
576
+			'name'  =>  __('Checkbox', 'geodirectory'),
577
+			'description' =>  __('Adds a checkbox', 'geodirectory')
578
+		),
579
+		'phone' => array(
580
+			'field_type'  =>  'phone',
581
+			'class' =>  'gd-phone',
582
+			'icon' =>  'fa fa-phone',
583
+			'name'  =>  __('Phone', 'geodirectory'),
584
+			'description' =>  __('Adds a phone input', 'geodirectory')
585
+		),
586
+		'radio' => array(
587
+			'field_type'  =>  'radio',
588
+			'class' =>  'gd-radio',
589
+			'icon' =>  'fa fa-dot-circle-o',
590
+			'name'  =>  __('Radio', 'geodirectory'),
591
+			'description' =>  __('Adds a radio input', 'geodirectory')
592
+		),
593
+		'email' => array(
594
+			'field_type'  =>  'email',
595
+			'class' =>  'gd-email',
596
+			'icon' =>  'fa fa-envelope-o',
597
+			'name'  =>  __('Email', 'geodirectory'),
598
+			'description' =>  __('Adds a email input', 'geodirectory')
599
+		),
600
+		'select' => array(
601
+			'field_type'  =>  'select',
602
+			'class' =>  'gd-select',
603
+			'icon' =>  'fa fa-caret-square-o-down',
604
+			'name'  =>  __('Select', 'geodirectory'),
605
+			'description' =>  __('Adds a select input', 'geodirectory')
606
+		),
607
+		'multiselect' => array(
608
+			'field_type'  =>  'multiselect',
609
+			'class' =>  'gd-multiselect',
610
+			'icon' =>  'fa fa-caret-square-o-down',
611
+			'name'  =>  __('Multi Select', 'geodirectory'),
612
+			'description' =>  __('Adds a multiselect input', 'geodirectory')
613
+		),
614
+		'url' => array(
615
+			'field_type'  =>  'url',
616
+			'class' =>  'gd-url',
617
+			'icon' =>  'fa fa-link',
618
+			'name'  =>  __('URL', 'geodirectory'),
619
+			'description' =>  __('Adds a url input', 'geodirectory')
620
+		),
621
+		'html' => array(
622
+			'field_type'  =>  'html',
623
+			'class' =>  'gd-html',
624
+			'icon' =>  'fa fa-code',
625
+			'name'  =>  __('HTML', 'geodirectory'),
626
+			'description' =>  __('Adds a html input textarea', 'geodirectory')
627
+		),
628
+		'file' => array(
629
+			'field_type'  =>  'file',
630
+			'class' =>  'gd-file',
631
+			'icon' =>  'fa fa-file',
632
+			'name'  =>  __('File Upload', 'geodirectory'),
633
+			'description' =>  __('Adds a file input', 'geodirectory')
634
+		)
635
+	);
636
+
637
+	/**
638
+	 * Filter the custom fields array to be able to add or remove items.
639
+	 * 
640
+	 * @since 1.6.6
641
+	 *
642
+	 * @param array $custom_fields {
643
+	 *     The custom fields array to be filtered.
644
+	 *
645
+	 *     @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file.
646
+	 *     @type string $class The class for the field in backend.
647
+	 *     @type string $icon Can be font-awesome class name or icon image url.
648
+	 *     @type string $name The name of the field.
649
+	 *     @type string $description A short description about the field.
650
+	 *     @type array $defaults {
651
+	 *                    Optional. Used to set the default value of the field.
652
+	 *
653
+	 *                    @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE
654
+	 *                    @type int decimal_point limit if using FLOAT data_type
655
+	 *                    @type string admin_title The admin title for the field.
656
+	 *                    @type string site_title This will be the title for the field on the frontend.
657
+	 *                    @type string admin_desc This will be shown below the field on the add listing form.
658
+	 *                    @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.
659
+	 *                    @type bool is_active If false the field will not be displayed anywhere.
660
+	 *                    @type bool for_admin_use If true then only site admin can see and edit this field.
661
+	 *                    @type string default_value The default value for the input on the add listing page.
662
+	 *                    @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble]
663
+	 *                    @type bool is_required If true the field will be required on the add listing page.
664
+	 *                    @type string option_values The option values for select and multiselect only
665
+	 *                    @type string validation_pattern HTML5 validation pattern (text input only by default).
666
+	 *                    @type string validation_msg HTML5 validation message (text input only by default).
667
+	 *                    @type string required_msg Required warning message.
668
+	 *                    @type string field_icon Icon url or font awesome class.
669
+	 *                    @type string css_class Field custom css class for field custom style.
670
+	 *                    @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.
671
+	 *                    @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)
672
+	 *     }
673
+	 * }
674
+	 * @param string $post_type The post type requested.
675
+	 */
676
+	return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
677 677
 }
678 678
 
679 679
 /**
@@ -686,19 +686,19 @@  discard block
 block discarded – undo
686 686
  */
687 687
 function geodir_custom_available_fields($type='')
688 688
 {
689
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
690
-    ?>
689
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
690
+	?>
691 691
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
692 692
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" />
693 693
 
694 694
         <?php
695
-        if($type=='predefined'){
696
-            $cfs = geodir_custom_fields_predefined($listing_type);
697
-        }elseif($type=='custom'){
698
-            $cfs = geodir_custom_fields_custom($listing_type);
699
-        }else{
700
-            $cfs = geodir_custom_fields($listing_type);
701
-            ?>
695
+		if($type=='predefined'){
696
+			$cfs = geodir_custom_fields_predefined($listing_type);
697
+		}elseif($type=='custom'){
698
+			$cfs = geodir_custom_fields_custom($listing_type);
699
+		}else{
700
+			$cfs = geodir_custom_fields($listing_type);
701
+			?>
702 702
             <ul class="full gd-cf-tooltip-wrap">
703 703
                 <li>
704 704
                     <div class="gdcf-tooltip">
@@ -719,18 +719,18 @@  discard block
 block discarded – undo
719 719
             </ul>
720 720
 
721 721
             <?php
722
-        }
722
+		}
723 723
 
724
-    if(!empty($cfs)) {
724
+	if(!empty($cfs)) {
725 725
 
726
-        foreach ( $cfs as $id => $cf ) {
727
-            ?>
726
+		foreach ( $cfs as $id => $cf ) {
727
+			?>
728 728
             <ul>
729 729
             <li class="gd-cf-tooltip-wrap">
730 730
                 <?php
731
-                if ( isset( $cf['description'] ) && $cf['description'] ) {
732
-                    echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>';
733
-                } ?>
731
+				if ( isset( $cf['description'] ) && $cf['description'] ) {
732
+					echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>';
733
+				} ?>
734 734
 
735 735
                 <a id="gd-<?php echo $id; ?>"
736 736
                    data-field-custom-type="<?php echo $type; ?>"
@@ -740,21 +740,21 @@  discard block
 block discarded – undo
740 740
                    href="javascript:void(0);">
741 741
 
742 742
                     <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], 'fa fa-' ) !== false ) {
743
-                        echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>';
744
-                    } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
745
-                        echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>';
746
-                    } else {
747
-                        echo '<i class="fa fa-cog" aria-hidden="true"></i>';
748
-                    } ?>
743
+						echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>';
744
+					} elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
745
+						echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>';
746
+					} else {
747
+						echo '<i class="fa fa-cog" aria-hidden="true"></i>';
748
+					} ?>
749 749
                     <?php echo $cf['name']; ?>
750 750
                 </a>
751 751
             </li>
752 752
             <?php
753
-        }
754
-    }else{
755
-        _e('There are no custom fields here yet.', 'geodirectory');
756
-    }
757
-        ?>
753
+		}
754
+	}else{
755
+		_e('There are no custom fields here yet.', 'geodirectory');
756
+	}
757
+		?>
758 758
 
759 759
 
760 760
     </ul>
@@ -773,26 +773,26 @@  discard block
 block discarded – undo
773 773
  */
774 774
 function geodir_custom_selected_fields()
775 775
 {
776
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
777
-    ?>
776
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
777
+	?>
778 778
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
779 779
     <ul class="core">
780 780
     <?php 
781
-        global $wpdb;
782
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
783
-
784
-        if (!empty($fields)) {
785
-            foreach ($fields as $field) {
786
-                //$result_str = $field->id;
787
-                $result_str = $field;
788
-                $field_type = $field->field_type;
789
-                $field_type_key = $field->field_type_key;
790
-                $field_ins_upd = 'display';
791
-
792
-                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key);
793
-            }
794
-        }
795
-        ?></ul>
781
+		global $wpdb;
782
+		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
783
+
784
+		if (!empty($fields)) {
785
+			foreach ($fields as $field) {
786
+				//$result_str = $field->id;
787
+				$result_str = $field;
788
+				$field_type = $field->field_type;
789
+				$field_type_key = $field->field_type_key;
790
+				$field_ins_upd = 'display';
791
+
792
+				geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key);
793
+			}
794
+		}
795
+		?></ul>
796 796
 <?php
797 797
 
798 798
 }
@@ -811,16 +811,16 @@  discard block
 block discarded – undo
811 811
 function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type)
812 812
 {
813 813
 
814
-    switch ($sub_tab) {
815
-        case 'custom_fields':
816
-            $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
817
-            break;
814
+	switch ($sub_tab) {
815
+		case 'custom_fields':
816
+			$heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
817
+			break;
818 818
 
819
-        case 'sorting_options':
820
-            $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
821
-            break;
822
-    }
823
-    return $heading;
819
+		case 'sorting_options':
820
+			$heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
821
+			break;
822
+	}
823
+	return $heading;
824 824
 }
825 825
 
826 826
 
@@ -838,16 +838,16 @@  discard block
 block discarded – undo
838 838
 function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type)
839 839
 {
840 840
 
841
-    switch ($sub_tab) {
842
-        case 'custom_fields':
843
-            $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
844
-            break;
841
+	switch ($sub_tab) {
842
+		case 'custom_fields':
843
+			$heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
844
+			break;
845 845
 
846
-        case 'sorting_options':
847
-            $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
848
-            break;
849
-    }
850
-    return $heading;
846
+		case 'sorting_options':
847
+			$heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
848
+			break;
849
+	}
850
+	return $heading;
851 851
 }
852 852
 
853 853
 
@@ -865,16 +865,16 @@  discard block
 block discarded – undo
865 865
 function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type)
866 866
 {
867 867
 
868
-    switch ($sub_tab) {
869
-        case 'custom_fields':
870
-            $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));;
871
-            break;
868
+	switch ($sub_tab) {
869
+		case 'custom_fields':
870
+			$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));;
871
+			break;
872 872
 
873
-        case 'sorting_options':
874
-            $note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing and search results.<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));
875
-            break;
876
-    }
877
-    return $note;
873
+		case 'sorting_options':
874
+			$note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing and search results.<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));
875
+			break;
876
+	}
877
+	return $note;
878 878
 }
879 879
 
880 880
 
@@ -892,16 +892,16 @@  discard block
 block discarded – undo
892 892
 function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type)
893 893
 {
894 894
 
895
-    switch ($sub_tab) {
896
-        case 'custom_fields':
897
-            $heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
898
-            break;
895
+	switch ($sub_tab) {
896
+		case 'custom_fields':
897
+			$heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
898
+			break;
899 899
 
900
-        case 'sorting_options':
901
-            $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));
902
-            break;
903
-    }
904
-    return $heading;
900
+		case 'sorting_options':
901
+			$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));
902
+			break;
903
+	}
904
+	return $heading;
905 905
 }
906 906
 
907 907
 
@@ -919,16 +919,16 @@  discard block
 block discarded – undo
919 919
 function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type)
920 920
 {
921 921
 
922
-    switch ($sub_tab) {
923
-        case 'custom_fields':
924
-            $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));;
925
-            break;
922
+	switch ($sub_tab) {
923
+		case 'custom_fields':
924
+			$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));;
925
+			break;
926 926
 
927
-        case 'sorting_options':
928
-            $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 and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type));
929
-            break;
930
-    }
931
-    return $note;
927
+		case 'sorting_options':
928
+			$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 and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type));
929
+			break;
930
+	}
931
+	return $note;
932 932
 }
933 933
 
934 934
 
@@ -944,16 +944,16 @@  discard block
 block discarded – undo
944 944
  */
945 945
 function geodir_remove_unnecessary_fields()
946 946
 {
947
-    global $wpdb, $plugin_prefix;
947
+	global $wpdb, $plugin_prefix;
948 948
 
949
-    if (!get_option('geodir_remove_unnecessary_fields')) {
949
+	if (!get_option('geodir_remove_unnecessary_fields')) {
950 950
 
951
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
952
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
951
+		if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
952
+			$wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
953 953
 
954
-        update_option('geodir_remove_unnecessary_fields', '1');
954
+		update_option('geodir_remove_unnecessary_fields', '1');
955 955
 
956
-    }
956
+	}
957 957
 
958 958
 }
959 959
 
@@ -971,25 +971,25 @@  discard block
 block discarded – undo
971 971
  */
972 972
 function geodir_admin_ajax_handler()
973 973
 {
974
-    if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
975
-        $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
976
-        switch ($geodir_admin_ajax_action) {
977
-            case 'diagnosis' :
978
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
979
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
980
-                call_user_func('geodir_diagnose_' . $diagnose_this);
981
-                exit();
982
-                break;
983
-
984
-            case 'diagnosis-fix' :
985
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
986
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
987
-                call_user_func('geodir_diagnose_' . $diagnose_this);
988
-                exit();
989
-                break;
990
-        }
991
-    }
992
-    exit();
974
+	if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
975
+		$geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
976
+		switch ($geodir_admin_ajax_action) {
977
+			case 'diagnosis' :
978
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
979
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
980
+				call_user_func('geodir_diagnose_' . $diagnose_this);
981
+				exit();
982
+				break;
983
+
984
+			case 'diagnosis-fix' :
985
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
986
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
987
+				call_user_func('geodir_diagnose_' . $diagnose_this);
988
+				exit();
989
+				break;
990
+		}
991
+	}
992
+	exit();
993 993
 }
994 994
 
995 995
 
@@ -1007,127 +1007,127 @@  discard block
 block discarded – undo
1007 1007
  */
1008 1008
 function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix)
1009 1009
 {
1010
-    global $wpdb;
1011
-    //$filter_arr['output_str'] .='###'.$table.'###';
1012
-    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
1013
-        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
1014
-        $filter_arr['is_error_during_diagnose'] = true;
1015
-
1016
-    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1017
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
1018
-        $filter_arr['is_error_during_diagnose'] = true;
1019
-        $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>";
1020
-        $filter_arr['is_error_during_diagnose'] = true;
1021
-
1022
-        if ($fix) {
1023
-            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
1024
-            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
1025
-
1026
-            if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
1027
-                //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
1028
-
1029
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
1030
-
1031
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1032
-                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
1033
-                } else {
1034
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1035
-                }
1036
-
1037
-            } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
1038
-
1039
-                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
1040
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
1041
-
1042
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1043
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
1044
-                } else {
1045
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1046
-                }
1047
-
1048
-            } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
1049
-
1050
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
1051
-
1052
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1053
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
1054
-                } else {
1055
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1056
-                }
1057
-
1058
-            }
1059
-
1060
-        }
1061
-
1062
-
1063
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1064
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
1065
-        $filter_arr['is_error_during_diagnose'] = true;
1066
-
1067
-        if ($fix) {
1068
-            if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
1069
-                if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
1070
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
1071
-                } else {
1072
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
1073
-                }
1074
-
1075
-            } 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
1076
-                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
1077
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1078
-                } else {
1079
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1080
-                }
1081
-                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1082
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1083
-                } else {
1084
-                    $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>";
1085
-                }
1086
-            } else {// else rename the original table to _ms_bak
1087
-                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1088
-                    $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>";
1089
-                } else {
1090
-                    $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>";
1091
-                }
1092
-            }
1093
-        }
1094
-
1095
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1096
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
1097
-        $filter_arr['is_error_during_diagnose'] = true;
1098
-
1099
-        if ($fix) {
1100
-            // if original table exists but new does not, rename
1101
-            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1102
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1103
-            } else {
1104
-                $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>";
1105
-            }
1106
-
1107
-        }
1108
-
1109
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1110
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
1111
-        $filter_arr['is_error_during_diagnose'] = true;
1112
-
1113
-        if ($fix) {
1114
-            // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
1115
-            delete_option('geodirlocation_db_version');
1116
-            delete_option('geodirevents_db_version');
1117
-            delete_option('geodir_reviewrating_db_version');
1118
-            delete_option('gdevents_db_version');
1119
-            delete_option('geodirectory_db_version');
1120
-            delete_option('geodirclaim_db_version');
1121
-            delete_option('geodir_custom_posts_db_version');
1122
-            delete_option('geodir_reviewratings_db_version');
1123
-            delete_option('geodiradvancesearch_db_version');
1124
-            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
1125
-        }
1126
-
1127
-    } else {
1128
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
1129
-    }
1130
-    return $filter_arr;
1010
+	global $wpdb;
1011
+	//$filter_arr['output_str'] .='###'.$table.'###';
1012
+	if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
1013
+		$filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
1014
+		$filter_arr['is_error_during_diagnose'] = true;
1015
+
1016
+	} elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1017
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
1018
+		$filter_arr['is_error_during_diagnose'] = true;
1019
+		$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>";
1020
+		$filter_arr['is_error_during_diagnose'] = true;
1021
+
1022
+		if ($fix) {
1023
+			$ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
1024
+			$new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
1025
+
1026
+			if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
1027
+				//$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
1028
+
1029
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
1030
+
1031
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1032
+					$filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
1033
+				} else {
1034
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1035
+				}
1036
+
1037
+			} elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
1038
+
1039
+				$wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
1040
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
1041
+
1042
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1043
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
1044
+				} else {
1045
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1046
+				}
1047
+
1048
+			} elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
1049
+
1050
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
1051
+
1052
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1053
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
1054
+				} else {
1055
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1056
+				}
1057
+
1058
+			}
1059
+
1060
+		}
1061
+
1062
+
1063
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1064
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
1065
+		$filter_arr['is_error_during_diagnose'] = true;
1066
+
1067
+		if ($fix) {
1068
+			if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
1069
+				if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
1070
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
1071
+				} else {
1072
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
1073
+				}
1074
+
1075
+			} 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
1076
+				if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
1077
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1078
+				} else {
1079
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1080
+				}
1081
+				if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1082
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1083
+				} else {
1084
+					$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>";
1085
+				}
1086
+			} else {// else rename the original table to _ms_bak
1087
+				if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1088
+					$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>";
1089
+				} else {
1090
+					$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>";
1091
+				}
1092
+			}
1093
+		}
1094
+
1095
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1096
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
1097
+		$filter_arr['is_error_during_diagnose'] = true;
1098
+
1099
+		if ($fix) {
1100
+			// if original table exists but new does not, rename
1101
+			if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1102
+				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1103
+			} else {
1104
+				$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>";
1105
+			}
1106
+
1107
+		}
1108
+
1109
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1110
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
1111
+		$filter_arr['is_error_during_diagnose'] = true;
1112
+
1113
+		if ($fix) {
1114
+			// if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
1115
+			delete_option('geodirlocation_db_version');
1116
+			delete_option('geodirevents_db_version');
1117
+			delete_option('geodir_reviewrating_db_version');
1118
+			delete_option('gdevents_db_version');
1119
+			delete_option('geodirectory_db_version');
1120
+			delete_option('geodirclaim_db_version');
1121
+			delete_option('geodir_custom_posts_db_version');
1122
+			delete_option('geodir_reviewratings_db_version');
1123
+			delete_option('geodiradvancesearch_db_version');
1124
+			$filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
1125
+		}
1126
+
1127
+	} else {
1128
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
1129
+	}
1130
+	return $filter_arr;
1131 1131
 }
1132 1132
 
1133 1133
 
@@ -1141,53 +1141,53 @@  discard block
 block discarded – undo
1141 1141
  */
1142 1142
 function geodir_diagnose_tags_sync()
1143 1143
 {
1144
-    global $wpdb, $plugin_prefix;
1145
-    $fix = isset($_POST['fix']) ? true : false;
1146
-
1147
-    //if($fix){echo 'true';}else{echo 'false';}
1148
-    $is_error_during_diagnose = false;
1149
-    $output_str = '';
1150
-
1151
-
1152
-    $all_postypes = geodir_get_posttypes();
1153
-
1154
-    if (!empty($all_postypes)) {
1155
-        foreach ($all_postypes as $key) {
1156
-            // update each GD CPT
1157
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
1158
-
1159
-            if (!empty($posts)) {
1160
-
1161
-                foreach ($posts as $p) {
1162
-                    $p->post_type = $key;
1163
-                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1164
-                    if (empty($raw_tags)) {
1165
-                        $post_tags = '';
1166
-                    } else {
1167
-                        $post_tags = implode(",", $raw_tags);
1168
-                    }
1169
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1170
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1171
-
1172
-                }
1173
-                $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1174
-            }
1175
-
1176
-        }
1177
-
1178
-    }
1179
-
1180
-    if ($is_error_during_diagnose) {
1181
-        $info_div_class = "geodir_problem_info";
1182
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1183
-    } else {
1184
-        $info_div_class = "geodir_noproblem_info";
1185
-        $fix_button_txt = '';
1186
-    }
1187
-    echo "<ul class='$info_div_class'>";
1188
-    echo $output_str;
1189
-    echo $fix_button_txt;
1190
-    echo "</ul>";
1144
+	global $wpdb, $plugin_prefix;
1145
+	$fix = isset($_POST['fix']) ? true : false;
1146
+
1147
+	//if($fix){echo 'true';}else{echo 'false';}
1148
+	$is_error_during_diagnose = false;
1149
+	$output_str = '';
1150
+
1151
+
1152
+	$all_postypes = geodir_get_posttypes();
1153
+
1154
+	if (!empty($all_postypes)) {
1155
+		foreach ($all_postypes as $key) {
1156
+			// update each GD CPT
1157
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
1158
+
1159
+			if (!empty($posts)) {
1160
+
1161
+				foreach ($posts as $p) {
1162
+					$p->post_type = $key;
1163
+					$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1164
+					if (empty($raw_tags)) {
1165
+						$post_tags = '';
1166
+					} else {
1167
+						$post_tags = implode(",", $raw_tags);
1168
+					}
1169
+					$tablename = $plugin_prefix . $p->post_type . '_detail';
1170
+					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1171
+
1172
+				}
1173
+				$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1174
+			}
1175
+
1176
+		}
1177
+
1178
+	}
1179
+
1180
+	if ($is_error_during_diagnose) {
1181
+		$info_div_class = "geodir_problem_info";
1182
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1183
+	} else {
1184
+		$info_div_class = "geodir_noproblem_info";
1185
+		$fix_button_txt = '';
1186
+	}
1187
+	echo "<ul class='$info_div_class'>";
1188
+	echo $output_str;
1189
+	echo $fix_button_txt;
1190
+	echo "</ul>";
1191 1191
 
1192 1192
 }
1193 1193
 
@@ -1203,75 +1203,75 @@  discard block
 block discarded – undo
1203 1203
  */
1204 1204
 function geodir_diagnose_cats_sync()
1205 1205
 {
1206
-    global $wpdb, $plugin_prefix;
1207
-    $fix = isset($_POST['fix']) ? true : false;
1206
+	global $wpdb, $plugin_prefix;
1207
+	$fix = isset($_POST['fix']) ? true : false;
1208 1208
 
1209
-    //if($fix){echo 'true';}else{echo 'false';}
1210
-    $is_error_during_diagnose = false;
1211
-    $output_str = '';
1209
+	//if($fix){echo 'true';}else{echo 'false';}
1210
+	$is_error_during_diagnose = false;
1211
+	$output_str = '';
1212 1212
 
1213 1213
 
1214
-    $all_postypes = geodir_get_posttypes();
1214
+	$all_postypes = geodir_get_posttypes();
1215 1215
 
1216
-    if (!empty($all_postypes)) {
1217
-        foreach ($all_postypes as $key) {
1218
-            // update each GD CTP
1219
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
1216
+	if (!empty($all_postypes)) {
1217
+		foreach ($all_postypes as $key) {
1218
+			// update each GD CTP
1219
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
1220 1220
 
1221
-            if (!empty($posts)) {
1221
+			if (!empty($posts)) {
1222 1222
 
1223
-                foreach ($posts as $p) {
1224
-                    $p->post_type = $key;
1225
-                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
1223
+				foreach ($posts as $p) {
1224
+					$p->post_type = $key;
1225
+					$raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
1226 1226
 
1227
-                    if (empty($raw_cats)) {
1228
-                        $post_categories = get_post_meta($p->post_id, 'post_categories', true);
1227
+					if (empty($raw_cats)) {
1228
+						$post_categories = get_post_meta($p->post_id, 'post_categories', true);
1229 1229
 
1230
-                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1231
-                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1232
-                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1233
-                                if (is_numeric($cat_part)) {
1234
-                                    $raw_cats[] = (int)$cat_part;
1235
-                                }
1236
-                            }
1230
+						if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1231
+							$post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1232
+							foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1233
+								if (is_numeric($cat_part)) {
1234
+									$raw_cats[] = (int)$cat_part;
1235
+								}
1236
+							}
1237 1237
 
1238
-                        }
1238
+						}
1239 1239
 
1240
-                        if (!empty($raw_cats)) {
1241
-                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1240
+						if (!empty($raw_cats)) {
1241
+							$term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1242 1242
 
1243
-                        }
1243
+						}
1244 1244
 
1245
-                    }
1245
+					}
1246 1246
 
1247 1247
 
1248
-                    if (empty($raw_cats)) {
1249
-                        $post_cats = '';
1250
-                    } else {
1251
-                        $post_cats = ',' . implode(",", $raw_cats) . ',';
1252
-                    }
1253
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1254
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1255
-                }
1248
+					if (empty($raw_cats)) {
1249
+						$post_cats = '';
1250
+					} else {
1251
+						$post_cats = ',' . implode(",", $raw_cats) . ',';
1252
+					}
1253
+					$tablename = $plugin_prefix . $p->post_type . '_detail';
1254
+					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1255
+				}
1256 1256
 
1257
-            }
1258
-            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1257
+			}
1258
+			$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1259 1259
 
1260
-        }
1260
+		}
1261 1261
 
1262
-    }
1262
+	}
1263 1263
 
1264
-    if ($is_error_during_diagnose) {
1265
-        $info_div_class = "geodir_problem_info";
1266
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1267
-    } else {
1268
-        $info_div_class = "geodir_noproblem_info";
1269
-        $fix_button_txt = '';
1270
-    }
1271
-    echo "<ul class='$info_div_class'>";
1272
-    echo $output_str;
1273
-    echo $fix_button_txt;
1274
-    echo "</ul>";
1264
+	if ($is_error_during_diagnose) {
1265
+		$info_div_class = "geodir_problem_info";
1266
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1267
+	} else {
1268
+		$info_div_class = "geodir_noproblem_info";
1269
+		$fix_button_txt = '';
1270
+	}
1271
+	echo "<ul class='$info_div_class'>";
1272
+	echo $output_str;
1273
+	echo $fix_button_txt;
1274
+	echo "</ul>";
1275 1275
 
1276 1276
 }
1277 1277
 
@@ -1285,61 +1285,61 @@  discard block
 block discarded – undo
1285 1285
  */
1286 1286
 function geodir_diagnose_version_clear()
1287 1287
 {
1288
-    global $wpdb, $plugin_prefix;
1289
-    $fix = isset($_POST['fix']) ? true : false;
1290
-
1291
-    //if($fix){echo 'true';}else{echo 'false';}
1292
-    $is_error_during_diagnose = false;
1293
-    $output_str = '';
1294
-
1295
-
1296
-    $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1297
-        'Payment Manager' => 'geodir_payments_db_version',
1298
-        'GeoDirectory Framework' => 'gdf_db_version',
1299
-        'Advanced Search' => 'geodiradvancesearch_db_version',
1300
-        'Review Rating Manager' => 'geodir_reviewratings_db_version',
1301
-        'Claim Manager' => 'geodirclaim_db_version',
1302
-        'CPT Manager' => 'geodir_custom_posts_db_version',
1303
-        'Location Manager' => 'geodirlocation_db_version',
1304
-        'Payment Manager' => 'geodir_payments_db_version',
1305
-        'Events Manager' => 'geodirevents_db_version',
1306
-    );
1307
-
1308
-    /**
1309
-     * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1310
-     *
1311
-     * @since 1.0.0
1312
-     * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1313
-     */
1314
-    $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1315
-
1316
-    if (!empty($ver_arr)) {
1317
-        foreach ($ver_arr as $key => $val) {
1318
-            if (delete_option($val)) {
1319
-                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1320
-            } else {
1321
-                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1322
-            }
1323
-
1324
-        }
1325
-
1326
-        if ($output_str) {
1327
-            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1328
-        }
1329
-
1330
-    }
1331
-
1332
-    if ($is_error_during_diagnose) {
1333
-        $info_div_class = "geodir_problem_info";
1334
-        $fix_button_txt = "";
1335
-    } else {
1336
-        $info_div_class = "geodir_noproblem_info";
1337
-        $fix_button_txt = '';
1338
-    }
1339
-    echo "<ul class='$info_div_class'>";
1340
-    echo $output_str;
1341
-    echo $fix_button_txt;
1342
-    echo "</ul>";
1288
+	global $wpdb, $plugin_prefix;
1289
+	$fix = isset($_POST['fix']) ? true : false;
1290
+
1291
+	//if($fix){echo 'true';}else{echo 'false';}
1292
+	$is_error_during_diagnose = false;
1293
+	$output_str = '';
1294
+
1295
+
1296
+	$gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1297
+		'Payment Manager' => 'geodir_payments_db_version',
1298
+		'GeoDirectory Framework' => 'gdf_db_version',
1299
+		'Advanced Search' => 'geodiradvancesearch_db_version',
1300
+		'Review Rating Manager' => 'geodir_reviewratings_db_version',
1301
+		'Claim Manager' => 'geodirclaim_db_version',
1302
+		'CPT Manager' => 'geodir_custom_posts_db_version',
1303
+		'Location Manager' => 'geodirlocation_db_version',
1304
+		'Payment Manager' => 'geodir_payments_db_version',
1305
+		'Events Manager' => 'geodirevents_db_version',
1306
+	);
1307
+
1308
+	/**
1309
+	 * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1310
+	 *
1311
+	 * @since 1.0.0
1312
+	 * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1313
+	 */
1314
+	$ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1315
+
1316
+	if (!empty($ver_arr)) {
1317
+		foreach ($ver_arr as $key => $val) {
1318
+			if (delete_option($val)) {
1319
+				$output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1320
+			} else {
1321
+				$output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1322
+			}
1323
+
1324
+		}
1325
+
1326
+		if ($output_str) {
1327
+			$output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1328
+		}
1329
+
1330
+	}
1331
+
1332
+	if ($is_error_during_diagnose) {
1333
+		$info_div_class = "geodir_problem_info";
1334
+		$fix_button_txt = "";
1335
+	} else {
1336
+		$info_div_class = "geodir_noproblem_info";
1337
+		$fix_button_txt = '';
1338
+	}
1339
+	echo "<ul class='$info_div_class'>";
1340
+	echo $output_str;
1341
+	echo $fix_button_txt;
1342
+	echo "</ul>";
1343 1343
 
1344 1344
 }
1345 1345
 
@@ -1353,59 +1353,59 @@  discard block
 block discarded – undo
1353 1353
  */
1354 1354
 function geodir_diagnose_ratings()
1355 1355
 {
1356
-    global $wpdb;
1357
-    $fix = isset($_POST['fix']) ? true : false;
1358
-
1359
-    //if($fix){echo 'true';}else{echo 'false';}
1360
-    $is_error_during_diagnose = false;
1361
-    $output_str = '';
1362
-
1363
-    // check review locations
1364
-    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")) {
1365
-        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1366
-        $is_error_during_diagnose = true;
1367
-
1368
-        if ($fix) {
1369
-            if (geodir_fix_review_location()) {
1370
-                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1371
-            } else {
1372
-                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1373
-            }
1374
-        }
1375
-
1376
-    } else {
1377
-        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1378
-    }
1379
-
1380
-    // check review content
1381
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1382
-        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1383
-        $is_error_during_diagnose = true;
1384
-
1385
-        if ($fix) {
1386
-            if (geodir_fix_review_content()) {
1387
-                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1388
-            } else {
1389
-                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1390
-            }
1391
-        }
1392
-
1393
-    } else {
1394
-        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1395
-    }
1396
-
1397
-
1398
-    if ($is_error_during_diagnose) {
1399
-        $info_div_class = "geodir_problem_info";
1400
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1401
-    } else {
1402
-        $info_div_class = "geodir_noproblem_info";
1403
-        $fix_button_txt = '';
1404
-    }
1405
-    echo "<ul class='$info_div_class'>";
1406
-    echo $output_str;
1407
-    echo $fix_button_txt;
1408
-    echo "</ul>";
1356
+	global $wpdb;
1357
+	$fix = isset($_POST['fix']) ? true : false;
1358
+
1359
+	//if($fix){echo 'true';}else{echo 'false';}
1360
+	$is_error_during_diagnose = false;
1361
+	$output_str = '';
1362
+
1363
+	// check review locations
1364
+	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")) {
1365
+		$output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1366
+		$is_error_during_diagnose = true;
1367
+
1368
+		if ($fix) {
1369
+			if (geodir_fix_review_location()) {
1370
+				$output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1371
+			} else {
1372
+				$output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1373
+			}
1374
+		}
1375
+
1376
+	} else {
1377
+		$output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1378
+	}
1379
+
1380
+	// check review content
1381
+	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1382
+		$output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1383
+		$is_error_during_diagnose = true;
1384
+
1385
+		if ($fix) {
1386
+			if (geodir_fix_review_content()) {
1387
+				$output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1388
+			} else {
1389
+				$output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1390
+			}
1391
+		}
1392
+
1393
+	} else {
1394
+		$output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1395
+	}
1396
+
1397
+
1398
+	if ($is_error_during_diagnose) {
1399
+		$info_div_class = "geodir_problem_info";
1400
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1401
+	} else {
1402
+		$info_div_class = "geodir_noproblem_info";
1403
+		$fix_button_txt = '';
1404
+	}
1405
+	echo "<ul class='$info_div_class'>";
1406
+	echo $output_str;
1407
+	echo $fix_button_txt;
1408
+	echo "</ul>";
1409 1409
 
1410 1410
 }
1411 1411
 
@@ -1419,57 +1419,57 @@  discard block
 block discarded – undo
1419 1419
  */
1420 1420
 function geodir_diagnose_multisite_conversion()
1421 1421
 {
1422
-    global $wpdb;
1423
-    $fix = isset($_POST['fix']) ? true : false;
1424
-    //if($fix){echo 'true';}else{echo 'false';}
1425
-    $is_error_during_diagnose = false;
1426
-    $output_str = '';
1427
-
1428
-    $filter_arr = array();
1429
-    $filter_arr['output_str'] = $output_str;
1430
-    $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1431
-    $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1432
-        'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1433
-        'geodir_post_icon' => __('Post icon', 'geodirectory'),
1434
-        'geodir_attachments' => __('Attachments', 'geodirectory'),
1435
-        'geodir_post_review' => __('Reviews', 'geodirectory'),
1436
-        'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1437
-        'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1438
-    );
1439
-
1440
-    // allow other addons to hook in and add their checks
1441
-
1442
-    /**
1443
-     * Filter the array of tables.
1444
-     *
1445
-     * 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.
1446
-     *
1447
-     * @since 1.0.0
1448
-     * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1449
-     */
1450
-    $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1451
-
1452
-    foreach ($table_arr as $table => $table_name) {
1453
-        // Diagnose table
1454
-        $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1455
-    }
1456
-
1457
-
1458
-    $output_str = $filter_arr['output_str'];
1459
-    $is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1460
-
1461
-
1462
-    if ($is_error_during_diagnose) {
1463
-        $info_div_class = "geodir_problem_info";
1464
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1465
-    } else {
1466
-        $info_div_class = "geodir_noproblem_info";
1467
-        $fix_button_txt = '';
1468
-    }
1469
-    echo "<ul class='$info_div_class'>";
1470
-    echo $output_str;
1471
-    echo $fix_button_txt;
1472
-    echo "</ul>";
1422
+	global $wpdb;
1423
+	$fix = isset($_POST['fix']) ? true : false;
1424
+	//if($fix){echo 'true';}else{echo 'false';}
1425
+	$is_error_during_diagnose = false;
1426
+	$output_str = '';
1427
+
1428
+	$filter_arr = array();
1429
+	$filter_arr['output_str'] = $output_str;
1430
+	$filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1431
+	$table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1432
+		'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1433
+		'geodir_post_icon' => __('Post icon', 'geodirectory'),
1434
+		'geodir_attachments' => __('Attachments', 'geodirectory'),
1435
+		'geodir_post_review' => __('Reviews', 'geodirectory'),
1436
+		'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1437
+		'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1438
+	);
1439
+
1440
+	// allow other addons to hook in and add their checks
1441
+
1442
+	/**
1443
+	 * Filter the array of tables.
1444
+	 *
1445
+	 * 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.
1446
+	 *
1447
+	 * @since 1.0.0
1448
+	 * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1449
+	 */
1450
+	$table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1451
+
1452
+	foreach ($table_arr as $table => $table_name) {
1453
+		// Diagnose table
1454
+		$filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1455
+	}
1456
+
1457
+
1458
+	$output_str = $filter_arr['output_str'];
1459
+	$is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1460
+
1461
+
1462
+	if ($is_error_during_diagnose) {
1463
+		$info_div_class = "geodir_problem_info";
1464
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1465
+	} else {
1466
+		$info_div_class = "geodir_noproblem_info";
1467
+		$fix_button_txt = '';
1468
+	}
1469
+	echo "<ul class='$info_div_class'>";
1470
+	echo $output_str;
1471
+	echo $fix_button_txt;
1472
+	echo "</ul>";
1473 1473
 }
1474 1474
 
1475 1475
 /**
@@ -1487,39 +1487,39 @@  discard block
 block discarded – undo
1487 1487
  */
1488 1488
 function geodir_fix_virtual_page($slug, $page_title, $old_id, $option)
1489 1489
 {
1490
-    global $wpdb, $current_user;
1491
-
1492
-    if (!empty($old_id)) {
1493
-        wp_delete_post($old_id, true);
1494
-    }//delete post if already there
1495
-    else {
1496
-        $page_found = $wpdb->get_var(
1497
-            $wpdb->prepare(
1498
-                "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1499
-                array($slug)
1500
-            )
1501
-        );
1502
-        wp_delete_post($page_found, true);
1503
-
1504
-    }
1505
-
1506
-    $page_data = array(
1507
-        'post_status' => 'publish',
1508
-        'post_type' => 'page',
1509
-        'post_author' => $current_user->ID,
1510
-        'post_name' => $slug,
1511
-        'post_title' => $page_title,
1512
-        'post_content' => '',
1513
-        'post_parent' => 0,
1514
-        'comment_status' => 'closed'
1515
-    );
1516
-    $page_id = wp_insert_post($page_data);
1517
-    update_option($option, $page_id);
1518
-    if ($page_id) {
1519
-        return true;
1520
-    } else {
1521
-        return false;
1522
-    }
1490
+	global $wpdb, $current_user;
1491
+
1492
+	if (!empty($old_id)) {
1493
+		wp_delete_post($old_id, true);
1494
+	}//delete post if already there
1495
+	else {
1496
+		$page_found = $wpdb->get_var(
1497
+			$wpdb->prepare(
1498
+				"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1499
+				array($slug)
1500
+			)
1501
+		);
1502
+		wp_delete_post($page_found, true);
1503
+
1504
+	}
1505
+
1506
+	$page_data = array(
1507
+		'post_status' => 'publish',
1508
+		'post_type' => 'page',
1509
+		'post_author' => $current_user->ID,
1510
+		'post_name' => $slug,
1511
+		'post_title' => $page_title,
1512
+		'post_content' => '',
1513
+		'post_parent' => 0,
1514
+		'comment_status' => 'closed'
1515
+	);
1516
+	$page_id = wp_insert_post($page_data);
1517
+	update_option($option, $page_id);
1518
+	if ($page_id) {
1519
+		return true;
1520
+	} else {
1521
+		return false;
1522
+	}
1523 1523
 }
1524 1524
 
1525 1525
 /**
@@ -1531,212 +1531,212 @@  discard block
 block discarded – undo
1531 1531
  */
1532 1532
 function geodir_diagnose_default_pages()
1533 1533
 {
1534
-    global $wpdb;
1535
-    $is_error_during_diagnose = false;
1536
-    $output_str = '';
1537
-    $fix = isset($_POST['fix']) ? true : false;
1538
-
1539
-    //////////////////////////////////
1540
-    /* Diagnose GD Home Page Starts */
1541
-    //////////////////////////////////
1542
-    $option_value = get_option('geodir_home_page');
1543
-    $page = get_post($option_value);
1544
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1545
-
1546
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1547
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1548
-    else {
1549
-        $is_error_during_diagnose = true;
1550
-        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1551
-        if ($fix) {
1552
-            if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1553
-                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1554
-            } else {
1555
-                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1556
-            }
1557
-        }
1558
-    }
1559
-
1560
-    ////////////////////////////////
1561
-    /* Diagnose GD Home Page Ends */
1562
-    ////////////////////////////////
1563
-
1564
-    //////////////////////////////////
1565
-    /* Diagnose Add Listing Page Starts */
1566
-    //////////////////////////////////
1567
-    $option_value = get_option('geodir_add_listing_page');
1568
-    $page = get_post($option_value);
1569
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1570
-
1571
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1572
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1573
-    else {
1574
-        $is_error_during_diagnose = true;
1575
-        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1576
-        if ($fix) {
1577
-            if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1578
-                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1579
-            } else {
1580
-                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1581
-            }
1582
-        }
1583
-    }
1584
-
1585
-    ////////////////////////////////
1586
-    /* Diagnose Add Listing Page Ends */
1587
-    ////////////////////////////////
1588
-
1589
-
1590
-    //////////////////////////////////
1591
-    /* Diagnose Listing Preview Page Starts */
1592
-    //////////////////////////////////
1593
-    $option_value = get_option('geodir_preview_page');
1594
-    $page = get_post($option_value);
1595
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1596
-
1597
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1598
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1599
-    else {
1600
-        $is_error_during_diagnose = true;
1601
-        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1602
-        if ($fix) {
1603
-            if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1604
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1605
-            } else {
1606
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1607
-            }
1608
-        }
1609
-    }
1610
-
1611
-    ////////////////////////////////
1612
-    /* Diagnose Listing Preview Page Ends */
1613
-    ////////////////////////////////
1614
-
1615
-    //////////////////////////////////
1616
-    /* Diagnose Listing Success Page Starts */
1617
-    //////////////////////////////////
1618
-    $option_value = get_option('geodir_success_page');
1619
-    $page = get_post($option_value);
1620
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1621
-
1622
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1623
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1624
-    else {
1625
-        $is_error_during_diagnose = true;
1626
-        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1627
-        if ($fix) {
1628
-            if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1629
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1630
-            } else {
1631
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1632
-            }
1633
-        }
1634
-    }
1635
-
1636
-    ////////////////////////////////
1637
-    /* Diagnose Listing Sucess Page Ends */
1638
-    ////////////////////////////////
1639
-
1640
-    //////////////////////////////////
1641
-    /* Diagnose Info Page Starts */
1642
-    //////////////////////////////////
1643
-    $option_value = get_option('geodir_info_page');
1644
-    $page = get_post($option_value);
1645
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1646
-
1647
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1648
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1649
-    else {
1650
-        $is_error_during_diagnose = true;
1651
-        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1652
-        if ($fix) {
1653
-            if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1654
-                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1655
-            } else {
1656
-                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1657
-            }
1658
-        }
1659
-    }
1660
-
1661
-    ////////////////////////////////
1662
-    /* Diagnose Info Page Ends */
1663
-    ////////////////////////////////
1664
-
1665
-    //////////////////////////////////
1666
-    /* Diagnose Login Page Starts */
1667
-    //////////////////////////////////
1668
-    $option_value = get_option('geodir_login_page');
1669
-    $page = get_post($option_value);
1670
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1671
-
1672
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1673
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1674
-    else {
1675
-        $is_error_during_diagnose = true;
1676
-        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1677
-        if ($fix) {
1678
-            if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1679
-                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1680
-            } else {
1681
-                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1682
-            }
1683
-        }
1684
-    }
1685
-
1686
-    ////////////////////////////////
1687
-    /* Diagnose Info Page Ends */
1688
-    ////////////////////////////////
1689
-
1690
-    //////////////////////////////////
1691
-    /* Diagnose Location Page Starts */
1692
-    //////////////////////////////////
1693
-    $option_value = get_option('geodir_location_page');
1694
-    $page = get_post($option_value);
1695
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1696
-
1697
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1698
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1699
-    else {
1700
-        $is_error_during_diagnose = true;
1701
-        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1702
-        if ($fix) {
1703
-            if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1704
-                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1705
-            } else {
1706
-                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1707
-            }
1708
-        }
1709
-    }
1710
-
1711
-    ////////////////////////////////
1712
-    /* Diagnose Location Page Ends */
1713
-    ////////////////////////////////
1714
-
1715
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1716
-    /**
1717
-     * This action is called at the end of the GD Tools page check function.
1718
-     *
1719
-     * @since 1.5.2
1720
-     */
1721
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1722
-
1723
-    $output_str = $page_chk_arr['output_str'];
1724
-    $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1725
-
1726
-    if ($is_error_during_diagnose) {
1727
-        if ($fix) {
1728
-            flush_rewrite_rules();
1729
-        }
1730
-        $info_div_class = "geodir_problem_info";
1731
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1732
-    } else {
1733
-        $info_div_class = "geodir_noproblem_info";
1734
-        $fix_button_txt = '';
1735
-    }
1736
-    echo "<ul class='$info_div_class'>";
1737
-    echo $output_str;
1738
-    echo $fix_button_txt;
1739
-    echo "</ul>";
1534
+	global $wpdb;
1535
+	$is_error_during_diagnose = false;
1536
+	$output_str = '';
1537
+	$fix = isset($_POST['fix']) ? true : false;
1538
+
1539
+	//////////////////////////////////
1540
+	/* Diagnose GD Home Page Starts */
1541
+	//////////////////////////////////
1542
+	$option_value = get_option('geodir_home_page');
1543
+	$page = get_post($option_value);
1544
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1545
+
1546
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1547
+		$output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1548
+	else {
1549
+		$is_error_during_diagnose = true;
1550
+		$output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1551
+		if ($fix) {
1552
+			if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1553
+				$output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1554
+			} else {
1555
+				$output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1556
+			}
1557
+		}
1558
+	}
1559
+
1560
+	////////////////////////////////
1561
+	/* Diagnose GD Home Page Ends */
1562
+	////////////////////////////////
1563
+
1564
+	//////////////////////////////////
1565
+	/* Diagnose Add Listing Page Starts */
1566
+	//////////////////////////////////
1567
+	$option_value = get_option('geodir_add_listing_page');
1568
+	$page = get_post($option_value);
1569
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1570
+
1571
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1572
+		$output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1573
+	else {
1574
+		$is_error_during_diagnose = true;
1575
+		$output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1576
+		if ($fix) {
1577
+			if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1578
+				$output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1579
+			} else {
1580
+				$output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1581
+			}
1582
+		}
1583
+	}
1584
+
1585
+	////////////////////////////////
1586
+	/* Diagnose Add Listing Page Ends */
1587
+	////////////////////////////////
1588
+
1589
+
1590
+	//////////////////////////////////
1591
+	/* Diagnose Listing Preview Page Starts */
1592
+	//////////////////////////////////
1593
+	$option_value = get_option('geodir_preview_page');
1594
+	$page = get_post($option_value);
1595
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1596
+
1597
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1598
+		$output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1599
+	else {
1600
+		$is_error_during_diagnose = true;
1601
+		$output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1602
+		if ($fix) {
1603
+			if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1604
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1605
+			} else {
1606
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1607
+			}
1608
+		}
1609
+	}
1610
+
1611
+	////////////////////////////////
1612
+	/* Diagnose Listing Preview Page Ends */
1613
+	////////////////////////////////
1614
+
1615
+	//////////////////////////////////
1616
+	/* Diagnose Listing Success Page Starts */
1617
+	//////////////////////////////////
1618
+	$option_value = get_option('geodir_success_page');
1619
+	$page = get_post($option_value);
1620
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1621
+
1622
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1623
+		$output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1624
+	else {
1625
+		$is_error_during_diagnose = true;
1626
+		$output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1627
+		if ($fix) {
1628
+			if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1629
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1630
+			} else {
1631
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1632
+			}
1633
+		}
1634
+	}
1635
+
1636
+	////////////////////////////////
1637
+	/* Diagnose Listing Sucess Page Ends */
1638
+	////////////////////////////////
1639
+
1640
+	//////////////////////////////////
1641
+	/* Diagnose Info Page Starts */
1642
+	//////////////////////////////////
1643
+	$option_value = get_option('geodir_info_page');
1644
+	$page = get_post($option_value);
1645
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1646
+
1647
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1648
+		$output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1649
+	else {
1650
+		$is_error_during_diagnose = true;
1651
+		$output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1652
+		if ($fix) {
1653
+			if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1654
+				$output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1655
+			} else {
1656
+				$output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1657
+			}
1658
+		}
1659
+	}
1660
+
1661
+	////////////////////////////////
1662
+	/* Diagnose Info Page Ends */
1663
+	////////////////////////////////
1664
+
1665
+	//////////////////////////////////
1666
+	/* Diagnose Login Page Starts */
1667
+	//////////////////////////////////
1668
+	$option_value = get_option('geodir_login_page');
1669
+	$page = get_post($option_value);
1670
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1671
+
1672
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1673
+		$output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1674
+	else {
1675
+		$is_error_during_diagnose = true;
1676
+		$output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1677
+		if ($fix) {
1678
+			if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1679
+				$output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1680
+			} else {
1681
+				$output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1682
+			}
1683
+		}
1684
+	}
1685
+
1686
+	////////////////////////////////
1687
+	/* Diagnose Info Page Ends */
1688
+	////////////////////////////////
1689
+
1690
+	//////////////////////////////////
1691
+	/* Diagnose Location Page Starts */
1692
+	//////////////////////////////////
1693
+	$option_value = get_option('geodir_location_page');
1694
+	$page = get_post($option_value);
1695
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1696
+
1697
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1698
+		$output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1699
+	else {
1700
+		$is_error_during_diagnose = true;
1701
+		$output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1702
+		if ($fix) {
1703
+			if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1704
+				$output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1705
+			} else {
1706
+				$output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1707
+			}
1708
+		}
1709
+	}
1710
+
1711
+	////////////////////////////////
1712
+	/* Diagnose Location Page Ends */
1713
+	////////////////////////////////
1714
+
1715
+	$page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1716
+	/**
1717
+	 * This action is called at the end of the GD Tools page check function.
1718
+	 *
1719
+	 * @since 1.5.2
1720
+	 */
1721
+	$page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1722
+
1723
+	$output_str = $page_chk_arr['output_str'];
1724
+	$is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1725
+
1726
+	if ($is_error_during_diagnose) {
1727
+		if ($fix) {
1728
+			flush_rewrite_rules();
1729
+		}
1730
+		$info_div_class = "geodir_problem_info";
1731
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1732
+	} else {
1733
+		$info_div_class = "geodir_noproblem_info";
1734
+		$fix_button_txt = '';
1735
+	}
1736
+	echo "<ul class='$info_div_class'>";
1737
+	echo $output_str;
1738
+	echo $fix_button_txt;
1739
+	echo "</ul>";
1740 1740
 
1741 1741
 }
1742 1742
 
@@ -1748,26 +1748,26 @@  discard block
 block discarded – undo
1748 1748
  * @global object $wpdb WordPress Database object.
1749 1749
  */
1750 1750
 function geodir_diagnose_load_db_language() {
1751
-    global $wpdb;
1751
+	global $wpdb;
1752 1752
 	
1753 1753
 	$is_error_during_diagnose = geodirectory_load_db_language();
1754 1754
 
1755
-    $output_str = '';
1756
-    $fix_button_txt = '';
1755
+	$output_str = '';
1756
+	$fix_button_txt = '';
1757 1757
 
1758
-    if ($is_error_during_diagnose) {
1759
-        $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>";
1758
+	if ($is_error_during_diagnose) {
1759
+		$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>";
1760 1760
 		$info_div_class = "geodir_problem_info";
1761
-    } else {
1762
-        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1761
+	} else {
1762
+		$output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1763 1763
 		$info_div_class = "geodir_noproblem_info";
1764
-        $fix_button_txt = '';
1765
-    }
1764
+		$fix_button_txt = '';
1765
+	}
1766 1766
     
1767 1767
 	echo "<ul class='$info_div_class'>";
1768
-    echo $output_str;
1769
-    echo $fix_button_txt;
1770
-    echo "</ul>";
1768
+	echo $output_str;
1769
+	echo $fix_button_txt;
1770
+	echo "</ul>";
1771 1771
 
1772 1772
 }
1773 1773
 
@@ -1798,23 +1798,23 @@  discard block
 block discarded – undo
1798 1798
  */
1799 1799
 function geodir_posts_clauses_request($clauses)
1800 1800
 {
1801
-    global $wpdb, $wp_query, $plugin_prefix;
1801
+	global $wpdb, $wp_query, $plugin_prefix;
1802 1802
 
1803
-    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'])) {
1804
-        $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1803
+	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'])) {
1804
+		$table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1805 1805
 
1806
-        $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1807
-        $clauses['join'] = $join;
1806
+		$join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1807
+		$clauses['join'] = $join;
1808 1808
 
1809
-        $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1810
-        $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';
1811
-        $clauses['fields'] = $fields;
1809
+		$fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1810
+		$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';
1811
+		$clauses['fields'] = $fields;
1812 1812
 
1813
-        $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1814
-        $orderby = 'gd_expire ' . $order;
1815
-        $clauses['orderby'] = $orderby;
1816
-    }
1817
-    return $clauses;
1813
+		$order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1814
+		$orderby = 'gd_expire ' . $order;
1815
+		$clauses['orderby'] = $orderby;
1816
+	}
1817
+	return $clauses;
1818 1818
 }
1819 1819
 
1820 1820
 
@@ -1835,7 +1835,7 @@  discard block
 block discarded – undo
1835 1835
  */
1836 1836
 function gd_theme_switch_compat_check()
1837 1837
 {
1838
-    gd_set_theme_compat();
1838
+	gd_set_theme_compat();
1839 1839
 }
1840 1840
 
1841 1841
 /**
@@ -1848,27 +1848,27 @@  discard block
 block discarded – undo
1848 1848
  */
1849 1849
 function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\")
1850 1850
 {
1851
-    if (function_exists('str_getcsv')) {
1852
-        $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1853
-    } else {
1854
-        global $current_user;
1855
-        $upload_dir = wp_upload_dir();
1856
-
1857
-        $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1858
-        $handle = fopen($file, 'w');
1859
-
1860
-        fwrite($handle, $input);
1861
-        fclose($handle);
1862
-
1863
-        $handle = fopen($file, 'rt');
1864
-        if (PHP_VERSION >= '5.3.0') {
1865
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1866
-        } else {
1867
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1868
-        }
1869
-        fclose($handle);
1870
-    }
1871
-    return $fgetcsv;
1851
+	if (function_exists('str_getcsv')) {
1852
+		$fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1853
+	} else {
1854
+		global $current_user;
1855
+		$upload_dir = wp_upload_dir();
1856
+
1857
+		$file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1858
+		$handle = fopen($file, 'w');
1859
+
1860
+		fwrite($handle, $input);
1861
+		fclose($handle);
1862
+
1863
+		$handle = fopen($file, 'rt');
1864
+		if (PHP_VERSION >= '5.3.0') {
1865
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1866
+		} else {
1867
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1868
+		}
1869
+		fclose($handle);
1870
+	}
1871
+	return $fgetcsv;
1872 1872
 }
1873 1873
 
1874 1874
 add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv');
@@ -1883,375 +1883,375 @@  discard block
 block discarded – undo
1883 1883
  */
1884 1884
 function geodir_ajax_import_csv()
1885 1885
 {
1886
-    error_reporting(0); // hide error to get clean json response
1886
+	error_reporting(0); // hide error to get clean json response
1887 1887
 
1888
-    global $wpdb, $plugin_prefix, $current_user;
1889
-    $uploads = wp_upload_dir();
1890
-    ini_set('auto_detect_line_endings', true);
1888
+	global $wpdb, $plugin_prefix, $current_user;
1889
+	$uploads = wp_upload_dir();
1890
+	ini_set('auto_detect_line_endings', true);
1891 1891
 	
1892 1892
 	$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
1893 1893
 
1894
-    $task = isset($_POST['task']) ? $_POST['task'] : '';
1895
-    $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1896
-    $filename = $uploadedFile;
1897
-
1898
-    $uploads = wp_upload_dir();
1899
-    $uploads_dir = $uploads['path'];
1900
-    $image_name_arr = explode('/', $filename);
1901
-    $filename = end($image_name_arr);
1902
-    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1903
-    $return = array();
1904
-    $return['file'] = $uploadedFile;
1905
-    $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1906
-
1907
-    if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1908
-        $wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1909
-
1910
-        if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1911
-            $return['error'] = NULL;
1912
-
1913
-            $return['rows'] = 0;
1914
-
1915
-
1916
-
1917
-                if (($handle = fopen($target_path, "r")) !== FALSE) {
1918
-                    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1919
-                        if(is_array($data) && !empty($data)) {
1920
-                            $file[] = '"' . implode('","', $data) . '"';
1921
-                        }
1922
-                    }
1923
-                    fclose($handle);
1924
-                    $file = $file;
1925
-                }
1926
-
1927
-
1928
-
1929
-                $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1930
-
1931
-
1932
-            if (!$return['rows'] > 0) {
1933
-                $return['error'] = __('No data found in csv file.', 'geodirectory');
1934
-            }
1935
-        }
1936
-    }
1937
-    if ($task == 'prepare' || !empty($return['error'])) {
1938
-        echo json_encode($return);
1939
-        exit;
1940
-    }
1941
-
1942
-    $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
1943
-    $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
1944
-    $count = $importlimit;
1945
-    $requested_limit = $importlimit;
1946
-    $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
1947
-
1948
-    if ($count < $totRecords) {
1949
-        $count = $tmpCnt + $count;
1950
-        if ($count > $totRecords) {
1951
-            $count = $totRecords;
1952
-        }
1953
-    } else {
1954
-        $count = $totRecords;
1955
-    }
1956
-
1957
-    $total_records = 0;
1958
-    $rowcount = 0;
1959
-    $address_invalid = 0;
1960
-    $blank_address = 0;
1961
-    $upload_files = 0;
1962
-    $invalid_post_type = 0;
1963
-    $invalid_title = 0;
1964
-    $customKeyarray = array();
1965
-    $gd_post_info = array();
1966
-    $post_location = array();
1967
-    $countpost = 0;
1968
-
1969
-    if (!empty($file)) {
1970
-        $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
1971
-        $customKeyarray = $columns;
1972
-
1973
-        if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
1974
-            $return['error'] = CSV_INVAILD_FILE;
1975
-            echo json_encode($return);
1976
-            exit;
1977
-        }
1978
-
1979
-        for ($i = 1; $i <= $importlimit; $i++) {
1980
-            $current_index = $tmpCnt + $i;
1981
-            if (isset($file[$current_index])) {
1982
-                $total_records++;
1983
-
1984
-                $buffer = geodir_str_getcsv($file[$current_index]);
1985
-                $post_title = addslashes($buffer[0]);
1986
-                $current_post_author = $buffer[1];
1987
-                $post_desc = addslashes($buffer[2]);
1988
-                $post_cat = array();
1989
-                $catids_arr = array();
1990
-                $post_cat = trim($buffer[3]); // comma seperated category name
1991
-
1992
-                if ($post_cat) {
1993
-                    $post_cat_arr = explode(',', $post_cat);
1994
-
1995
-                    for ($c = 0; $c < count($post_cat_arr); $c++) {
1996
-                        $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1997
-
1998
-                        if (!empty($buffer[5])) {
1999
-                            if (in_array($buffer[5], geodir_get_posttypes())) {
2000
-
2001
-                                $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
2002
-
2003
-                                if (get_term_by('name', $catid, $p_taxonomy[0])) {
2004
-                                    $cat = get_term_by('name', $catid, $p_taxonomy[0]);
2005
-                                    $catids_arr[] = $cat->slug;
2006
-                                } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
2007
-                                    $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2008
-                                    $catids_arr[] = $cat->slug;
2009
-                                } else {
2010
-                                    $ret = wp_insert_term($catid, $p_taxonomy[0]);
2011
-                                    if ($ret && !is_wp_error($ret)) {
2012
-                                        if (get_term_by('name', $catid, $p_taxonomy[0])) {
2013
-                                            $cat = get_term_by('name', $catid, $p_taxonomy[0]);
2014
-                                            $catids_arr[] = $cat->slug;
2015
-                                        } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
2016
-                                            $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2017
-                                            $catids_arr[] = $cat->slug;
2018
-                                        }
2019
-                                    }
2020
-                                }
2021
-                            }
2022
-                        }
2023
-                    }
2024
-                }
2025
-
2026
-                if (!$catids_arr) {
2027
-                    $catids_arr[] = 1;
2028
-                }
2029
-
2030
-                $post_tags = trim($buffer[4]); // comma seperated tags
2031
-
2032
-                $tag_arr = '';
2033
-                if ($post_tags) {
2034
-                    $tag_arr = explode(',', $post_tags);
2035
-                }
2036
-
2037
-                $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
2038
-
2039
-                $error = '';
2040
-                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
2041
-                    $invalid_post_type++;
2042
-                    continue;
2043
-                }
2044
-
2045
-                if ($post_title != '') {
2046
-                    $menu_order = 0;
2047
-                    $image_folder_name = 'uplaod/';
2048
-
2049
-                    $image_names = array();
2050
-
2051
-                    for ($c = 5; $c < count($customKeyarray); $c++) {
2052
-                        $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
2053
-
2054
-                        if ($customKeyarray[$c] == 'IMAGE') {
2055
-                            $buffer[$c] = trim($buffer[$c]);
2056
-
2057
-                            if (!empty($buffer[$c])) {
2058
-                                $image_names[] = $buffer[$c];
2059
-                            }
2060
-                        }
2061
-
2062
-                        if ($customKeyarray[$c] == 'alive_days') {
2063
-                            if ($buffer[$c] != '0' && $buffer[$c] != '') {
2064
-                                $submitdata = date('Y-m-d');
2065
-
2066
-                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
2067
-                            } else {
2068
-                                $gd_post_info['expire_date'] = 'Never';
2069
-                            }
2070
-                        }
2071
-
2072
-                        if ($customKeyarray[$c] == 'post_city') {
2073
-                            $post_city = addslashes($buffer[$c]);
2074
-                        }
2075
-
2076
-                        if ($customKeyarray[$c] == 'post_region') {
2077
-                            $post_region = addslashes($buffer[$c]);
2078
-                        }
2079
-
2080
-                        if ($customKeyarray[$c] == 'post_country') {
2081
-                            $post_country = addslashes($buffer[$c]);
2082
-                        }
2083
-
2084
-                        if ($customKeyarray[$c] == 'post_latitude') {
2085
-                            $post_latitude = addslashes($buffer[$c]);
2086
-                        }
2087
-
2088
-                        if ($customKeyarray[$c] == 'post_longitude') {
2089
-                            $post_longitude = addslashes($buffer[$c]);
2090
-                        }
1894
+	$task = isset($_POST['task']) ? $_POST['task'] : '';
1895
+	$uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1896
+	$filename = $uploadedFile;
1897
+
1898
+	$uploads = wp_upload_dir();
1899
+	$uploads_dir = $uploads['path'];
1900
+	$image_name_arr = explode('/', $filename);
1901
+	$filename = end($image_name_arr);
1902
+	$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1903
+	$return = array();
1904
+	$return['file'] = $uploadedFile;
1905
+	$return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1906
+
1907
+	if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1908
+		$wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1909
+
1910
+		if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1911
+			$return['error'] = NULL;
1912
+
1913
+			$return['rows'] = 0;
1914
+
1915
+
1916
+
1917
+				if (($handle = fopen($target_path, "r")) !== FALSE) {
1918
+					while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1919
+						if(is_array($data) && !empty($data)) {
1920
+							$file[] = '"' . implode('","', $data) . '"';
1921
+						}
1922
+					}
1923
+					fclose($handle);
1924
+					$file = $file;
1925
+				}
1926
+
1927
+
1928
+
1929
+				$return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1930
+
1931
+
1932
+			if (!$return['rows'] > 0) {
1933
+				$return['error'] = __('No data found in csv file.', 'geodirectory');
1934
+			}
1935
+		}
1936
+	}
1937
+	if ($task == 'prepare' || !empty($return['error'])) {
1938
+		echo json_encode($return);
1939
+		exit;
1940
+	}
1941
+
1942
+	$totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
1943
+	$importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
1944
+	$count = $importlimit;
1945
+	$requested_limit = $importlimit;
1946
+	$tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
1947
+
1948
+	if ($count < $totRecords) {
1949
+		$count = $tmpCnt + $count;
1950
+		if ($count > $totRecords) {
1951
+			$count = $totRecords;
1952
+		}
1953
+	} else {
1954
+		$count = $totRecords;
1955
+	}
1956
+
1957
+	$total_records = 0;
1958
+	$rowcount = 0;
1959
+	$address_invalid = 0;
1960
+	$blank_address = 0;
1961
+	$upload_files = 0;
1962
+	$invalid_post_type = 0;
1963
+	$invalid_title = 0;
1964
+	$customKeyarray = array();
1965
+	$gd_post_info = array();
1966
+	$post_location = array();
1967
+	$countpost = 0;
1968
+
1969
+	if (!empty($file)) {
1970
+		$columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
1971
+		$customKeyarray = $columns;
1972
+
1973
+		if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
1974
+			$return['error'] = CSV_INVAILD_FILE;
1975
+			echo json_encode($return);
1976
+			exit;
1977
+		}
1978
+
1979
+		for ($i = 1; $i <= $importlimit; $i++) {
1980
+			$current_index = $tmpCnt + $i;
1981
+			if (isset($file[$current_index])) {
1982
+				$total_records++;
1983
+
1984
+				$buffer = geodir_str_getcsv($file[$current_index]);
1985
+				$post_title = addslashes($buffer[0]);
1986
+				$current_post_author = $buffer[1];
1987
+				$post_desc = addslashes($buffer[2]);
1988
+				$post_cat = array();
1989
+				$catids_arr = array();
1990
+				$post_cat = trim($buffer[3]); // comma seperated category name
1991
+
1992
+				if ($post_cat) {
1993
+					$post_cat_arr = explode(',', $post_cat);
1994
+
1995
+					for ($c = 0; $c < count($post_cat_arr); $c++) {
1996
+						$catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1997
+
1998
+						if (!empty($buffer[5])) {
1999
+							if (in_array($buffer[5], geodir_get_posttypes())) {
2000
+
2001
+								$p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
2002
+
2003
+								if (get_term_by('name', $catid, $p_taxonomy[0])) {
2004
+									$cat = get_term_by('name', $catid, $p_taxonomy[0]);
2005
+									$catids_arr[] = $cat->slug;
2006
+								} else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
2007
+									$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2008
+									$catids_arr[] = $cat->slug;
2009
+								} else {
2010
+									$ret = wp_insert_term($catid, $p_taxonomy[0]);
2011
+									if ($ret && !is_wp_error($ret)) {
2012
+										if (get_term_by('name', $catid, $p_taxonomy[0])) {
2013
+											$cat = get_term_by('name', $catid, $p_taxonomy[0]);
2014
+											$catids_arr[] = $cat->slug;
2015
+										} elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
2016
+											$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2017
+											$catids_arr[] = $cat->slug;
2018
+										}
2019
+									}
2020
+								}
2021
+							}
2022
+						}
2023
+					}
2024
+				}
2025
+
2026
+				if (!$catids_arr) {
2027
+					$catids_arr[] = 1;
2028
+				}
2029
+
2030
+				$post_tags = trim($buffer[4]); // comma seperated tags
2031
+
2032
+				$tag_arr = '';
2033
+				if ($post_tags) {
2034
+					$tag_arr = explode(',', $post_tags);
2035
+				}
2036
+
2037
+				$table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
2038
+
2039
+				$error = '';
2040
+				if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
2041
+					$invalid_post_type++;
2042
+					continue;
2043
+				}
2044
+
2045
+				if ($post_title != '') {
2046
+					$menu_order = 0;
2047
+					$image_folder_name = 'uplaod/';
2048
+
2049
+					$image_names = array();
2050
+
2051
+					for ($c = 5; $c < count($customKeyarray); $c++) {
2052
+						$gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
2053
+
2054
+						if ($customKeyarray[$c] == 'IMAGE') {
2055
+							$buffer[$c] = trim($buffer[$c]);
2056
+
2057
+							if (!empty($buffer[$c])) {
2058
+								$image_names[] = $buffer[$c];
2059
+							}
2060
+						}
2061
+
2062
+						if ($customKeyarray[$c] == 'alive_days') {
2063
+							if ($buffer[$c] != '0' && $buffer[$c] != '') {
2064
+								$submitdata = date('Y-m-d');
2065
+
2066
+								$gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
2067
+							} else {
2068
+								$gd_post_info['expire_date'] = 'Never';
2069
+							}
2070
+						}
2071
+
2072
+						if ($customKeyarray[$c] == 'post_city') {
2073
+							$post_city = addslashes($buffer[$c]);
2074
+						}
2075
+
2076
+						if ($customKeyarray[$c] == 'post_region') {
2077
+							$post_region = addslashes($buffer[$c]);
2078
+						}
2079
+
2080
+						if ($customKeyarray[$c] == 'post_country') {
2081
+							$post_country = addslashes($buffer[$c]);
2082
+						}
2083
+
2084
+						if ($customKeyarray[$c] == 'post_latitude') {
2085
+							$post_latitude = addslashes($buffer[$c]);
2086
+						}
2087
+
2088
+						if ($customKeyarray[$c] == 'post_longitude') {
2089
+							$post_longitude = addslashes($buffer[$c]);
2090
+						}
2091 2091
 						
2092 2092
 						// Post status
2093 2093
 						if ($customKeyarray[$c] == 'post_status') {
2094
-                            $post_status = sanitize_key( $buffer[$c] );
2095
-                        }
2096
-                    }
2097
-
2098
-                    /* ================ before array create ============== */
2099
-                    $location_result = geodir_get_default_location();
2100
-                    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'] == '')) {
2101
-                        $blank_address++;
2102
-                        continue;
2103
-                    } else if ($location_result->location_id == 0) {
2104
-                        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))) {
2105
-                            $address_invalid++;
2106
-                            continue;
2107
-                        }
2108
-                    }
2094
+							$post_status = sanitize_key( $buffer[$c] );
2095
+						}
2096
+					}
2097
+
2098
+					/* ================ before array create ============== */
2099
+					$location_result = geodir_get_default_location();
2100
+					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'] == '')) {
2101
+						$blank_address++;
2102
+						continue;
2103
+					} else if ($location_result->location_id == 0) {
2104
+						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))) {
2105
+							$address_invalid++;
2106
+							continue;
2107
+						}
2108
+					}
2109 2109
 					
2110 2110
 					// Default post status
2111 2111
 					$default_status = 'publish';
2112 2112
 					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
2113 2113
 					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
2114 2114
 
2115
-                    $my_post['post_title'] = $post_title;
2116
-                    $my_post['post_content'] = $post_desc;
2117
-                    $my_post['post_type'] = addslashes($buffer[5]);
2118
-                    $my_post['post_author'] = $current_post_author;
2119
-                    $my_post['post_status'] = $post_status;
2120
-                    $my_post['post_category'] = $catids_arr;
2121
-                    $my_post['post_tags'] = $tag_arr;
2122
-
2123
-                    $gd_post_info['post_tags'] = $tag_arr;
2124
-                    $gd_post_info['post_title'] = $post_title;
2125
-                    $gd_post_info['post_status'] = $post_status;
2126
-                    $gd_post_info['submit_time'] = time();
2127
-                    $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
2128
-
2129
-                    $last_postid = wp_insert_post($my_post);
2130
-                    $countpost++;
2131
-
2132
-                    // Check if we need to save post location as new location
2133
-                    if ($location_result->location_id > 0) {
2134
-                        if (isset($post_city) && isset($post_region)) {
2135
-                            $request_info['post_location'] = array(
2136
-                                'city' => $post_city,
2137
-                                'region' => $post_region,
2138
-                                'country' => $post_country,
2139
-                                'geo_lat' => $post_latitude,
2140
-                                'geo_lng' => $post_longitude
2141
-                            );
2142
-
2143
-                            $post_location_info = $request_info['post_location'];
2144
-                            if ($location_id = geodir_add_new_location($post_location_info))
2145
-                                $post_location_id = $location_id;
2146
-                        } else {
2147
-                            $post_location_id = 0;
2148
-                        }
2149
-                    } else {
2150
-                        $post_location_id = 0;
2151
-                    }
2152
-
2153
-                    /* ------- get default package info ----- */
2154
-                    $payment_info = array();
2155
-                    $package_info = array();
2156
-
2157
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2158
-                    $package_id = '';
2159
-                    if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2160
-                        $package_id = $gd_post_info['package_id'];
2161
-                    }
2162
-
2163
-                    if (!empty($package_info)) {
2164
-                        $payment_info['package_id'] = $package_info['pid'];
2165
-
2166
-                        if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2167
-                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2168
-                        } else {
2169
-                            $payment_info['expire_date'] = 'Never';
2170
-                        }
2171
-
2172
-                        $gd_post_info = array_merge($gd_post_info, $payment_info);
2173
-                    }
2174
-
2175
-                    $gd_post_info['post_location_id'] = $post_location_id;
2176
-
2177
-                    $post_type = get_post_type($last_postid);
2178
-
2179
-                    $table = $plugin_prefix . $post_type . '_detail';
2180
-
2181
-                    geodir_save_post_info($last_postid, $gd_post_info);
2182
-
2183
-                    if (!empty($image_names)) {
2184
-                        $upload_files++;
2185
-                        $menu_order = 1;
2186
-
2187
-                        foreach ($image_names as $image_name) {
2188
-                            $img_name_arr = explode('.', $image_name);
2189
-
2190
-                            $uploads = wp_upload_dir();
2191
-                            $sub_dir = $uploads['subdir'];
2192
-
2193
-                            $arr_file_type = wp_check_filetype($image_name);
2194
-                            $uploaded_file_type = $arr_file_type['type'];
2195
-
2196
-                            $attachment = array();
2197
-                            $attachment['post_id'] = $last_postid;
2198
-                            $attachment['title'] = $img_name_arr[0];
2199
-                            $attachment['content'] = '';
2200
-                            $attachment['file'] = $sub_dir . '/' . $image_name;
2201
-                            $attachment['mime_type'] = $uploaded_file_type;
2202
-                            $attachment['menu_order'] = $menu_order;
2203
-                            $attachment['is_featured'] = 0;
2204
-
2205
-                            $attachment_set = '';
2206
-
2207
-                            foreach ($attachment as $key => $val) {
2208
-                                if ($val != '')
2209
-                                    $attachment_set .= $key . " = '" . $val . "', ";
2210
-                            }
2211
-                            $attachment_set = trim($attachment_set, ", ");
2212
-
2213
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2214
-
2215
-                            if ($menu_order == 1) {
2216
-                                $post_type = get_post_type($last_postid);
2217
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2218
-                            }
2219
-                            $menu_order++;
2220
-                        }
2221
-                    }
2222
-
2223
-                    $gd_post_info['package_id'] = $package_id;
2224
-
2225
-                    /** This action is documented in geodirectory-functions/post-functions.php */
2226
-                    do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
2227
-
2228
-                    if (!empty($buffer[5])) {
2229
-                        if (in_array($buffer[5], geodir_get_posttypes())) {
2230
-                            $taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2231
-                            wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2232
-                            wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2233
-
2234
-                            $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2235
-                            $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2236
-                            geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2237
-                        }
2238
-                    }
2239
-                } else {
2240
-                    $invalid_title++;
2241
-                }
2242
-            }
2243
-        }
2244
-    }
2245
-    $return['rowcount'] = $countpost;
2246
-    $return['invalidcount'] = $address_invalid;
2247
-    $return['blank_address'] = $blank_address;
2248
-    $return['upload_files'] = $upload_files;
2249
-    $return['invalid_post_type'] = $invalid_post_type;
2250
-    $return['invalid_title'] = $invalid_title;
2251
-    $return['total_records'] = $total_records;
2252
-
2253
-    echo json_encode($return);
2254
-    exit;
2115
+					$my_post['post_title'] = $post_title;
2116
+					$my_post['post_content'] = $post_desc;
2117
+					$my_post['post_type'] = addslashes($buffer[5]);
2118
+					$my_post['post_author'] = $current_post_author;
2119
+					$my_post['post_status'] = $post_status;
2120
+					$my_post['post_category'] = $catids_arr;
2121
+					$my_post['post_tags'] = $tag_arr;
2122
+
2123
+					$gd_post_info['post_tags'] = $tag_arr;
2124
+					$gd_post_info['post_title'] = $post_title;
2125
+					$gd_post_info['post_status'] = $post_status;
2126
+					$gd_post_info['submit_time'] = time();
2127
+					$gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
2128
+
2129
+					$last_postid = wp_insert_post($my_post);
2130
+					$countpost++;
2131
+
2132
+					// Check if we need to save post location as new location
2133
+					if ($location_result->location_id > 0) {
2134
+						if (isset($post_city) && isset($post_region)) {
2135
+							$request_info['post_location'] = array(
2136
+								'city' => $post_city,
2137
+								'region' => $post_region,
2138
+								'country' => $post_country,
2139
+								'geo_lat' => $post_latitude,
2140
+								'geo_lng' => $post_longitude
2141
+							);
2142
+
2143
+							$post_location_info = $request_info['post_location'];
2144
+							if ($location_id = geodir_add_new_location($post_location_info))
2145
+								$post_location_id = $location_id;
2146
+						} else {
2147
+							$post_location_id = 0;
2148
+						}
2149
+					} else {
2150
+						$post_location_id = 0;
2151
+					}
2152
+
2153
+					/* ------- get default package info ----- */
2154
+					$payment_info = array();
2155
+					$package_info = array();
2156
+
2157
+					$package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2158
+					$package_id = '';
2159
+					if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2160
+						$package_id = $gd_post_info['package_id'];
2161
+					}
2162
+
2163
+					if (!empty($package_info)) {
2164
+						$payment_info['package_id'] = $package_info['pid'];
2165
+
2166
+						if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2167
+							$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2168
+						} else {
2169
+							$payment_info['expire_date'] = 'Never';
2170
+						}
2171
+
2172
+						$gd_post_info = array_merge($gd_post_info, $payment_info);
2173
+					}
2174
+
2175
+					$gd_post_info['post_location_id'] = $post_location_id;
2176
+
2177
+					$post_type = get_post_type($last_postid);
2178
+
2179
+					$table = $plugin_prefix . $post_type . '_detail';
2180
+
2181
+					geodir_save_post_info($last_postid, $gd_post_info);
2182
+
2183
+					if (!empty($image_names)) {
2184
+						$upload_files++;
2185
+						$menu_order = 1;
2186
+
2187
+						foreach ($image_names as $image_name) {
2188
+							$img_name_arr = explode('.', $image_name);
2189
+
2190
+							$uploads = wp_upload_dir();
2191
+							$sub_dir = $uploads['subdir'];
2192
+
2193
+							$arr_file_type = wp_check_filetype($image_name);
2194
+							$uploaded_file_type = $arr_file_type['type'];
2195
+
2196
+							$attachment = array();
2197
+							$attachment['post_id'] = $last_postid;
2198
+							$attachment['title'] = $img_name_arr[0];
2199
+							$attachment['content'] = '';
2200
+							$attachment['file'] = $sub_dir . '/' . $image_name;
2201
+							$attachment['mime_type'] = $uploaded_file_type;
2202
+							$attachment['menu_order'] = $menu_order;
2203
+							$attachment['is_featured'] = 0;
2204
+
2205
+							$attachment_set = '';
2206
+
2207
+							foreach ($attachment as $key => $val) {
2208
+								if ($val != '')
2209
+									$attachment_set .= $key . " = '" . $val . "', ";
2210
+							}
2211
+							$attachment_set = trim($attachment_set, ", ");
2212
+
2213
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2214
+
2215
+							if ($menu_order == 1) {
2216
+								$post_type = get_post_type($last_postid);
2217
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2218
+							}
2219
+							$menu_order++;
2220
+						}
2221
+					}
2222
+
2223
+					$gd_post_info['package_id'] = $package_id;
2224
+
2225
+					/** This action is documented in geodirectory-functions/post-functions.php */
2226
+					do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
2227
+
2228
+					if (!empty($buffer[5])) {
2229
+						if (in_array($buffer[5], geodir_get_posttypes())) {
2230
+							$taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2231
+							wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2232
+							wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2233
+
2234
+							$post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2235
+							$post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2236
+							geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2237
+						}
2238
+					}
2239
+				} else {
2240
+					$invalid_title++;
2241
+				}
2242
+			}
2243
+		}
2244
+	}
2245
+	$return['rowcount'] = $countpost;
2246
+	$return['invalidcount'] = $address_invalid;
2247
+	$return['blank_address'] = $blank_address;
2248
+	$return['upload_files'] = $upload_files;
2249
+	$return['invalid_post_type'] = $invalid_post_type;
2250
+	$return['invalid_title'] = $invalid_title;
2251
+	$return['total_records'] = $total_records;
2252
+
2253
+	echo json_encode($return);
2254
+	exit;
2255 2255
 }
2256 2256
 
2257 2257
 // Add the tab in left sidebar menu fro import & export page.
@@ -2271,9 +2271,9 @@  discard block
 block discarded – undo
2271 2271
  * @param $post object $post The post object of the post being saved.
2272 2272
  */
2273 2273
 function geodir_update_location_prefix($post_id,$post){
2274
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2275
-        update_option('geodir_location_prefix',$post->post_name);
2276
-    }
2274
+	if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2275
+		update_option('geodir_location_prefix',$post->post_name);
2276
+	}
2277 2277
 
2278 2278
 }
2279 2279
 
@@ -2284,50 +2284,50 @@  discard block
 block discarded – undo
2284 2284
 function geodir_ga_callback(){
2285 2285
 
2286 2286
 if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2287
-    $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2288
-    $code = "code=".$_REQUEST['code'];
2289
-    $grant_type = "&grant_type=authorization_code";
2290
-    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2291
-    $client_id = "&client_id=".get_option('geodir_ga_client_id');
2292
-    $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2287
+	$oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2288
+	$code = "code=".$_REQUEST['code'];
2289
+	$grant_type = "&grant_type=authorization_code";
2290
+	$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2291
+	$client_id = "&client_id=".get_option('geodir_ga_client_id');
2292
+	$client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2293 2293
 
2294
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2294
+	$auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2295 2295
 
2296
-    $response = wp_remote_post($auth_url, array('timeout' => 15));
2296
+	$response = wp_remote_post($auth_url, array('timeout' => 15));
2297 2297
 
2298
-    //print_r($response);
2298
+	//print_r($response);
2299 2299
 
2300
-    $error_msg =  __('Something went wrong','geodirectory');
2301
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2300
+	$error_msg =  __('Something went wrong','geodirectory');
2301
+	if(!empty($response['response']['code']) && $response['response']['code']==200){
2302 2302
 
2303
-        $parts = json_decode($response['body']);
2304
-        //print_r($parts);
2305
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2306
-        else{
2303
+		$parts = json_decode($response['body']);
2304
+		//print_r($parts);
2305
+		if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2306
+		else{
2307 2307
 
2308
-            update_option('gd_ga_access_token', $parts->access_token);
2309
-            update_option('gd_ga_refresh_token', $parts->refresh_token);
2310
-            ?><script>window.close();</script><?php
2311
-        }
2308
+			update_option('gd_ga_access_token', $parts->access_token);
2309
+			update_option('gd_ga_refresh_token', $parts->refresh_token);
2310
+			?><script>window.close();</script><?php
2311
+		}
2312 2312
 
2313 2313
 
2314
-    }
2315
-    elseif(!empty($response['response']['code'])) {
2316
-        $parts = json_decode($response['body']);
2314
+	}
2315
+	elseif(!empty($response['response']['code'])) {
2316
+		$parts = json_decode($response['body']);
2317 2317
 
2318
-        if(isset($parts->error)){
2319
-            echo $parts->error.": ".$parts->error_description;exit;
2320
-        }else{
2321
-            echo $error_msg." - #2";exit;
2322
-        }
2318
+		if(isset($parts->error)){
2319
+			echo $parts->error.": ".$parts->error_description;exit;
2320
+		}else{
2321
+			echo $error_msg." - #2";exit;
2322
+		}
2323 2323
 
2324
-    }else{
2324
+	}else{
2325 2325
 
2326
-        echo $error_msg." - #3";exit;
2326
+		echo $error_msg." - #3";exit;
2327 2327
 
2328
-    }
2328
+	}
2329 2329
 }
2330
-    exit;
2330
+	exit;
2331 2331
 }
2332 2332
 
2333 2333
 add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 );
@@ -2345,45 +2345,45 @@  discard block
 block discarded – undo
2345 2345
  * @return array Array of settings.
2346 2346
  */
2347 2347
 function geodir_uninstall_settings($general_settings) {
2348
-    $settings   = array();
2349
-    $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
2350
-    $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
2348
+	$settings   = array();
2349
+	$settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
2350
+	$settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
2351 2351
     
2352
-    $plugins    = get_plugins();
2353
-    $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
2352
+	$plugins    = get_plugins();
2353
+	$un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
2354 2354
     
2355
-    if (!empty($plugins) && !empty($un_plugins)) {
2356
-        foreach ($plugins as $plugin => $data) {
2357
-            $plugin_name = plugin_basename(dirname($plugin));
2355
+	if (!empty($plugins) && !empty($un_plugins)) {
2356
+		foreach ($plugins as $plugin => $data) {
2357
+			$plugin_name = plugin_basename(dirname($plugin));
2358 2358
             
2359
-            if (in_array($plugin_name, $un_plugins)) {
2360
-                $settings[] = array(
2361
-                    'type' => 'checkbox',
2362
-                    'id' => 'geodir_un_' . $plugin_name,
2363
-                    'name' => $data['Name'],
2364
-                    'desc' => wp_sprintf(__('Remove all of its data when the <b>%s</b> is deleted', 'geodirectory'), $plugin_name),
2365
-                    'std' => '0'
2366
-                );
2367
-            }
2368
-        }
2369
-    }
2359
+			if (in_array($plugin_name, $un_plugins)) {
2360
+				$settings[] = array(
2361
+					'type' => 'checkbox',
2362
+					'id' => 'geodir_un_' . $plugin_name,
2363
+					'name' => $data['Name'],
2364
+					'desc' => wp_sprintf(__('Remove all of its data when the <b>%s</b> is deleted', 'geodirectory'), $plugin_name),
2365
+					'std' => '0'
2366
+				);
2367
+			}
2368
+		}
2369
+	}
2370 2370
         
2371
-    $settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main');
2371
+	$settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main');
2372 2372
     
2373
-    /**
2374
-     * Filter the uninstall settings array.
2375
-     *
2376
-     * @since 1.6.9
2377
-     *
2378
-     * @param array $settings The settings array.
2379
-     */
2380
-    $settings = apply_filters('geodir_uninstall_settings', $settings);
2373
+	/**
2374
+	 * Filter the uninstall settings array.
2375
+	 *
2376
+	 * @since 1.6.9
2377
+	 *
2378
+	 * @param array $settings The settings array.
2379
+	 */
2380
+	$settings = apply_filters('geodir_uninstall_settings', $settings);
2381 2381
     
2382
-    if (!empty($settings) && count($settings) > 3) {
2383
-        return array_merge($general_settings, $settings);
2384
-    }
2382
+	if (!empty($settings) && count($settings) > 3) {
2383
+		return array_merge($general_settings, $settings);
2384
+	}
2385 2385
     
2386
-    return $general_settings;
2386
+	return $general_settings;
2387 2387
 }
2388 2388
 add_filter('geodir_general_settings', 'geodir_uninstall_settings', 100, 1);
2389 2389
 
@@ -2393,7 +2393,7 @@  discard block
 block discarded – undo
2393 2393
  * @since 1.6.9
2394 2394
  */
2395 2395
 function geodir_uninstall_settings_desc() {
2396
-    echo '<p class="gd-un-settings-desc">' . __('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory') . '</p>';
2396
+	echo '<p class="gd-un-settings-desc">' . __('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory') . '</p>';
2397 2397
 }
2398 2398
 add_action('geodir_settings_uninstall_settings_main_start', 'geodir_uninstall_settings_desc');
2399 2399
 
@@ -2409,16 +2409,16 @@  discard block
 block discarded – undo
2409 2409
  * @return array The settings array.
2410 2410
  */
2411 2411
 function geodir_resave_settings($settings = array()) {
2412
-    if (!empty($settings) && is_array($settings)) {
2413
-        $c = 0;
2412
+	if (!empty($settings) && is_array($settings)) {
2413
+		$c = 0;
2414 2414
         
2415
-        foreach ($settings as $setting) {
2416
-            if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) {
2417
-                $settings[$c]['std'] = $value;
2418
-            }
2419
-            $c++;
2420
-        }
2421
-    }
2422
-
2423
-    return $settings;
2415
+		foreach ($settings as $setting) {
2416
+			if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) {
2417
+				$settings[$c]['std'] = $value;
2418
+			}
2419
+			$c++;
2420
+		}
2421
+	}
2422
+
2423
+	return $settings;
2424 2424
 }
2425 2425
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -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
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 add_action('geodir_update_options_compatibility_settings', 'geodir_update_options_compatibility_settings');
71 71
 add_action('geodir_update_options_default_location_settings', 'geodir_location_form_submit');
72 72
 add_action('geodir_before_admin_panel', 'geodir_before_admin_panel'); // this function is in admin_functions.php
73
-add_action('geodir_before_update_options', 'geodir_before_update_options',10,2);
73
+add_action('geodir_before_update_options', 'geodir_before_update_options', 10, 2);
74 74
 
75 75
 //add_action('geodir_before_admin_panel', 'geodir_autoinstall_admin_header');
76 76
 
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 
229 229
         // Filter-Payment-Manager
230 230
 
231
-        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
231
+        add_meta_box('geodir_post_images', $post_typename.' '.__('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
232 232
 
233
-        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
233
+        add_meta_box('geodir_post_info', $post_typename.' '.__('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
234 234
 
235 235
         // no need of this box as all fields moved to main information box
236 236
         //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
 }
241 241
 
242
-add_action('save_post', 'geodir_post_information_save',10,2);
242
+add_action('save_post', 'geodir_post_information_save', 10, 2);
243 243
 
244 244
 
245 245
 
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 
267 267
             $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
268 268
 
269
-            if(!empty($gd_taxonomy)) {
269
+            if (!empty($gd_taxonomy)) {
270 270
                 foreach ($gd_taxonomy as $tax) {
271 271
 
272
-                    remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
272
+                    remove_meta_box($tax.'div', $geodir_post_type, 'normal');
273 273
 
274 274
                 }
275 275
             }
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
 add_action('geodir_manage_available_fields_predefined', 'geodir_manage_available_fields_predefined');
356 356
 add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom');
357 357
 
358
-function geodir_manage_available_fields_predefined($sub_tab){
359
-    if($sub_tab=='custom_fields'){
358
+function geodir_manage_available_fields_predefined($sub_tab) {
359
+    if ($sub_tab == 'custom_fields') {
360 360
         geodir_custom_available_fields('predefined');
361 361
     }
362 362
 }
363 363
 
364
-function geodir_manage_available_fields_custom($sub_tab){
365
-    if($sub_tab=='custom_fields'){
364
+function geodir_manage_available_fields_custom($sub_tab) {
365
+    if ($sub_tab == 'custom_fields') {
366 366
         geodir_custom_available_fields('custom');
367 367
     }
368 368
 }
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
     global $wpdb;
433 433
     $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
434 434
     ?>
435
-    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
435
+    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/>
436 436
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
437 437
     <ul>
438 438
     <?php
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 
444 444
             $check_html_variable = $wpdb->get_var(
445 445
                 $wpdb->prepare(
446
-                    "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
446
+                    "SELECT htmlvar_name FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
447 447
                     array($val['htmlvar_name'], $listing_type, $val['field_type'])
448 448
                 )
449 449
             );
@@ -451,23 +451,23 @@  discard block
 block discarded – undo
451 451
             $display = $check_html_variable ? ' style="display:none;"' : '';
452 452
            ?>
453 453
 
454
-            <li   class="gd-cf-tooltip-wrap" <?php echo $display;?>>
454
+            <li   class="gd-cf-tooltip-wrap" <?php echo $display; ?>>
455 455
                 <?php
456
-                if(isset($val['description']) && $val['description']){
456
+                if (isset($val['description']) && $val['description']) {
457 457
                     echo '<div class="gdcf-tooltip">'.$val['description'].'</div>';
458 458
                 }?>
459 459
 
460
-                <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'];?>"
461
-                   title="<?php echo $val['site_title'];?>"
462
-                   class="gd-draggable-form-items  gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);">
460
+                <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']; ?>"
461
+                   title="<?php echo $val['site_title']; ?>"
462
+                   class="gd-draggable-form-items  gd-<?php echo $val['field_type']; ?> geodir-sort-<?php echo $val['htmlvar_name']; ?>" href="javascript:void(0);">
463 463
                     <?php if (isset($val['field_icon']) && strpos($val['field_icon'], 'fa fa-') !== false) {
464 464
                         echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>';
465
-                    }elseif(isset($val['field_icon']) && $val['field_icon'] ){
465
+                    }elseif (isset($val['field_icon']) && $val['field_icon']) {
466 466
                         echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>';
467
-                    }else{
467
+                    } else {
468 468
                         echo '<i class="fa fa-cog" aria-hidden="true"></i>';
469 469
                     }?>
470
-                    <?php echo $val['site_title'];?>
470
+                    <?php echo $val['site_title']; ?>
471 471
                 </a>
472 472
             </li>
473 473
 
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
     <?php 
496 496
         global $wpdb;
497 497
         
498
-        $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)));
498
+        $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)));
499 499
 
500 500
         if (!empty($fields)) {
501 501
             foreach ($fields as $field) {
@@ -520,14 +520,14 @@  discard block
 block discarded – undo
520 520
  * @since 1.6.9
521 521
  * @package GeoDirectory
522 522
  */
523
-function geodir_custom_fields_custom($post_type=''){
523
+function geodir_custom_fields_custom($post_type = '') {
524 524
 
525 525
     $custom_fields = array();
526 526
 
527 527
     /**
528 528
      * @see `geodir_custom_fields`
529 529
      */
530
-    return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
530
+    return apply_filters('geodir_custom_fields_custom', $custom_fields, $post_type);
531 531
 }
532 532
 
533 533
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
  * @since 1.6.6
539 539
  * @package GeoDirectory
540 540
  */
541
-function geodir_custom_fields($post_type=''){
541
+function geodir_custom_fields($post_type = '') {
542 542
     
543 543
     $custom_fields = array(
544 544
         'text' => array(
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
      * }
674 674
      * @param string $post_type The post type requested.
675 675
      */
676
-    return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
676
+    return apply_filters('geodir_custom_fields', $custom_fields, $post_type);
677 677
 }
678 678
 
679 679
 /**
@@ -684,25 +684,25 @@  discard block
 block discarded – undo
684 684
  * @param string $type The custom field type, predefined, custom or blank for default
685 685
  * @package GeoDirectory
686 686
  */
687
-function geodir_custom_available_fields($type='')
687
+function geodir_custom_available_fields($type = '')
688 688
 {
689 689
     $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
690 690
     ?>
691
-    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
691
+    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/>
692 692
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" />
693 693
 
694 694
         <?php
695
-        if($type=='predefined'){
695
+        if ($type == 'predefined') {
696 696
             $cfs = geodir_custom_fields_predefined($listing_type);
697
-        }elseif($type=='custom'){
697
+        }elseif ($type == 'custom') {
698 698
             $cfs = geodir_custom_fields_custom($listing_type);
699
-        }else{
699
+        } else {
700 700
             $cfs = geodir_custom_fields($listing_type);
701 701
             ?>
702 702
             <ul class="full gd-cf-tooltip-wrap">
703 703
                 <li>
704 704
                     <div class="gdcf-tooltip">
705
-                        <?php _e('This adds a section separator with a title.', 'geodirectory');?>
705
+                        <?php _e('This adds a section separator with a title.', 'geodirectory'); ?>
706 706
                     </div>
707 707
                     <a id="gt-fieldset"
708 708
                        class="gd-draggable-form-items gt-fieldset"
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 
714 714
                         <i class="fa fa-long-arrow-left " aria-hidden="true"></i>
715 715
                         <i class="fa fa-long-arrow-right " aria-hidden="true"></i>
716
-                        <?php _e('Fieldset (section separator)', 'geodirectory');?>
716
+                        <?php _e('Fieldset (section separator)', 'geodirectory'); ?>
717 717
                     </a>
718 718
                 </li>
719 719
             </ul>
@@ -721,15 +721,15 @@  discard block
 block discarded – undo
721 721
             <?php
722 722
         }
723 723
 
724
-    if(!empty($cfs)) {
724
+    if (!empty($cfs)) {
725 725
 
726
-        foreach ( $cfs as $id => $cf ) {
726
+        foreach ($cfs as $id => $cf) {
727 727
             ?>
728 728
             <ul>
729 729
             <li class="gd-cf-tooltip-wrap">
730 730
                 <?php
731
-                if ( isset( $cf['description'] ) && $cf['description'] ) {
732
-                    echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>';
731
+                if (isset($cf['description']) && $cf['description']) {
732
+                    echo '<div class="gdcf-tooltip">'.$cf['description'].'</div>';
733 733
                 } ?>
734 734
 
735 735
                 <a id="gd-<?php echo $id; ?>"
@@ -739,10 +739,10 @@  discard block
 block discarded – undo
739 739
                    class="gd-draggable-form-items <?php echo $cf['class']; ?>"
740 740
                    href="javascript:void(0);">
741 741
 
742
-                    <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], 'fa fa-' ) !== false ) {
743
-                        echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>';
744
-                    } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
745
-                        echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>';
742
+                    <?php if (isset($cf['icon']) && strpos($cf['icon'], 'fa fa-') !== false) {
743
+                        echo '<i class="'.$cf['icon'].'" aria-hidden="true"></i>';
744
+                    } elseif (isset($cf['icon']) && $cf['icon']) {
745
+                        echo '<b style="background-image: url("'.$cf['icon'].'")"></b>';
746 746
                     } else {
747 747
                         echo '<i class="fa fa-cog" aria-hidden="true"></i>';
748 748
                     } ?>
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
             </li>
752 752
             <?php
753 753
         }
754
-    }else{
754
+    } else {
755 755
         _e('There are no custom fields here yet.', 'geodirectory');
756 756
     }
757 757
         ?>
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
     <ul class="core">
780 780
     <?php 
781 781
         global $wpdb;
782
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
782
+        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
783 783
 
784 784
         if (!empty($fields)) {
785 785
             foreach ($fields as $field) {
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
                 $field_type_key = $field->field_type_key;
790 790
                 $field_ins_upd = 'display';
791 791
 
792
-                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key);
792
+                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd, $field_type_key);
793 793
             }
794 794
         }
795 795
         ?></ul>
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 
868 868
     switch ($sub_tab) {
869 869
         case 'custom_fields':
870
-            $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));;
870
+            $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)); ;
871 871
             break;
872 872
 
873 873
         case 'sorting_options':
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 
922 922
     switch ($sub_tab) {
923 923
         case 'custom_fields':
924
-            $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));;
924
+            $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)); ;
925 925
             break;
926 926
 
927 927
         case 'sorting_options':
@@ -948,8 +948,8 @@  discard block
 block discarded – undo
948 948
 
949 949
     if (!get_option('geodir_remove_unnecessary_fields')) {
950 950
 
951
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
952
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
951
+        if ($wpdb->get_var("SHOW COLUMNS FROM ".$plugin_prefix."gd_place_detail WHERE field = 'categories'"))
952
+            $wpdb->query("ALTER TABLE `".$plugin_prefix."gd_place_detail` DROP `categories`");
953 953
 
954 954
         update_option('geodir_remove_unnecessary_fields', '1');
955 955
 
@@ -977,14 +977,14 @@  discard block
 block discarded – undo
977 977
             case 'diagnosis' :
978 978
                 if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
979 979
                     $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
980
-                call_user_func('geodir_diagnose_' . $diagnose_this);
980
+                call_user_func('geodir_diagnose_'.$diagnose_this);
981 981
                 exit();
982 982
                 break;
983 983
 
984 984
             case 'diagnosis-fix' :
985 985
                 if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
986 986
                     $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
987
-                call_user_func('geodir_diagnose_' . $diagnose_this);
987
+                call_user_func('geodir_diagnose_'.$diagnose_this);
988 988
                 exit();
989 989
                 break;
990 990
         }
@@ -1009,50 +1009,50 @@  discard block
 block discarded – undo
1009 1009
 {
1010 1010
     global $wpdb;
1011 1011
     //$filter_arr['output_str'] .='###'.$table.'###';
1012
-    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
1013
-        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
1012
+    if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0) {
1013
+        $filter_arr['output_str'] .= "<li>".__('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory')."</li>";
1014 1014
         $filter_arr['is_error_during_diagnose'] = true;
1015 1015
 
1016
-    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1017
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
1016
+    } elseif ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
1017
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name)."</li>";
1018 1018
         $filter_arr['is_error_during_diagnose'] = true;
1019
-        $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>";
1019
+        $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>";
1020 1020
         $filter_arr['is_error_during_diagnose'] = true;
1021 1021
 
1022 1022
         if ($fix) {
1023
-            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
1024
-            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
1023
+            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$table."_ms_bak"); // get backup table count
1024
+            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table"); // get new table count
1025 1025
 
1026 1026
             if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
1027 1027
                 //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
1028 1028
 
1029
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
1029
+                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename bak table to new table
1030 1030
 
1031
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1032
-                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
1031
+                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
1032
+                    $filter_arr['output_str'] .= "<li>".__('-->FIXED: Renamed and backed up the tables', 'geodirectory')."</li>";
1033 1033
                 } else {
1034
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1034
+                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
1035 1035
                 }
1036 1036
 
1037 1037
             } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
1038 1038
 
1039
-                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
1040
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
1039
+                $wpdb->query("RENAME TABLE ".$wpdb->prefix."$table TO ".$table."_ms_bak2"); // rename new table to bak2
1040
+                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$wpdb->prefix."$table"); // rename bak table to new table
1041 1041
 
1042
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1043
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
1042
+                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1043
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table)."</li>";
1044 1044
                 } else {
1045
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1045
+                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
1046 1046
                 }
1047 1047
 
1048 1048
             } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
1049 1049
 
1050
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
1050
+                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename ms_bak table to ms_bak2
1051 1051
 
1052
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1053
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
1052
+                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
1053
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table)."</li>";
1054 1054
                 } else {
1055
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1055
+                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
1056 1056
                 }
1057 1057
 
1058 1058
             }
@@ -1060,54 +1060,54 @@  discard block
 block discarded – undo
1060 1060
         }
1061 1061
 
1062 1062
 
1063
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1064
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
1063
+    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
1064
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name)."</li>";
1065 1065
         $filter_arr['is_error_during_diagnose'] = true;
1066 1066
 
1067 1067
         if ($fix) {
1068 1068
             if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
1069 1069
                 if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
1070
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
1070
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table)."</li>";
1071 1071
                 } else {
1072
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
1072
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table)."</li>";
1073 1073
                 }
1074 1074
 
1075
-            } 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
1076
-                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
1077
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1075
+            } 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
1076
+                if ($wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."$table")) {
1077
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix.$table)."</li>";
1078 1078
                 } else {
1079
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1079
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix.$table)."</li>";
1080 1080
                 }
1081
-                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1082
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1081
+                if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1082
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
1083 1083
                 } else {
1084
-                    $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>";
1084
+                    $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>";
1085 1085
                 }
1086 1086
             } else {// else rename the original table to _ms_bak
1087
-                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1088
-                    $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>";
1087
+                if ($wpdb->query("RENAME TABLE $table TO ".$table."_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1088
+                    $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>";
1089 1089
                 } else {
1090
-                    $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>";
1090
+                    $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>";
1091 1091
                 }
1092 1092
             }
1093 1093
         }
1094 1094
 
1095
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1096
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
1095
+    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
1096
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name)."</li>";
1097 1097
         $filter_arr['is_error_during_diagnose'] = true;
1098 1098
 
1099 1099
         if ($fix) {
1100 1100
             // if original table exists but new does not, rename
1101
-            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1102
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1101
+            if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1102
+                $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
1103 1103
             } else {
1104
-                $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>";
1104
+                $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>";
1105 1105
             }
1106 1106
 
1107 1107
         }
1108 1108
 
1109
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1110
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
1109
+    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
1110
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name)."</li>";
1111 1111
         $filter_arr['is_error_during_diagnose'] = true;
1112 1112
 
1113 1113
         if ($fix) {
@@ -1121,11 +1121,11 @@  discard block
 block discarded – undo
1121 1121
             delete_option('geodir_custom_posts_db_version');
1122 1122
             delete_option('geodir_reviewratings_db_version');
1123 1123
             delete_option('geodiradvancesearch_db_version');
1124
-            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
1124
+            $filter_arr['output_str'] .= "<li>".__('-->TRY: Please refresh page to run table install functions', 'geodirectory')."</li>";
1125 1125
         }
1126 1126
 
1127 1127
     } else {
1128
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
1128
+        $filter_arr['output_str'] .= "<li>".sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name)."</li>";
1129 1129
     }
1130 1130
     return $filter_arr;
1131 1131
 }
@@ -1154,23 +1154,23 @@  discard block
 block discarded – undo
1154 1154
     if (!empty($all_postypes)) {
1155 1155
         foreach ($all_postypes as $key) {
1156 1156
             // update each GD CPT
1157
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
1157
+            $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d");
1158 1158
 
1159 1159
             if (!empty($posts)) {
1160 1160
 
1161 1161
                 foreach ($posts as $p) {
1162 1162
                     $p->post_type = $key;
1163
-                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1163
+                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type.'_tags', array('fields' => 'names'));
1164 1164
                     if (empty($raw_tags)) {
1165 1165
                         $post_tags = '';
1166 1166
                     } else {
1167 1167
                         $post_tags = implode(",", $raw_tags);
1168 1168
                     }
1169
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1170
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1169
+                    $tablename = $plugin_prefix.$p->post_type.'_detail';
1170
+                    $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1171 1171
 
1172 1172
                 }
1173
-                $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1173
+                $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
1174 1174
             }
1175 1175
 
1176 1176
         }
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 
1180 1180
     if ($is_error_during_diagnose) {
1181 1181
         $info_div_class = "geodir_problem_info";
1182
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1182
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1183 1183
     } else {
1184 1184
         $info_div_class = "geodir_noproblem_info";
1185 1185
         $fix_button_txt = '';
@@ -1216,29 +1216,29 @@  discard block
 block discarded – undo
1216 1216
     if (!empty($all_postypes)) {
1217 1217
         foreach ($all_postypes as $key) {
1218 1218
             // update each GD CTP
1219
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
1219
+            $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d WHERE d.".$key."category='' ");
1220 1220
 
1221 1221
             if (!empty($posts)) {
1222 1222
 
1223 1223
                 foreach ($posts as $p) {
1224 1224
                     $p->post_type = $key;
1225
-                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
1225
+                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type.'category', array('fields' => 'ids'));
1226 1226
 
1227 1227
                     if (empty($raw_cats)) {
1228 1228
                         $post_categories = get_post_meta($p->post_id, 'post_categories', true);
1229 1229
 
1230
-                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1231
-                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1232
-                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1230
+                        if (!empty($post_categories) && !empty($post_categories[$p->post_type.'category'])) {
1231
+                            $post_categories[$p->post_type.'category'] = str_replace("d:", "", $post_categories[$p->post_type.'category']);
1232
+                            foreach (explode(",", $post_categories[$p->post_type.'category']) as $cat_part) {
1233 1233
                                 if (is_numeric($cat_part)) {
1234
-                                    $raw_cats[] = (int)$cat_part;
1234
+                                    $raw_cats[] = (int) $cat_part;
1235 1235
                                 }
1236 1236
                             }
1237 1237
 
1238 1238
                         }
1239 1239
 
1240 1240
                         if (!empty($raw_cats)) {
1241
-                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1241
+                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type.'category');
1242 1242
 
1243 1243
                         }
1244 1244
 
@@ -1248,14 +1248,14 @@  discard block
 block discarded – undo
1248 1248
                     if (empty($raw_cats)) {
1249 1249
                         $post_cats = '';
1250 1250
                     } else {
1251
-                        $post_cats = ',' . implode(",", $raw_cats) . ',';
1251
+                        $post_cats = ','.implode(",", $raw_cats).',';
1252 1252
                     }
1253
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1254
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1253
+                    $tablename = $plugin_prefix.$p->post_type.'_detail';
1254
+                    $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET ".$p->post_type."category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1255 1255
                 }
1256 1256
 
1257 1257
             }
1258
-            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1258
+            $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
1259 1259
 
1260 1260
         }
1261 1261
 
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
 
1264 1264
     if ($is_error_during_diagnose) {
1265 1265
         $info_div_class = "geodir_problem_info";
1266
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1266
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1267 1267
     } else {
1268 1268
         $info_div_class = "geodir_noproblem_info";
1269 1269
         $fix_button_txt = '';
@@ -1316,15 +1316,15 @@  discard block
 block discarded – undo
1316 1316
     if (!empty($ver_arr)) {
1317 1317
         foreach ($ver_arr as $key => $val) {
1318 1318
             if (delete_option($val)) {
1319
-                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1319
+                $output_str .= "<li>".$key.__(' Version: Deleted', 'geodirectory')."</li>";
1320 1320
             } else {
1321
-                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1321
+                $output_str .= "<li>".$key.__(' Version: Not Found', 'geodirectory')."</li>";
1322 1322
             }
1323 1323
 
1324 1324
         }
1325 1325
 
1326 1326
         if ($output_str) {
1327
-            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1327
+            $output_str .= "<li><strong>".__(' Upgrade/install scripts will run on next page reload.', 'geodirectory')."</strong></li>";
1328 1328
         }
1329 1329
 
1330 1330
     }
@@ -1361,43 +1361,43 @@  discard block
 block discarded – undo
1361 1361
     $output_str = '';
1362 1362
 
1363 1363
     // check review locations
1364
-    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")) {
1365
-        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1364
+    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")) {
1365
+        $output_str .= "<li>".__('Review locations missing or broken', 'geodirectory')."</li>";
1366 1366
         $is_error_during_diagnose = true;
1367 1367
 
1368 1368
         if ($fix) {
1369 1369
             if (geodir_fix_review_location()) {
1370
-                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1370
+                $output_str .= "<li><strong>".__('-->FIXED: Review locations fixed', 'geodirectory')."</strong></li>";
1371 1371
             } else {
1372
-                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1372
+                $output_str .= "<li><strong>".__('-->FAILED: Review locations fix failed', 'geodirectory')."</strong></li>";
1373 1373
             }
1374 1374
         }
1375 1375
 
1376 1376
     } else {
1377
-        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1377
+        $output_str .= "<li>".__('Review locations ok', 'geodirectory')."</li>";
1378 1378
     }
1379 1379
 
1380 1380
     // check review content
1381
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1382
-        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1381
+    if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_content IS NULL")) {
1382
+        $output_str .= "<li>".__('Review content missing or broken', 'geodirectory')."</li>";
1383 1383
         $is_error_during_diagnose = true;
1384 1384
 
1385 1385
         if ($fix) {
1386 1386
             if (geodir_fix_review_content()) {
1387
-                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1387
+                $output_str .= "<li><strong>".__('-->FIXED: Review content fixed', 'geodirectory')."</strong></li>";
1388 1388
             } else {
1389
-                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1389
+                $output_str .= "<li><strong>".__('-->FAILED: Review content fix failed', 'geodirectory')."</strong></li>";
1390 1390
             }
1391 1391
         }
1392 1392
 
1393 1393
     } else {
1394
-        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1394
+        $output_str .= "<li>".__('Review content ok', 'geodirectory')."</li>";
1395 1395
     }
1396 1396
 
1397 1397
 
1398 1398
     if ($is_error_during_diagnose) {
1399 1399
         $info_div_class = "geodir_problem_info";
1400
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1400
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1401 1401
     } else {
1402 1402
         $info_div_class = "geodir_noproblem_info";
1403 1403
         $fix_button_txt = '';
@@ -1461,7 +1461,7 @@  discard block
 block discarded – undo
1461 1461
 
1462 1462
     if ($is_error_during_diagnose) {
1463 1463
         $info_div_class = "geodir_problem_info";
1464
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1464
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1465 1465
     } else {
1466 1466
         $info_div_class = "geodir_noproblem_info";
1467 1467
         $fix_button_txt = '';
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
     else {
1496 1496
         $page_found = $wpdb->get_var(
1497 1497
             $wpdb->prepare(
1498
-                "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1498
+                "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;",
1499 1499
                 array($slug)
1500 1500
             )
1501 1501
         );
@@ -1541,18 +1541,18 @@  discard block
 block discarded – undo
1541 1541
     //////////////////////////////////
1542 1542
     $option_value = get_option('geodir_home_page');
1543 1543
     $page = get_post($option_value);
1544
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1544
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1545 1545
 
1546
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1547
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1546
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1547
+        $output_str .= "<li>".__('GD Home page exists with proper setting.', 'geodirectory')."</li>";
1548 1548
     else {
1549 1549
         $is_error_during_diagnose = true;
1550
-        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1550
+        $output_str .= "<li><strong>".__('GD Home page is missing.', 'geodirectory')."</strong></li>";
1551 1551
         if ($fix) {
1552 1552
             if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1553
-                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1553
+                $output_str .= "<li><strong>".__('-->FIXED: GD Home page fixed', 'geodirectory')."</strong></li>";
1554 1554
             } else {
1555
-                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1555
+                $output_str .= "<li><strong>".__('-->FAILED: GD Home page fix failed', 'geodirectory')."</strong></li>";
1556 1556
             }
1557 1557
         }
1558 1558
     }
@@ -1566,18 +1566,18 @@  discard block
 block discarded – undo
1566 1566
     //////////////////////////////////
1567 1567
     $option_value = get_option('geodir_add_listing_page');
1568 1568
     $page = get_post($option_value);
1569
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1569
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1570 1570
 
1571
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1572
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1571
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1572
+        $output_str .= "<li>".__('Add Listing page exists with proper setting.', 'geodirectory')."</li>";
1573 1573
     else {
1574 1574
         $is_error_during_diagnose = true;
1575
-        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1575
+        $output_str .= "<li><strong>".__('Add Listing page is missing.', 'geodirectory')."</strong></li>";
1576 1576
         if ($fix) {
1577 1577
             if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1578
-                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1578
+                $output_str .= "<li><strong>".__('-->FIXED: Add Listing page fixed', 'geodirectory')."</strong></li>";
1579 1579
             } else {
1580
-                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1580
+                $output_str .= "<li><strong>".__('-->FAILED: Add Listing page fix failed', 'geodirectory')."</strong></li>";
1581 1581
             }
1582 1582
         }
1583 1583
     }
@@ -1592,18 +1592,18 @@  discard block
 block discarded – undo
1592 1592
     //////////////////////////////////
1593 1593
     $option_value = get_option('geodir_preview_page');
1594 1594
     $page = get_post($option_value);
1595
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1595
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1596 1596
 
1597
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1598
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1597
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1598
+        $output_str .= "<li>".__('Listing Preview page exists with proper setting.', 'geodirectory')."</li>";
1599 1599
     else {
1600 1600
         $is_error_during_diagnose = true;
1601
-        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1601
+        $output_str .= "<li><strong>".__('Listing Preview page is missing.', 'geodirectory')."</strong></li>";
1602 1602
         if ($fix) {
1603 1603
             if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1604
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1604
+                $output_str .= "<li><strong>".__('-->FIXED: Listing Preview page fixed', 'geodirectory')."</strong></li>";
1605 1605
             } else {
1606
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1606
+                $output_str .= "<li><strong>".__('-->FAILED: Listing Preview page fix failed', 'geodirectory')."</strong></li>";
1607 1607
             }
1608 1608
         }
1609 1609
     }
@@ -1617,18 +1617,18 @@  discard block
 block discarded – undo
1617 1617
     //////////////////////////////////
1618 1618
     $option_value = get_option('geodir_success_page');
1619 1619
     $page = get_post($option_value);
1620
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1620
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1621 1621
 
1622
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1623
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1622
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1623
+        $output_str .= "<li>".__('Listing Success page exists with proper setting.', 'geodirectory')."</li>";
1624 1624
     else {
1625 1625
         $is_error_during_diagnose = true;
1626
-        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1626
+        $output_str .= "<li><strong>".__('Listing Success page is missing.', 'geodirectory')."</strong></li>";
1627 1627
         if ($fix) {
1628 1628
             if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1629
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1629
+                $output_str .= "<li><strong>".__('-->FIXED: Listing Success page fixed', 'geodirectory')."</strong></li>";
1630 1630
             } else {
1631
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1631
+                $output_str .= "<li><strong>".__('-->FAILED: Listing Success page fix failed', 'geodirectory')."</strong></li>";
1632 1632
             }
1633 1633
         }
1634 1634
     }
@@ -1642,18 +1642,18 @@  discard block
 block discarded – undo
1642 1642
     //////////////////////////////////
1643 1643
     $option_value = get_option('geodir_info_page');
1644 1644
     $page = get_post($option_value);
1645
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1645
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1646 1646
 
1647
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1648
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1647
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1648
+        $output_str .= "<li>".__('Info page exists with proper setting.', 'geodirectory')."</li>";
1649 1649
     else {
1650 1650
         $is_error_during_diagnose = true;
1651
-        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1651
+        $output_str .= "<li><strong>".__('Info page is missing.', 'geodirectory')."</strong></li>";
1652 1652
         if ($fix) {
1653 1653
             if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1654
-                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1654
+                $output_str .= "<li><strong>".__('-->FIXED: Info page fixed', 'geodirectory')."</strong></li>";
1655 1655
             } else {
1656
-                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1656
+                $output_str .= "<li><strong>".__('-->FAILED: Info page fix failed', 'geodirectory')."</strong></li>";
1657 1657
             }
1658 1658
         }
1659 1659
     }
@@ -1667,18 +1667,18 @@  discard block
 block discarded – undo
1667 1667
     //////////////////////////////////
1668 1668
     $option_value = get_option('geodir_login_page');
1669 1669
     $page = get_post($option_value);
1670
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1670
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1671 1671
 
1672
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1673
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1672
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1673
+        $output_str .= "<li>".__('Login page exists with proper setting.', 'geodirectory')."</li>";
1674 1674
     else {
1675 1675
         $is_error_during_diagnose = true;
1676
-        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1676
+        $output_str .= "<li><strong>".__('Login page is missing.', 'geodirectory')."</strong></li>";
1677 1677
         if ($fix) {
1678 1678
             if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1679
-                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1679
+                $output_str .= "<li><strong>".__('-->FIXED: Login page fixed', 'geodirectory')."</strong></li>";
1680 1680
             } else {
1681
-                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1681
+                $output_str .= "<li><strong>".__('-->FAILED: Login page fix failed', 'geodirectory')."</strong></li>";
1682 1682
             }
1683 1683
         }
1684 1684
     }
@@ -1692,18 +1692,18 @@  discard block
 block discarded – undo
1692 1692
     //////////////////////////////////
1693 1693
     $option_value = get_option('geodir_location_page');
1694 1694
     $page = get_post($option_value);
1695
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1695
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1696 1696
 
1697
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1698
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1697
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1698
+        $output_str .= "<li>".__('Location page exists with proper setting.', 'geodirectory')."</li>";
1699 1699
     else {
1700 1700
         $is_error_during_diagnose = true;
1701
-        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1701
+        $output_str .= "<li><strong>".__('Location page is missing.', 'geodirectory')."</strong></li>";
1702 1702
         if ($fix) {
1703 1703
             if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1704
-                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1704
+                $output_str .= "<li><strong>".__('-->FIXED: Location page fixed', 'geodirectory')."</strong></li>";
1705 1705
             } else {
1706
-                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1706
+                $output_str .= "<li><strong>".__('-->FAILED: Location page fix failed', 'geodirectory')."</strong></li>";
1707 1707
             }
1708 1708
         }
1709 1709
     }
@@ -1712,13 +1712,13 @@  discard block
 block discarded – undo
1712 1712
     /* Diagnose Location Page Ends */
1713 1713
     ////////////////////////////////
1714 1714
 
1715
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1715
+    $page_chk_arr = array('output_str'=>$output_str, 'is_error_during_diagnose'=>$is_error_during_diagnose);
1716 1716
     /**
1717 1717
      * This action is called at the end of the GD Tools page check function.
1718 1718
      *
1719 1719
      * @since 1.5.2
1720 1720
      */
1721
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1721
+    $page_chk_arr = apply_filters('geodir_diagnose_default_pages', $page_chk_arr);
1722 1722
 
1723 1723
     $output_str = $page_chk_arr['output_str'];
1724 1724
     $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
@@ -1728,7 +1728,7 @@  discard block
 block discarded – undo
1728 1728
             flush_rewrite_rules();
1729 1729
         }
1730 1730
         $info_div_class = "geodir_problem_info";
1731
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1731
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1732 1732
     } else {
1733 1733
         $info_div_class = "geodir_noproblem_info";
1734 1734
         $fix_button_txt = '';
@@ -1756,10 +1756,10 @@  discard block
 block discarded – undo
1756 1756
     $fix_button_txt = '';
1757 1757
 
1758 1758
     if ($is_error_during_diagnose) {
1759
-        $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>";
1759
+        $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>";
1760 1760
 		$info_div_class = "geodir_problem_info";
1761 1761
     } else {
1762
-        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1762
+        $output_str .= "<li>".__('Load custom fields in to file for translation: ok', 'geodirectory')."</li>";
1763 1763
 		$info_div_class = "geodir_noproblem_info";
1764 1764
         $fix_button_txt = '';
1765 1765
     }
@@ -1801,17 +1801,17 @@  discard block
 block discarded – undo
1801 1801
     global $wpdb, $wp_query, $plugin_prefix;
1802 1802
 
1803 1803
     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'])) {
1804
-        $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1804
+        $table = $plugin_prefix.$wp_query->query_vars['post_type'].'_detail';
1805 1805
 
1806
-        $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1806
+        $join = $clauses['join'].' INNER JOIN '.$table.' AS gd_posts ON (gd_posts.post_id = '.$wpdb->posts.'.ID)';
1807 1807
         $clauses['join'] = $join;
1808 1808
 
1809
-        $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1809
+        $fields = $clauses['fields'] != '' ? $clauses['fields'].', ' : '';
1810 1810
         $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';
1811 1811
         $clauses['fields'] = $fields;
1812 1812
 
1813 1813
         $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1814
-        $orderby = 'gd_expire ' . $order;
1814
+        $orderby = 'gd_expire '.$order;
1815 1815
         $clauses['orderby'] = $orderby;
1816 1816
     }
1817 1817
     return $clauses;
@@ -1854,7 +1854,7 @@  discard block
 block discarded – undo
1854 1854
         global $current_user;
1855 1855
         $upload_dir = wp_upload_dir();
1856 1856
 
1857
-        $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1857
+        $file = $upload_dir['path'].'/temp_'.$current_user->data->ID.'/geodir_tmp.csv';
1858 1858
         $handle = fopen($file, 'w');
1859 1859
 
1860 1860
         fwrite($handle, $input);
@@ -1899,7 +1899,7 @@  discard block
 block discarded – undo
1899 1899
     $uploads_dir = $uploads['path'];
1900 1900
     $image_name_arr = explode('/', $filename);
1901 1901
     $filename = end($image_name_arr);
1902
-    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1902
+    $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename;
1903 1903
     $return = array();
1904 1904
     $return['file'] = $uploadedFile;
1905 1905
     $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
@@ -1916,8 +1916,8 @@  discard block
 block discarded – undo
1916 1916
 
1917 1917
                 if (($handle = fopen($target_path, "r")) !== FALSE) {
1918 1918
                     while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1919
-                        if(is_array($data) && !empty($data)) {
1920
-                            $file[] = '"' . implode('","', $data) . '"';
1919
+                        if (is_array($data) && !empty($data)) {
1920
+                            $file[] = '"'.implode('","', $data).'"';
1921 1921
                         }
1922 1922
                     }
1923 1923
                     fclose($handle);
@@ -2034,10 +2034,10 @@  discard block
 block discarded – undo
2034 2034
                     $tag_arr = explode(',', $post_tags);
2035 2035
                 }
2036 2036
 
2037
-                $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
2037
+                $table = $plugin_prefix.$buffer[5].'_detail'; // check table in database
2038 2038
 
2039 2039
                 $error = '';
2040
-                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
2040
+                if ($wpdb->get_var("SHOW TABLES LIKE '".$table."'") != $table) {
2041 2041
                     $invalid_post_type++;
2042 2042
                     continue;
2043 2043
                 }
@@ -2063,7 +2063,7 @@  discard block
 block discarded – undo
2063 2063
                             if ($buffer[$c] != '0' && $buffer[$c] != '') {
2064 2064
                                 $submitdata = date('Y-m-d');
2065 2065
 
2066
-                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
2066
+                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata."+".addslashes($buffer[$c])." days"));
2067 2067
                             } else {
2068 2068
                                 $gd_post_info['expire_date'] = 'Never';
2069 2069
                             }
@@ -2091,7 +2091,7 @@  discard block
 block discarded – undo
2091 2091
 						
2092 2092
 						// Post status
2093 2093
 						if ($customKeyarray[$c] == 'post_status') {
2094
-                            $post_status = sanitize_key( $buffer[$c] );
2094
+                            $post_status = sanitize_key($buffer[$c]);
2095 2095
                         }
2096 2096
                     }
2097 2097
 
@@ -2109,8 +2109,8 @@  discard block
 block discarded – undo
2109 2109
 					
2110 2110
 					// Default post status
2111 2111
 					$default_status = 'publish';
2112
-					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
2113
-					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
2112
+					$post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
2113
+					$post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
2114 2114
 
2115 2115
                     $my_post['post_title'] = $post_title;
2116 2116
                     $my_post['post_content'] = $post_desc;
@@ -2154,7 +2154,7 @@  discard block
 block discarded – undo
2154 2154
                     $payment_info = array();
2155 2155
                     $package_info = array();
2156 2156
 
2157
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2157
+                    $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]);
2158 2158
                     $package_id = '';
2159 2159
                     if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2160 2160
                         $package_id = $gd_post_info['package_id'];
@@ -2164,7 +2164,7 @@  discard block
 block discarded – undo
2164 2164
                         $payment_info['package_id'] = $package_info['pid'];
2165 2165
 
2166 2166
                         if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2167
-                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2167
+                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+".$package_info['alive_days']." days"));
2168 2168
                         } else {
2169 2169
                             $payment_info['expire_date'] = 'Never';
2170 2170
                         }
@@ -2176,7 +2176,7 @@  discard block
 block discarded – undo
2176 2176
 
2177 2177
                     $post_type = get_post_type($last_postid);
2178 2178
 
2179
-                    $table = $plugin_prefix . $post_type . '_detail';
2179
+                    $table = $plugin_prefix.$post_type.'_detail';
2180 2180
 
2181 2181
                     geodir_save_post_info($last_postid, $gd_post_info);
2182 2182
 
@@ -2197,7 +2197,7 @@  discard block
 block discarded – undo
2197 2197
                             $attachment['post_id'] = $last_postid;
2198 2198
                             $attachment['title'] = $img_name_arr[0];
2199 2199
                             $attachment['content'] = '';
2200
-                            $attachment['file'] = $sub_dir . '/' . $image_name;
2200
+                            $attachment['file'] = $sub_dir.'/'.$image_name;
2201 2201
                             $attachment['mime_type'] = $uploaded_file_type;
2202 2202
                             $attachment['menu_order'] = $menu_order;
2203 2203
                             $attachment['is_featured'] = 0;
@@ -2206,15 +2206,15 @@  discard block
 block discarded – undo
2206 2206
 
2207 2207
                             foreach ($attachment as $key => $val) {
2208 2208
                                 if ($val != '')
2209
-                                    $attachment_set .= $key . " = '" . $val . "', ";
2209
+                                    $attachment_set .= $key." = '".$val."', ";
2210 2210
                             }
2211 2211
                             $attachment_set = trim($attachment_set, ", ");
2212 2212
 
2213
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2213
+                            $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
2214 2214
 
2215 2215
                             if ($menu_order == 1) {
2216 2216
                                 $post_type = get_post_type($last_postid);
2217
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2217
+                                $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($sub_dir.'/'.$image_name, $last_postid)));
2218 2218
                             }
2219 2219
                             $menu_order++;
2220 2220
                         }
@@ -2255,11 +2255,11 @@  discard block
 block discarded – undo
2255 2255
 }
2256 2256
 
2257 2257
 // Add the tab in left sidebar menu fro import & export page.
2258
-add_filter( 'geodir_settings_tabs_array', 'geodir_import_export_tab', 94 );
2258
+add_filter('geodir_settings_tabs_array', 'geodir_import_export_tab', 94);
2259 2259
 
2260 2260
 // Handle ajax request for import/export.
2261
-add_action( 'wp_ajax_geodir_import_export', 'geodir_ajax_import_export' );
2262
-add_action( 'wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export' );
2261
+add_action('wp_ajax_geodir_import_export', 'geodir_ajax_import_export');
2262
+add_action('wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export');
2263 2263
 
2264 2264
 
2265 2265
 /**
@@ -2270,40 +2270,40 @@  discard block
 block discarded – undo
2270 2270
  * @param $post_id int $post_id The post ID of the post being saved.
2271 2271
  * @param $post object $post The post object of the post being saved.
2272 2272
  */
2273
-function geodir_update_location_prefix($post_id,$post){
2274
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2275
-        update_option('geodir_location_prefix',$post->post_name);
2273
+function geodir_update_location_prefix($post_id, $post) {
2274
+    if ($post->post_type == 'page' && $post->post_name && $post_id == get_option('geodir_location_page')) {
2275
+        update_option('geodir_location_prefix', $post->post_name);
2276 2276
     }
2277 2277
 
2278 2278
 }
2279 2279
 
2280
-add_action('save_post', 'geodir_update_location_prefix',10,2);
2280
+add_action('save_post', 'geodir_update_location_prefix', 10, 2);
2281 2281
 
2282
-add_action( 'wp_ajax_geodir_ga_callback', 'geodir_ga_callback' );
2282
+add_action('wp_ajax_geodir_ga_callback', 'geodir_ga_callback');
2283 2283
 
2284
-function geodir_ga_callback(){
2284
+function geodir_ga_callback() {
2285 2285
 
2286
-if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2286
+if (isset($_REQUEST['code']) && $_REQUEST['code']) {
2287 2287
     $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2288 2288
     $code = "code=".$_REQUEST['code'];
2289 2289
     $grant_type = "&grant_type=authorization_code";
2290
-    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2290
+    $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback";
2291 2291
     $client_id = "&client_id=".get_option('geodir_ga_client_id');
2292 2292
     $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2293 2293
 
2294
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2294
+    $auth_url = $oAuthURL.$code.$redirect_uri.$grant_type.$client_id.$client_secret;
2295 2295
 
2296 2296
     $response = wp_remote_post($auth_url, array('timeout' => 15));
2297 2297
 
2298 2298
     //print_r($response);
2299 2299
 
2300
-    $error_msg =  __('Something went wrong','geodirectory');
2301
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2300
+    $error_msg = __('Something went wrong', 'geodirectory');
2301
+    if (!empty($response['response']['code']) && $response['response']['code'] == 200) {
2302 2302
 
2303 2303
         $parts = json_decode($response['body']);
2304 2304
         //print_r($parts);
2305
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2306
-        else{
2305
+        if (!isset($parts->access_token)) {echo $error_msg." - #1"; exit; }
2306
+        else {
2307 2307
 
2308 2308
             update_option('gd_ga_access_token', $parts->access_token);
2309 2309
             update_option('gd_ga_refresh_token', $parts->refresh_token);
@@ -2312,25 +2312,25 @@  discard block
 block discarded – undo
2312 2312
 
2313 2313
 
2314 2314
     }
2315
-    elseif(!empty($response['response']['code'])) {
2315
+    elseif (!empty($response['response']['code'])) {
2316 2316
         $parts = json_decode($response['body']);
2317 2317
 
2318
-        if(isset($parts->error)){
2319
-            echo $parts->error.": ".$parts->error_description;exit;
2320
-        }else{
2321
-            echo $error_msg." - #2";exit;
2318
+        if (isset($parts->error)) {
2319
+            echo $parts->error.": ".$parts->error_description; exit;
2320
+        } else {
2321
+            echo $error_msg." - #2"; exit;
2322 2322
         }
2323 2323
 
2324
-    }else{
2324
+    } else {
2325 2325
 
2326
-        echo $error_msg." - #3";exit;
2326
+        echo $error_msg." - #3"; exit;
2327 2327
 
2328 2328
     }
2329 2329
 }
2330 2330
     exit;
2331 2331
 }
2332 2332
 
2333
-add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 );
2333
+add_filter('icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4);
2334 2334
 
2335 2335
 if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
2336 2336
 	add_action('geodir_before_admin_panel', 'geodir_wpml_permalink_setting_notice');
@@ -2347,7 +2347,7 @@  discard block
 block discarded – undo
2347 2347
 function geodir_uninstall_settings($general_settings) {
2348 2348
     $settings   = array();
2349 2349
     $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
2350
-    $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
2350
+    $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory'));
2351 2351
     
2352 2352
     $plugins    = get_plugins();
2353 2353
     $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
@@ -2359,7 +2359,7 @@  discard block
 block discarded – undo
2359 2359
             if (in_array($plugin_name, $un_plugins)) {
2360 2360
                 $settings[] = array(
2361 2361
                     'type' => 'checkbox',
2362
-                    'id' => 'geodir_un_' . $plugin_name,
2362
+                    'id' => 'geodir_un_'.$plugin_name,
2363 2363
                     'name' => $data['Name'],
2364 2364
                     'desc' => wp_sprintf(__('Remove all of its data when the <b>%s</b> is deleted', 'geodirectory'), $plugin_name),
2365 2365
                     'std' => '0'
@@ -2393,7 +2393,7 @@  discard block
 block discarded – undo
2393 2393
  * @since 1.6.9
2394 2394
  */
2395 2395
 function geodir_uninstall_settings_desc() {
2396
-    echo '<p class="gd-un-settings-desc">' . __('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory') . '</p>';
2396
+    echo '<p class="gd-un-settings-desc">'.__('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory').'</p>';
2397 2397
 }
2398 2398
 add_action('geodir_settings_uninstall_settings_main_start', 'geodir_uninstall_settings_desc');
2399 2399
 
Please login to merge, or discard this patch.