Test Failed
Pull Request — master (#439)
by Kiran
19:28
created
geodirectory-functions/custom_taxonomy_hooks_actions.php 2 patches
Indentation   +503 added lines, -503 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
 /**
@@ -46,45 +46,45 @@  discard block
 block discarded – undo
46 46
  * @global array $wp_post_types List of post types.
47 47
  */
48 48
 function geodir_register_post_types() {
49
-    global $wp_post_types;
49
+	global $wp_post_types;
50 50
     
51
-    /**
52
-     * Get available custom posttypes and taxonomies and register them.
53
-     */
54
-    _x('places', 'URL slug', 'geodirectory');
55
-
56
-    $post_types = array();
57
-    $post_types = get_option('geodir_post_types');
58
-
59
-    // Register each post type if array of data is returned
60
-    if (is_array($post_types)):
61
-
62
-        foreach ($post_types as $post_type => $args):
63
-
64
-            if (!empty($args['rewrite']['slug'])) {
65
-                $args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory');
66
-            }
67
-            $args = stripslashes_deep($args);
68
-
69
-            if (!empty($args['labels'])) {
70
-                foreach ($args['labels'] as $key => $val) {
71
-                    $args['labels'][$key] = __($val, 'geodirectory');// allow translation
72
-                }
73
-            }
74
-
75
-            /**
76
-             * Filter post type args.
77
-             *
78
-             * @since 1.0.0
79
-             * @param string $args Post type args.
80
-             * @param string $post_type The post type.
81
-             */
82
-            $args = apply_filters('geodir_post_type_args', $args, $post_type);
83
-
84
-            $post_type = register_post_type($post_type, $args);
85
-
86
-        endforeach;
87
-    endif;
51
+	/**
52
+	 * Get available custom posttypes and taxonomies and register them.
53
+	 */
54
+	_x('places', 'URL slug', 'geodirectory');
55
+
56
+	$post_types = array();
57
+	$post_types = get_option('geodir_post_types');
58
+
59
+	// Register each post type if array of data is returned
60
+	if (is_array($post_types)):
61
+
62
+		foreach ($post_types as $post_type => $args):
63
+
64
+			if (!empty($args['rewrite']['slug'])) {
65
+				$args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory');
66
+			}
67
+			$args = stripslashes_deep($args);
68
+
69
+			if (!empty($args['labels'])) {
70
+				foreach ($args['labels'] as $key => $val) {
71
+					$args['labels'][$key] = __($val, 'geodirectory');// allow translation
72
+				}
73
+			}
74
+
75
+			/**
76
+			 * Filter post type args.
77
+			 *
78
+			 * @since 1.0.0
79
+			 * @param string $args Post type args.
80
+			 * @param string $post_type The post type.
81
+			 */
82
+			$args = apply_filters('geodir_post_type_args', $args, $post_type);
83
+
84
+			$post_type = register_post_type($post_type, $args);
85
+
86
+		endforeach;
87
+	endif;
88 88
 }
89 89
 
90 90
 /**
@@ -98,72 +98,72 @@  discard block
 block discarded – undo
98 98
  */
99 99
 function geodir_post_type_args_modify($args, $post_type)
100 100
 {
101
-    $geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
101
+	$geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
102 102
 	if (isset($_REQUEST['geodir_listing_prefix']) && $_REQUEST['geodir_listing_prefix'] != '' && geodir_strtolower($_REQUEST['geodir_listing_prefix']) != geodir_strtolower($geodir_location_prefix)) {
103 103
 
104
-        $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix']));
104
+		$listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix']));
105 105
 
106
-        if ($post_type == 'gd_place') {
107
-            if (array_key_exists('has_archive', $args))
108
-                $args['has_archive'] = $listing_slug;
106
+		if ($post_type == 'gd_place') {
107
+			if (array_key_exists('has_archive', $args))
108
+				$args['has_archive'] = $listing_slug;
109 109
 
110
-            if (array_key_exists('rewrite', $args)) {
111
-                if (array_key_exists('slug', $args['rewrite']))
112
-                    $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
113
-            }
110
+			if (array_key_exists('rewrite', $args)) {
111
+				if (array_key_exists('slug', $args['rewrite']))
112
+					$args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
113
+			}
114 114
 
115
-            $geodir_post_types = get_option('geodir_post_types');
115
+			$geodir_post_types = get_option('geodir_post_types');
116 116
 
117
-            if (array_key_exists($post_type, $geodir_post_types)) {
117
+			if (array_key_exists($post_type, $geodir_post_types)) {
118 118
 
119
-                if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
120
-                    $geodir_post_types[$post_type]['has_archive'] = $listing_slug;
119
+				if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
120
+					$geodir_post_types[$post_type]['has_archive'] = $listing_slug;
121 121
 
122
-                if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
123
-                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
124
-                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
122
+				if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
123
+					if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
124
+						$geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
125 125
 
126
-                update_option('geodir_post_types', $geodir_post_types);
126
+				update_option('geodir_post_types', $geodir_post_types);
127 127
 
128
-            }
128
+			}
129 129
 
130
-            $geodir_post_types = get_option('geodir_post_types');
130
+			$geodir_post_types = get_option('geodir_post_types');
131 131
 
132
-            /* --- update taxonomies (category) --- */
132
+			/* --- update taxonomies (category) --- */
133 133
 
134
-            $geodir_taxonomies = get_option('geodir_taxonomies');
134
+			$geodir_taxonomies = get_option('geodir_taxonomies');
135 135
 
136
-            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
137
-                $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
136
+			if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
137
+				$geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
138 138
 
139
-                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
140
-                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
141
-                        if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
142
-                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
139
+				if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
140
+					if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
141
+						if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
142
+							$geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
143 143
 
144
-                update_option('geodir_taxonomies', $geodir_taxonomies);
144
+				update_option('geodir_taxonomies', $geodir_taxonomies);
145 145
 
146
-            }
146
+			}
147 147
 
148
-            /* --- update taxonomies (tags) --- */
149
-            $geodir_taxonomies_tag = get_option('geodir_taxonomies');
150
-            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
151
-                $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
148
+			/* --- update taxonomies (tags) --- */
149
+			$geodir_taxonomies_tag = get_option('geodir_taxonomies');
150
+			if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
151
+				$geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
152 152
 
153
-                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
154
-                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
155
-                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
156
-                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
153
+				if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
154
+					if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
155
+						if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
156
+							$geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
157 157
 
158
-                update_option('geodir_taxonomies', $geodir_taxonomies_tag);
158
+				update_option('geodir_taxonomies', $geodir_taxonomies_tag);
159 159
 
160
-            }
160
+			}
161 161
 
162
-        }
162
+		}
163 163
 
164
-    }
164
+	}
165 165
 
166
-    return $args;
166
+	return $args;
167 167
 }
168 168
 
169 169
 /**
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
  */
177 177
 function geodir_flush_rewrite_rules()
178 178
 {
179
-    global $wp_rewrite;
180
-    $wp_rewrite->flush_rules(false);
179
+	global $wp_rewrite;
180
+	$wp_rewrite->flush_rules(false);
181 181
 }
182 182
 
183 183
 /**
@@ -192,35 +192,35 @@  discard block
 block discarded – undo
192 192
  * @return array Rewrite rules.
193 193
  */
194 194
 function geodir_listing_rewrite_rules($rules) {
195
-    $newrules = array();
196
-    $taxonomies = get_option('geodir_taxonomies');
197
-    $detail_url_seprator = get_option('geodir_detailurl_separator');
195
+	$newrules = array();
196
+	$taxonomies = get_option('geodir_taxonomies');
197
+	$detail_url_seprator = get_option('geodir_detailurl_separator');
198 198
     
199 199
 	// create rules for post listing
200
-    if (is_array($taxonomies)):
201
-        foreach ($taxonomies as $taxonomy => $args):
202
-            $post_type = $args['object_type'];
203
-            $listing_slug = $args['listing_slug'];
204
-
205
-            if (strpos($taxonomy, 'tags')) {
206
-                $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
207
-                $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
208
-            } else {
209
-                // use this loop to add paging for details page comments paging
210
-                $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
211
-            }
212
-        endforeach;
213
-    endif;
214
-
215
-    // create rules for location listing
216
-    $location_page = get_option('geodir_location_page');
200
+	if (is_array($taxonomies)):
201
+		foreach ($taxonomies as $taxonomy => $args):
202
+			$post_type = $args['object_type'];
203
+			$listing_slug = $args['listing_slug'];
204
+
205
+			if (strpos($taxonomy, 'tags')) {
206
+				$newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
207
+				$newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
208
+			} else {
209
+				// use this loop to add paging for details page comments paging
210
+				$newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
211
+			}
212
+		endforeach;
213
+	endif;
214
+
215
+	// create rules for location listing
216
+	$location_page = get_option('geodir_location_page');
217 217
 	
218
-    if($location_page) {
219
-        global $wpdb;
220
-        $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
221
-    }
222
-    if (!isset($location_prefix))
223
-        $location_prefix = 'location';
218
+	if($location_page) {
219
+		global $wpdb;
220
+		$location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
221
+	}
222
+	if (!isset($location_prefix))
223
+		$location_prefix = 'location';
224 224
 
225 225
 	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
226 226
 	if ($location_manager) {
@@ -264,12 +264,12 @@  discard block
 block discarded – undo
264 264
 		$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]';
265 265
 	}
266 266
 
267
-    if ($location_page && geodir_is_wpml()) {
268
-        foreach(icl_get_languages('skip_missing=N') as $lang){
269
-            $alt_page_id = '';
270
-            $alt_page_id = geodir_wpml_object_id($location_page, 'page', false,$lang['language_code']);
271
-            if($alt_page_id){
272
-                $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
267
+	if ($location_page && geodir_is_wpml()) {
268
+		foreach(icl_get_languages('skip_missing=N') as $lang){
269
+			$alt_page_id = '';
270
+			$alt_page_id = geodir_wpml_object_id($location_page, 'page', false,$lang['language_code']);
271
+			if($alt_page_id){
272
+				$location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
273 273
 
274 274
 				if ($location_manager && ($hide_country_part || $hide_region_part)) {
275 275
 					$matches2 = '';
@@ -305,14 +305,14 @@  discard block
 block discarded – undo
305 305
 					$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]';
306 306
 					$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]';
307 307
 				}
308
-            }
309
-        }
310
-    }
308
+			}
309
+		}
310
+	}
311 311
 
312
-    $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page;
312
+	$newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page;
313 313
 
314
-    $rules = array_merge($newrules, $rules);
315
-    return $rules;
314
+	$rules = array_merge($newrules, $rules);
315
+	return $rules;
316 316
 }
317 317
 
318 318
 /**
@@ -327,18 +327,18 @@  discard block
 block discarded – undo
327 327
  */
328 328
 function geodir_htaccess_contents($rules)
329 329
 {
330
-    global $wpdb;
331
-    $location_prefix = get_option('geodir_location_prefix');
332
-    // if location page slug changed then add redirect
333
-    if ($location_prefix == 'location') {
334
-        return $rules;
335
-    }
336
-    $my_content = <<<EOD
330
+	global $wpdb;
331
+	$location_prefix = get_option('geodir_location_prefix');
332
+	// if location page slug changed then add redirect
333
+	if ($location_prefix == 'location') {
334
+		return $rules;
335
+	}
336
+	$my_content = <<<EOD
337 337
 \n# BEGIN GeoDirectory Rules
338 338
 #Redirect 301 /location/ /$location_prefix/
339 339
 # END GeoDirectory Rules\n\n
340 340
 EOD;
341
-    return $my_content . $rules;
341
+	return $my_content . $rules;
342 342
 }
343 343
 //add_filter('mod_rewrite_rules', 'geodir_htaccess_contents');
344 344
 
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
  */
353 353
 function geodir_add_location_var($public_query_vars)
354 354
 {
355
-    $public_query_vars[] = 'gd_country';
356
-    $public_query_vars[] = 'gd_region';
357
-    $public_query_vars[] = 'gd_city';
358
-    return $public_query_vars;
355
+	$public_query_vars[] = 'gd_country';
356
+	$public_query_vars[] = 'gd_region';
357
+	$public_query_vars[] = 'gd_city';
358
+	return $public_query_vars;
359 359
 }
360 360
 
361 361
 /**
@@ -368,8 +368,8 @@  discard block
 block discarded – undo
368 368
  */
369 369
 function geodir_add_geodir_page_var($public_query_vars)
370 370
 {
371
-    $public_query_vars[] = 'gd_is_geodir_page';
372
-    return $public_query_vars;
371
+	$public_query_vars[] = 'gd_is_geodir_page';
372
+	return $public_query_vars;
373 373
 }
374 374
 
375 375
 /**
@@ -381,20 +381,20 @@  discard block
 block discarded – undo
381 381
  */
382 382
 function geodir_add_page_id_in_query_var()
383 383
 {
384
-    global $wp_query;
384
+	global $wp_query;
385 385
 
386
-    $page_id = $wp_query->get_queried_object_id();
386
+	$page_id = $wp_query->get_queried_object_id();
387 387
 
388
-    if (!get_query_var('page_id') && !is_archive()) {
389
-        // fix for WP tags conflict with enfold theme
390
-        $theme_name = geodir_strtolower(wp_get_theme());
391
-        if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
392
-            return $wp_query;
393
-        }
394
-        $wp_query->set('page_id', $page_id);
395
-    }
388
+	if (!get_query_var('page_id') && !is_archive()) {
389
+		// fix for WP tags conflict with enfold theme
390
+		$theme_name = geodir_strtolower(wp_get_theme());
391
+		if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
392
+			return $wp_query;
393
+		}
394
+		$wp_query->set('page_id', $page_id);
395
+	}
396 396
 
397
-    return $wp_query;
397
+	return $wp_query;
398 398
 }
399 399
 
400 400
 /**
@@ -409,23 +409,23 @@  discard block
 block discarded – undo
409 409
 function geodir_set_location_var_in_session_in_core($wp) {
410 410
 	global $gd_session;
411 411
 
412
-    // Fix for WPML removing page_id query var:
413
-    if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
414
-        global $wpdb;
412
+	// Fix for WPML removing page_id query var:
413
+	if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
414
+		global $wpdb;
415 415
 
416
-        $page_for_posts = get_option('page_for_posts');
417
-        $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']));
416
+		$page_for_posts = get_option('page_for_posts');
417
+		$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']));
418 418
 
419
-        if (geodir_is_wpml()) {
420
-            $real_page_id = geodir_wpml_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
421
-        }
422
-        if ($real_page_id && $real_page_id!=$page_for_posts) {
423
-            $wp->query_vars['page_id'] = $real_page_id;
424
-        }
425
-    }
419
+		if (geodir_is_wpml()) {
420
+			$real_page_id = geodir_wpml_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
421
+		}
422
+		if ($real_page_id && $real_page_id!=$page_for_posts) {
423
+			$wp->query_vars['page_id'] = $real_page_id;
424
+		}
425
+	}
426 426
 	// Query Vars will have page_id parameter
427 427
 	// check if query var has page_id and that page id is location page
428
-    geodir_set_is_geodir_page($wp);
428
+	geodir_set_is_geodir_page($wp);
429 429
 	// if is GD homepage set the page ID
430 430
 	if (geodir_is_page('home')) {
431 431
 		$wp->query_vars['page_id'] = get_option('page_on_front');
@@ -434,118 +434,118 @@  discard block
 block discarded – undo
434 434
 	// The location url format (all or country_city or region_city or city).
435 435
 	$geodir_show_location_url = get_option('geodir_show_location_url');
436 436
 
437
-    if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
438
-        $gd_country = '';
439
-        $gd_region = '';
440
-        $gd_city = '';
441
-        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '')
442
-            $gd_country = urldecode($wp->query_vars['gd_country']);
443
-
444
-        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '')
445
-            $gd_region = urldecode($wp->query_vars['gd_region']);
446
-
447
-        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '')
448
-            $gd_city = urldecode($wp->query_vars['gd_city']);
449
-
450
-        if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
451
-            $default_location = geodir_get_default_location();
452
-
453
-            if (get_option('geodir_add_location_url')) {
454
-                if ($geodir_show_location_url != 'all') {
455
-                    if ($gd_region == '') {
456
-                        if ($gd_ses_region = $gd_session->get('gd_region'))
457
-                            $gd_region = $gd_ses_region;
458
-                        else
459
-                            $gd_region = $default_location->region_slug;
460
-                    }
461
-
462
-                    if ($gd_city == '') {
463
-                        if ($gd_ses_city = $gd_session->get('gd_city'))
464
-                            $gd_city = $gd_ses_city;
465
-                        else
466
-                            $gd_city = $default_location->city_slug;
467
-
468
-                        $base_location_link = geodir_get_location_link('base');
469
-                        wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
470
-                        exit();
471
-                    }
472
-                }
473
-            }
474
-
475
-            $args = array(
476
-                'what' => 'city',
477
-                'city_val' => $gd_city,
478
-                'region_val' => $gd_region,
479
-                'country_val' => $gd_country,
480
-                'country_column_name' => 'country_slug',
481
-                'region_column_name' => 'region_slug',
482
-                'city_column_name' => 'city_slug',
483
-                'location_link_part' => false,
484
-                'compare_operator' => ''
485
-            );
486
-
487
-            $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
488
-            if (!empty($location_array)) {
489
-                $gd_session->set('gd_multi_location', 1);
490
-                $gd_session->set('gd_country', $gd_country);
491
-                $gd_session->set('gd_region', $gd_region);
492
-                $gd_session->set('gd_city', $gd_city);
437
+	if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
438
+		$gd_country = '';
439
+		$gd_region = '';
440
+		$gd_city = '';
441
+		if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '')
442
+			$gd_country = urldecode($wp->query_vars['gd_country']);
443
+
444
+		if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '')
445
+			$gd_region = urldecode($wp->query_vars['gd_region']);
446
+
447
+		if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '')
448
+			$gd_city = urldecode($wp->query_vars['gd_city']);
449
+
450
+		if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
451
+			$default_location = geodir_get_default_location();
452
+
453
+			if (get_option('geodir_add_location_url')) {
454
+				if ($geodir_show_location_url != 'all') {
455
+					if ($gd_region == '') {
456
+						if ($gd_ses_region = $gd_session->get('gd_region'))
457
+							$gd_region = $gd_ses_region;
458
+						else
459
+							$gd_region = $default_location->region_slug;
460
+					}
461
+
462
+					if ($gd_city == '') {
463
+						if ($gd_ses_city = $gd_session->get('gd_city'))
464
+							$gd_city = $gd_ses_city;
465
+						else
466
+							$gd_city = $default_location->city_slug;
467
+
468
+						$base_location_link = geodir_get_location_link('base');
469
+						wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
470
+						exit();
471
+					}
472
+				}
473
+			}
474
+
475
+			$args = array(
476
+				'what' => 'city',
477
+				'city_val' => $gd_city,
478
+				'region_val' => $gd_region,
479
+				'country_val' => $gd_country,
480
+				'country_column_name' => 'country_slug',
481
+				'region_column_name' => 'region_slug',
482
+				'city_column_name' => 'city_slug',
483
+				'location_link_part' => false,
484
+				'compare_operator' => ''
485
+			);
486
+
487
+			$location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
488
+			if (!empty($location_array)) {
489
+				$gd_session->set('gd_multi_location', 1);
490
+				$gd_session->set('gd_country', $gd_country);
491
+				$gd_session->set('gd_region', $gd_region);
492
+				$gd_session->set('gd_city', $gd_city);
493 493
                 
494 494
 				$wp->query_vars['gd_country'] = $gd_country;
495
-                $wp->query_vars['gd_region'] = $gd_region;
496
-                $wp->query_vars['gd_city'] = $gd_city;
497
-            } else {
498
-                $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
499
-            }
500
-        } else {
501
-            $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
502
-        }
503
-
504
-    } else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
505
-        if (!is_admin()) {
506
-            $requested_post_type = $wp->query_vars['post_type'];
507
-            // check if this post type is geodirectory post types
508
-            $post_type_array = geodir_get_posttypes();
495
+				$wp->query_vars['gd_region'] = $gd_region;
496
+				$wp->query_vars['gd_city'] = $gd_city;
497
+			} else {
498
+				$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
499
+			}
500
+		} else {
501
+			$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
502
+		}
503
+
504
+	} else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
505
+		if (!is_admin()) {
506
+			$requested_post_type = $wp->query_vars['post_type'];
507
+			// check if this post type is geodirectory post types
508
+			$post_type_array = geodir_get_posttypes();
509 509
             
510 510
 			if (in_array($requested_post_type, $post_type_array)) {
511
-                // now u can apply geodirectory related manipulation.
512
-            }
513
-        }
514
-    } else {
515
-        // check if a geodirectory taxonomy is set
516
-        $gd_country = '';
517
-        $gd_region = '';
518
-        $gd_city = '';
511
+				// now u can apply geodirectory related manipulation.
512
+			}
513
+		}
514
+	} else {
515
+		// check if a geodirectory taxonomy is set
516
+		$gd_country = '';
517
+		$gd_region = '';
518
+		$gd_city = '';
519 519
         
520 520
 		$is_geodir_taxonomy = false;
521
-        $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not
522
-        $is_geodir_location_found = false;
521
+		$is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not
522
+		$is_geodir_location_found = false;
523 523
 		
524 524
 		$geodir_taxonomy = '';
525
-        $geodir_post_type = '';
526
-        $geodir_term = '';
527
-        $geodir_set_location_session = true;
528
-        $geodir_taxonomis = geodir_get_taxonomies('', true);
529
-
530
-        if(!empty($geodir_taxonomis)){
531
-            foreach ($geodir_taxonomis as $taxonomy) {
532
-                if (array_key_exists($taxonomy, $wp->query_vars)) {
533
-                    $is_geodir_taxonomy = true;
534
-                    $geodir_taxonomy = $taxonomy;
535
-                    $geodir_post_type = str_replace('category', '', $taxonomy);
536
-                    $geodir_post_type = str_replace('_tags', '', $geodir_post_type);
537
-                    $geodir_term = $wp->query_vars[$geodir_taxonomy];
538
-                    break;
539
-                }
540
-            }
541
-        }
542
-
543
-        // now get an array of all terms seperated by '/'
544
-        $geodir_terms = explode('/', $geodir_term);
545
-        $geodir_last_term = end($geodir_terms);
546
-
547
-        if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
548
-            $wp->query_vars['post_type'] = $geodir_post_type;
525
+		$geodir_post_type = '';
526
+		$geodir_term = '';
527
+		$geodir_set_location_session = true;
528
+		$geodir_taxonomis = geodir_get_taxonomies('', true);
529
+
530
+		if(!empty($geodir_taxonomis)){
531
+			foreach ($geodir_taxonomis as $taxonomy) {
532
+				if (array_key_exists($taxonomy, $wp->query_vars)) {
533
+					$is_geodir_taxonomy = true;
534
+					$geodir_taxonomy = $taxonomy;
535
+					$geodir_post_type = str_replace('category', '', $taxonomy);
536
+					$geodir_post_type = str_replace('_tags', '', $geodir_post_type);
537
+					$geodir_term = $wp->query_vars[$geodir_taxonomy];
538
+					break;
539
+				}
540
+			}
541
+		}
542
+
543
+		// now get an array of all terms seperated by '/'
544
+		$geodir_terms = explode('/', $geodir_term);
545
+		$geodir_last_term = end($geodir_terms);
546
+
547
+		if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
548
+			$wp->query_vars['post_type'] = $geodir_post_type;
549 549
 
550 550
 			// now check if last term is a post of geodirectory post types
551 551
 			$geodir_post = get_posts(array(
@@ -594,196 +594,196 @@  discard block
 block discarded – undo
594 594
 				//return ;
595 595
 			}
596 596
 
597
-            $geodir_location_terms = '';
598
-            // if last term is not a post then check if last term is a term of the specific texonomy or not
599
-            if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
600
-                $is_geodir_taxonomy_term = true;
597
+			$geodir_location_terms = '';
598
+			// if last term is not a post then check if last term is a term of the specific texonomy or not
599
+			if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
600
+				$is_geodir_taxonomy_term = true;
601 601
 
602
-                $geodir_set_location_session = false;
603
-            }
602
+				$geodir_set_location_session = false;
603
+			}
604 604
 
605 605
 
606
-            // now check if there is location parts in the url or not
607
-            if (get_option('geodir_add_location_url')) {				
606
+			// now check if there is location parts in the url or not
607
+			if (get_option('geodir_add_location_url')) {				
608 608
 				$default_location = geodir_get_default_location();
609 609
                 
610 610
 				if ($geodir_show_location_url == 'all') {
611
-                    if (count($geodir_terms) >= 3) {
612
-                        $gd_country = urldecode($geodir_terms[0]);
613
-                        $gd_region = urldecode($geodir_terms[1]);
614
-                        $gd_city = urldecode($geodir_terms[2]);
615
-                    } else if (count($geodir_terms) >= 2) {
616
-                        $gd_country = urldecode($geodir_terms[0]);
617
-                        $gd_region = urldecode($geodir_terms[1]);
618
-                    } else if (count($geodir_terms) >= 1) {
619
-                        $gd_country = urldecode($geodir_terms[0]);
620
-                    }
621
-
622
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
623
-                        geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
624
-                        geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
625
-                    )
626
-                        $is_geodir_location_found = true;
627
-
628
-                    // if location has not been found for country , region and city then search for country and region only
629
-
630
-                    if (!$is_geodir_location_found) {
631
-                        $gd_city = '';
632
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
633
-                            geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
634
-                        )
635
-                            $is_geodir_location_found = true;
636
-
637
-                    }
638
-
639
-                    // if location has not been found for country , region  then search for country only
640
-                    if (!$is_geodir_location_found) {
641
-                        $gd_city = '';
642
-                        $gd_region = '';
643
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
644
-                            $is_geodir_location_found = true;
645
-                    }
646
-                } else if ($geodir_show_location_url == 'country_city') {
647
-                    if (count($geodir_terms) >= 2) {
648
-                        $gd_country = urldecode($geodir_terms[0]);
649
-                        $gd_city = urldecode($geodir_terms[1]);
650
-                    } else if (count($geodir_terms) >= 1) {
651
-                        $gd_country = urldecode($geodir_terms[0]);
652
-                    }
653
-
654
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
655
-                        $is_geodir_location_found = true;
656
-
657
-                    // if location has not been found for country and city  then search for country only
658
-                    if (!$is_geodir_location_found) {
659
-                        $gd_city = '';
611
+					if (count($geodir_terms) >= 3) {
612
+						$gd_country = urldecode($geodir_terms[0]);
613
+						$gd_region = urldecode($geodir_terms[1]);
614
+						$gd_city = urldecode($geodir_terms[2]);
615
+					} else if (count($geodir_terms) >= 2) {
616
+						$gd_country = urldecode($geodir_terms[0]);
617
+						$gd_region = urldecode($geodir_terms[1]);
618
+					} else if (count($geodir_terms) >= 1) {
619
+						$gd_country = urldecode($geodir_terms[0]);
620
+					}
621
+
622
+					if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
623
+						geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
624
+						geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
625
+					)
626
+						$is_geodir_location_found = true;
627
+
628
+					// if location has not been found for country , region and city then search for country and region only
629
+
630
+					if (!$is_geodir_location_found) {
631
+						$gd_city = '';
632
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
633
+							geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
634
+						)
635
+							$is_geodir_location_found = true;
636
+
637
+					}
638
+
639
+					// if location has not been found for country , region  then search for country only
640
+					if (!$is_geodir_location_found) {
641
+						$gd_city = '';
642
+						$gd_region = '';
643
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
644
+							$is_geodir_location_found = true;
645
+					}
646
+				} else if ($geodir_show_location_url == 'country_city') {
647
+					if (count($geodir_terms) >= 2) {
648
+						$gd_country = urldecode($geodir_terms[0]);
649
+						$gd_city = urldecode($geodir_terms[1]);
650
+					} else if (count($geodir_terms) >= 1) {
651
+						$gd_country = urldecode($geodir_terms[0]);
652
+					}
653
+
654
+					if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
655
+						$is_geodir_location_found = true;
656
+
657
+					// if location has not been found for country and city  then search for country only
658
+					if (!$is_geodir_location_found) {
659
+						$gd_city = '';
660 660
                         
661 661
 						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
662
-                            $is_geodir_location_found = true;
663
-                    }
664
-                }  else if ($geodir_show_location_url == 'region_city') {
665
-                    if (count($geodir_terms) >= 2) {
666
-                        $gd_region = urldecode($geodir_terms[0]);
667
-                        $gd_city = urldecode($geodir_terms[1]);
668
-                    } else if (count($geodir_terms) >= 1) {
669
-                        $gd_region = urldecode($geodir_terms[0]);
670
-                    }
671
-
672
-                    if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
673
-                        $is_geodir_location_found = true;
674
-
675
-                    // if location has not been found for region and city  then search for region only
676
-                    if (!$is_geodir_location_found) {
677
-                        $gd_city = '';
662
+							$is_geodir_location_found = true;
663
+					}
664
+				}  else if ($geodir_show_location_url == 'region_city') {
665
+					if (count($geodir_terms) >= 2) {
666
+						$gd_region = urldecode($geodir_terms[0]);
667
+						$gd_city = urldecode($geodir_terms[1]);
668
+					} else if (count($geodir_terms) >= 1) {
669
+						$gd_region = urldecode($geodir_terms[0]);
670
+					}
671
+
672
+					if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
673
+						$is_geodir_location_found = true;
674
+
675
+					// if location has not been found for region and city  then search for region only
676
+					if (!$is_geodir_location_found) {
677
+						$gd_city = '';
678 678
                         
679 679
 						if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region))
680
-                            $is_geodir_location_found = true;
681
-                    }
682
-                } else {
683
-                    $gd_city = $geodir_terms[0];
684
-
685
-                    if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
686
-                        $is_geodir_location_found = true;
687
-                        $gd_region = $default_location->region_slug;
688
-                        $gd_country = $default_location->country_slug;
689
-                    }
690
-                }
691
-                // if location still not found then clear location related session variables
692
-                if ($is_geodir_location_found && $geodir_set_location_session) {
693
-                    $gd_session->set('gd_multi_location', 1);
694
-                    $gd_session->set('gd_country', $gd_country);
695
-                    $gd_session->set('gd_region', $gd_region);
696
-                    $gd_session->set('gd_city', $gd_city);
697
-                }
698
-
699
-                if ($geodir_show_location_url == 'all') {
680
+							$is_geodir_location_found = true;
681
+					}
682
+				} else {
683
+					$gd_city = $geodir_terms[0];
684
+
685
+					if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
686
+						$is_geodir_location_found = true;
687
+						$gd_region = $default_location->region_slug;
688
+						$gd_country = $default_location->country_slug;
689
+					}
690
+				}
691
+				// if location still not found then clear location related session variables
692
+				if ($is_geodir_location_found && $geodir_set_location_session) {
693
+					$gd_session->set('gd_multi_location', 1);
694
+					$gd_session->set('gd_country', $gd_country);
695
+					$gd_session->set('gd_region', $gd_region);
696
+					$gd_session->set('gd_city', $gd_city);
697
+				}
698
+
699
+				if ($geodir_show_location_url == 'all') {
700 700
 				} else if ($geodir_show_location_url == 'country_city') {
701 701
 					$gd_region = '';
702 702
 				} else if ($geodir_show_location_url == 'region_city') {
703 703
 					$gd_country = '';
704 704
 				} else {
705 705
 					$gd_country = '';
706
-                    $gd_region = '';
706
+					$gd_region = '';
707
+				}
708
+
709
+				if ($is_geodir_location_found) {
710
+					$wp->query_vars['gd_country'] = $gd_country;
711
+					$wp->query_vars['gd_region'] = $gd_region;
712
+					$wp->query_vars['gd_city'] = $gd_city;
713
+				} else {
714
+					$gd_country = '';
715
+					$gd_region = '';
716
+					$gd_city = '';
707 717
 				}
718
+			}
719
+
720
+			$wp->query_vars[$geodir_taxonomy] = $geodir_term;
721
+			// eliminate location related terms from taxonomy term
722
+			if ($gd_country != '')
723
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
724
+
725
+			if ($gd_region != '')
726
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
727
+
728
+			if ($gd_city != '')
729
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
708 730
 
709
-                if ($is_geodir_location_found) {
710
-                    $wp->query_vars['gd_country'] = $gd_country;
711
-                    $wp->query_vars['gd_region'] = $gd_region;
712
-                    $wp->query_vars['gd_city'] = $gd_city;
713
-                } else {
714
-                    $gd_country = '';
715
-                    $gd_region = '';
716
-                    $gd_city = '';
717
-                }
718
-            }
719
-
720
-            $wp->query_vars[$geodir_taxonomy] = $geodir_term;
721
-            // eliminate location related terms from taxonomy term
722
-            if ($gd_country != '')
723
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
724
-
725
-            if ($gd_region != '')
726
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
727
-
728
-            if ($gd_city != '')
729
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
730
-
731
-
732
-            $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
733
-            $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
734
-
735
-            $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
736
-
737
-            if ($wp->query_vars[$geodir_taxonomy] == '') {
738
-                unset($wp->query_vars[$geodir_taxonomy]);
739
-            } else {
740
-                if (!$is_geodir_taxonomy_term) {
741
-                    foreach ($wp->query_vars as $key => $vars) {
742
-                        unset($wp->query_vars[$key]);
743
-                    }
744
-                    $wp->query_vars['error'] = '404';
745
-                }
746
-            }
747
-        }
748
-    }
731
+
732
+			$wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
733
+			$wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
734
+
735
+			$wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
736
+
737
+			if ($wp->query_vars[$geodir_taxonomy] == '') {
738
+				unset($wp->query_vars[$geodir_taxonomy]);
739
+			} else {
740
+				if (!$is_geodir_taxonomy_term) {
741
+					foreach ($wp->query_vars as $key => $vars) {
742
+						unset($wp->query_vars[$key]);
743
+					}
744
+					$wp->query_vars['error'] = '404';
745
+				}
746
+			}
747
+		}
748
+	}
749 749
 	
750 750
 	// Unset location session if gd page and location not set.
751 751
 	if (isset($wp->query_vars['gd_is_geodir_page']) && !isset($wp->query_vars['gd_country'])) {
752 752
 		$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
753 753
 	}
754 754
 
755
-    if ($gd_session->get('gd_multi_location') == 1) {
756
-        $wp->query_vars['gd_country'] = $gd_session->get('gd_country');
757
-        $wp->query_vars['gd_region'] = $gd_session->get('gd_region');
758
-        $wp->query_vars['gd_city'] = $gd_session->get('gd_city');
759
-    }
755
+	if ($gd_session->get('gd_multi_location') == 1) {
756
+		$wp->query_vars['gd_country'] = $gd_session->get('gd_country');
757
+		$wp->query_vars['gd_region'] = $gd_session->get('gd_region');
758
+		$wp->query_vars['gd_city'] = $gd_session->get('gd_city');
759
+	}
760 760
 
761
-    // now check if there is location parts in the url or not
762
-    if (get_option('geodir_add_location_url')) {        
761
+	// now check if there is location parts in the url or not
762
+	if (get_option('geodir_add_location_url')) {        
763 763
 		if ($geodir_show_location_url == 'all') {
764 764
 		} else if ($geodir_show_location_url == 'country_city') {
765 765
 			 if (isset($wp->query_vars['gd_region']))
766
-                $wp->query_vars['gd_region'] = '';
766
+				$wp->query_vars['gd_region'] = '';
767 767
 		} else if ($geodir_show_location_url == 'region_city') {
768 768
 			if (isset($wp->query_vars['gd_country']))
769
-                $wp->query_vars['gd_country'] = '';
769
+				$wp->query_vars['gd_country'] = '';
770 770
 		} else {
771 771
 			if (isset($wp->query_vars['gd_country']))
772
-                $wp->query_vars['gd_country'] = '';
772
+				$wp->query_vars['gd_country'] = '';
773 773
 
774
-            if (isset($wp->query_vars['gd_region']))
775
-                $wp->query_vars['gd_region'] = '';
774
+			if (isset($wp->query_vars['gd_region']))
775
+				$wp->query_vars['gd_region'] = '';
776 776
 		}
777
-    } else {
778
-        if (isset($wp->query_vars['gd_country']))
779
-            $wp->query_vars['gd_country'] = '';
777
+	} else {
778
+		if (isset($wp->query_vars['gd_country']))
779
+			$wp->query_vars['gd_country'] = '';
780 780
 
781
-        if (isset($wp->query_vars['gd_region']))
782
-            $wp->query_vars['gd_region'] = '';
781
+		if (isset($wp->query_vars['gd_region']))
782
+			$wp->query_vars['gd_region'] = '';
783 783
 
784
-        if (isset($wp->query_vars['gd_city']))
785
-            $wp->query_vars['gd_city'] = '';
786
-    }
784
+		if (isset($wp->query_vars['gd_city']))
785
+			$wp->query_vars['gd_city'] = '';
786
+	}
787 787
 }
788 788
 
789 789
 /**
@@ -797,24 +797,24 @@  discard block
 block discarded – undo
797 797
  */
798 798
 function geodir_custom_post_status()
799 799
 {
800
-    // Virtual Page Status
801
-    register_post_status('virtual', array(
802
-        'label' => _x('Virtual', 'page', 'geodirectory'),
803
-        'public' => true,
804
-        'exclude_from_search' => true,
805
-        'show_in_admin_all_list' => true,
806
-        'show_in_admin_status_list' => true,
807
-        'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
808
-    ));
809
-
810
-    /**
811
-     * Called after we register the custom post status 'Virtual'.
812
-     *
813
-     * Can be use to add more post statuses.
814
-     *
815
-     * @since 1.0.0
816
-     */
817
-    do_action('geodir_custom_post_status');
800
+	// Virtual Page Status
801
+	register_post_status('virtual', array(
802
+		'label' => _x('Virtual', 'page', 'geodirectory'),
803
+		'public' => true,
804
+		'exclude_from_search' => true,
805
+		'show_in_admin_all_list' => true,
806
+		'show_in_admin_status_list' => true,
807
+		'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
808
+	));
809
+
810
+	/**
811
+	 * Called after we register the custom post status 'Virtual'.
812
+	 *
813
+	 * Can be use to add more post statuses.
814
+	 *
815
+	 * @since 1.0.0
816
+	 */
817
+	do_action('geodir_custom_post_status');
818 818
 }
819 819
 
820 820
 /**
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
  */
830 830
 function geodir_get_term_link($termlink, $term, $taxonomy)
831 831
 {
832
-    return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php
832
+	return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php
833 833
 }
834 834
 
835 835
 /**
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
  */
844 844
 function geodir_get_posttype_link($link, $post_type)
845 845
 {
846
-    return geodir_posttype_link($link, $post_type); // taxonomy_functions.php
846
+	return geodir_posttype_link($link, $post_type); // taxonomy_functions.php
847 847
 }
848 848
 
849 849
 /**
@@ -858,13 +858,13 @@  discard block
 block discarded – undo
858 858
  */
859 859
 function exclude_from_wp_list_pages($exclude_array)
860 860
 {
861
-    $pages_ids = array();
862
-    $pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
863
-    foreach ($pages_array as $page) {
864
-        $pages_ids[] = $page->ID;
865
-    }
866
-    $exclude_array = $exclude_array + $pages_ids;
867
-    return $exclude_array;
861
+	$pages_ids = array();
862
+	$pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
863
+	foreach ($pages_array as $page) {
864
+		$pages_ids[] = $page->ID;
865
+	}
866
+	$exclude_array = $exclude_array + $pages_ids;
867
+	return $exclude_array;
868 868
 }
869 869
 
870 870
 /**
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
  */
878 878
 function geodir_exclude_page($query)
879 879
 {
880
-    add_filter('posts_where', 'geodir_exclude_page_where', 100);
881
-    return $query;
880
+	add_filter('posts_where', 'geodir_exclude_page_where', 100);
881
+	return $query;
882 882
 }
883 883
 
884 884
 /**
@@ -893,11 +893,11 @@  discard block
 block discarded – undo
893 893
  */
894 894
 function geodir_exclude_page_where($where)
895 895
 {
896
-    global $wpdb;
897
-    if (is_admin())
898
-        $where .= " AND $wpdb->posts.post_status != 'virtual'";
896
+	global $wpdb;
897
+	if (is_admin())
898
+		$where .= " AND $wpdb->posts.post_status != 'virtual'";
899 899
 
900
-    return $where;
900
+	return $where;
901 901
 }
902 902
 
903 903
 /**
@@ -912,21 +912,21 @@  discard block
 block discarded – undo
912 912
  * @return mixed The taxonomy option value.
913 913
  */
914 914
 function geodir_wpseo_taxonomy_meta( $value, $option = '' ) {
915
-    global $wp_query;
915
+	global $wp_query;
916 916
     
917
-    if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
918
-        $term = $wp_query->get_queried_object();
917
+	if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
918
+		$term = $wp_query->get_queried_object();
919 919
         
920
-        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() ) ) {
921
-            $image  = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) );
920
+		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() ) ) {
921
+			$image  = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) );
922 922
             
923
-            if ( !empty( $image['src'] ) ) {
924
-                $value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src'];
925
-                $value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src'];
926
-            }
927
-        }
928
-    }
929
-    return $value;
923
+			if ( !empty( $image['src'] ) ) {
924
+				$value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src'];
925
+				$value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src'];
926
+			}
927
+		}
928
+	}
929
+	return $value;
930 930
 }
931 931
 add_filter( 'option_wpseo_taxonomy_meta', 'geodir_wpseo_taxonomy_meta', 10, 2 );
932 932
 
@@ -937,24 +937,24 @@  discard block
 block discarded – undo
937 937
  *
938 938
  */
939 939
 function geodir_affiliate_wp_rewrite_fix() {
940
-    if ( !class_exists( 'Affiliate_WP' ) ) {
941
-        return;
942
-    }
943
-
944
-    $gd_post_types = geodir_get_posttypes( 'array' );
945
-
946
-    if ( !empty( $gd_post_types ) ) {
947
-        $ref = affiliate_wp()->tracking->get_referral_var();
948
-        if ( empty( $ref ) ) {
949
-            return;
950
-        }
951
-
952
-        foreach ( $gd_post_types as $key => $post_type ) {
953
-            if ( !empty( $key ) && !empty( $post_type['rewrite']['slug'] ) ) {
954
-                add_rewrite_rule( $post_type['rewrite']['slug'] . '/' . $ref . '(/(.*))?/page/([0-9]{1,})/?$', 'index.php?post_type=' . $key . '&' . $ref . '=$matches[1]&paged=$matches[3]', 'top');
955
-                add_rewrite_rule( $post_type['rewrite']['slug'] . '/' . $ref . '(/(.*))?/?$', 'index.php?post_type=' . $key . '&' . $ref . '=$matches[1]', 'top');
956
-            }
957
-        }
958
-    }
940
+	if ( !class_exists( 'Affiliate_WP' ) ) {
941
+		return;
942
+	}
943
+
944
+	$gd_post_types = geodir_get_posttypes( 'array' );
945
+
946
+	if ( !empty( $gd_post_types ) ) {
947
+		$ref = affiliate_wp()->tracking->get_referral_var();
948
+		if ( empty( $ref ) ) {
949
+			return;
950
+		}
951
+
952
+		foreach ( $gd_post_types as $key => $post_type ) {
953
+			if ( !empty( $key ) && !empty( $post_type['rewrite']['slug'] ) ) {
954
+				add_rewrite_rule( $post_type['rewrite']['slug'] . '/' . $ref . '(/(.*))?/page/([0-9]{1,})/?$', 'index.php?post_type=' . $key . '&' . $ref . '=$matches[1]&paged=$matches[3]', 'top');
955
+				add_rewrite_rule( $post_type['rewrite']['slug'] . '/' . $ref . '(/(.*))?/?$', 'index.php?post_type=' . $key . '&' . $ref . '=$matches[1]', 'top');
956
+			}
957
+		}
958
+	}
959 959
 }
960 960
 add_action( 'init', 'geodir_affiliate_wp_rewrite_fix', 99999 );
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
             if (!empty($args['labels'])) {
70 70
                 foreach ($args['labels'] as $key => $val) {
71
-                    $args['labels'][$key] = __($val, 'geodirectory');// allow translation
71
+                    $args['labels'][$key] = __($val, 'geodirectory'); // allow translation
72 72
                 }
73 73
             }
74 74
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
             if (array_key_exists('rewrite', $args)) {
111 111
                 if (array_key_exists('slug', $args['rewrite']))
112
-                    $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
112
+                    $args['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%';
113 113
             }
114 114
 
115 115
             $geodir_post_types = get_option('geodir_post_types');
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
                 if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
123 123
                     if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
124
-                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
124
+                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%';
125 125
 
126 126
                 update_option('geodir_post_types', $geodir_post_types);
127 127
 
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 
134 134
             $geodir_taxonomies = get_option('geodir_taxonomies');
135 135
 
136
-            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
137
-                $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
136
+            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type.'category'])) {
137
+                $geodir_taxonomies[$post_type.'category']['listing_slug'] = $listing_slug;
138 138
 
139
-                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
140
-                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
141
-                        if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
142
-                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
139
+                if (array_key_exists('args', $geodir_taxonomies[$post_type.'category']))
140
+                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type.'category']['args']))
141
+                        if (array_key_exists('slug', $geodir_taxonomies[$post_type.'category']['args']['rewrite']))
142
+                            $geodir_taxonomies[$post_type.'category']['args']['rewrite']['slug'] = $listing_slug;
143 143
 
144 144
                 update_option('geodir_taxonomies', $geodir_taxonomies);
145 145
 
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
 
148 148
             /* --- update taxonomies (tags) --- */
149 149
             $geodir_taxonomies_tag = get_option('geodir_taxonomies');
150
-            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
151
-                $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
150
+            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type.'_tags'])) {
151
+                $geodir_taxonomies_tag[$post_type.'_tags']['listing_slug'] = $listing_slug.'/tags';
152 152
 
153
-                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
154
-                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
155
-                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
156
-                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
153
+                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type.'_tags']))
154
+                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type.'_tags']['args']))
155
+                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type.'_tags']['args']['rewrite']))
156
+                            $geodir_taxonomies_tag[$post_type.'_tags']['args']['rewrite']['slug'] = $listing_slug.'/tags';
157 157
 
158 158
                 update_option('geodir_taxonomies', $geodir_taxonomies_tag);
159 159
 
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
             $listing_slug = $args['listing_slug'];
204 204
 
205 205
             if (strpos($taxonomy, 'tags')) {
206
-                $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
207
-                $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
206
+                $newrules[$listing_slug.'/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?'.$taxonomy.'=$matches[1]&paged=$matches[2]';
207
+                $newrules[$listing_slug.'/(.+?)/?$'] = 'index.php?'.$taxonomy.'=$matches[1]';
208 208
             } else {
209 209
                 // use this loop to add paging for details page comments paging
210
-                $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
210
+                $newrules[str_replace("/tags", "", $listing_slug).'/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?'.$taxonomy.'=$matches[1]&cpage=$matches[2]';
211 211
             }
212 212
         endforeach;
213 213
     endif;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
     // create rules for location listing
216 216
     $location_page = get_option('geodir_location_page');
217 217
 	
218
-    if($location_page) {
218
+    if ($location_page) {
219 219
         global $wpdb;
220 220
         $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
221 221
     }
@@ -245,30 +245,30 @@  discard block
 block discarded – undo
245 245
 		
246 246
 		if ($matches2) {
247 247
 			if ($neighbourhood_active) {
248
-				$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]';
248
+				$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]&gd_neighbourhood=$matches[3]';
249 249
 			}
250
-			$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]';
250
+			$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]';
251 251
 		} else {
252 252
 			if ($neighbourhood_active) {
253
-				$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]';
253
+				$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&gd_neighbourhood=$matches[2]';
254 254
 			}
255 255
 		}
256 256
 		
257
-		$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]';
257
+		$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]';
258 258
 	} else { // country/region/city
259 259
 		if ($neighbourhood_active) {
260
-			$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]';
260
+			$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]';
261 261
 		}
262
-		$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
263
-		$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]';
264
-		$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]';
262
+		$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
263
+		$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]';
264
+		$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]';
265 265
 	}
266 266
 
267 267
     if ($location_page && geodir_is_wpml()) {
268
-        foreach(icl_get_languages('skip_missing=N') as $lang){
268
+        foreach (icl_get_languages('skip_missing=N') as $lang) {
269 269
             $alt_page_id = '';
270
-            $alt_page_id = geodir_wpml_object_id($location_page, 'page', false,$lang['language_code']);
271
-            if($alt_page_id){
270
+            $alt_page_id = geodir_wpml_object_id($location_page, 'page', false, $lang['language_code']);
271
+            if ($alt_page_id) {
272 272
                 $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
273 273
 
274 274
 				if ($location_manager && ($hide_country_part || $hide_region_part)) {
@@ -287,29 +287,29 @@  discard block
 block discarded – undo
287 287
 					
288 288
 					if ($matches2) {
289 289
 						if ($neighbourhood_active) {
290
-							$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]';
290
+							$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]&gd_neighbourhood=$matches[3]';
291 291
 						}
292
-						$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]';
292
+						$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]';
293 293
 					} else {
294 294
 						if ($neighbourhood_active) {
295
-							$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]';
295
+							$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&gd_neighbourhood=$matches[2]';
296 296
 						}
297 297
 					}
298 298
 					
299
-					$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]';
299
+					$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]';
300 300
 				} else { // country/region/city
301 301
 					if ($neighbourhood_active) {
302
-						$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]';
302
+						$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]';
303 303
 					}
304
-					$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
305
-					$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]';
306
-					$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]';
304
+					$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
305
+					$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]';
306
+					$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]';
307 307
 				}
308 308
             }
309 309
         }
310 310
     }
311 311
 
312
-    $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page;
312
+    $newrules[$location_prefix.'/?$'] = 'index.php?page_id='.$location_page;
313 313
 
314 314
     $rules = array_merge($newrules, $rules);
315 315
     return $rules;
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 #Redirect 301 /location/ /$location_prefix/
339 339
 # END GeoDirectory Rules\n\n
340 340
 EOD;
341
-    return $my_content . $rules;
341
+    return $my_content.$rules;
342 342
 }
343 343
 //add_filter('mod_rewrite_rules', 'geodir_htaccess_contents');
344 344
 
@@ -414,12 +414,12 @@  discard block
 block discarded – undo
414 414
         global $wpdb;
415 415
 
416 416
         $page_for_posts = get_option('page_for_posts');
417
-        $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']));
417
+        $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']));
418 418
 
419 419
         if (geodir_is_wpml()) {
420 420
             $real_page_id = geodir_wpml_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
421 421
         }
422
-        if ($real_page_id && $real_page_id!=$page_for_posts) {
422
+        if ($real_page_id && $real_page_id != $page_for_posts) {
423 423
             $wp->query_vars['page_id'] = $real_page_id;
424 424
         }
425 425
     }
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
                             $gd_city = $default_location->city_slug;
467 467
 
468 468
                         $base_location_link = geodir_get_location_link('base');
469
-                        wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
469
+                        wp_redirect($base_location_link.'/'.$gd_country.'/'.$gd_region.'/'.$gd_city);
470 470
                         exit();
471 471
                     }
472 472
                 }
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         $geodir_set_location_session = true;
528 528
         $geodir_taxonomis = geodir_get_taxonomies('', true);
529 529
 
530
-        if(!empty($geodir_taxonomis)){
530
+        if (!empty($geodir_taxonomis)) {
531 531
             foreach ($geodir_taxonomis as $taxonomy) {
532 532
                 if (array_key_exists($taxonomy, $wp->query_vars)) {
533 533
                     $is_geodir_taxonomy = true;
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 				}
585 585
 
586 586
 
587
-				$geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
587
+				$geodir_term = str_replace('/'.$geodir_last_term, '', $geodir_term, $post_title_replace_count);
588 588
 				if (!$post_title_replace_count)
589 589
 					$geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count);
590 590
 				$geodir_terms = explode('/', $geodir_term);
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
662 662
                             $is_geodir_location_found = true;
663 663
                     }
664
-                }  else if ($geodir_show_location_url == 'region_city') {
664
+                } else if ($geodir_show_location_url == 'region_city') {
665 665
                     if (count($geodir_terms) >= 2) {
666 666
                         $gd_region = urldecode($geodir_terms[0]);
667 667
                         $gd_city = urldecode($geodir_terms[1]);
@@ -720,13 +720,13 @@  discard block
 block discarded – undo
720 720
             $wp->query_vars[$geodir_taxonomy] = $geodir_term;
721 721
             // eliminate location related terms from taxonomy term
722 722
             if ($gd_country != '')
723
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
723
+                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_country).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
724 724
 
725 725
             if ($gd_region != '')
726
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
726
+                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_region).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
727 727
 
728 728
             if ($gd_city != '')
729
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
729
+                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_city).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
730 730
 
731 731
 
732 732
             $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
@@ -911,16 +911,16 @@  discard block
 block discarded – undo
911 911
  * @param string $option Option name.
912 912
  * @return mixed The taxonomy option value.
913 913
  */
914
-function geodir_wpseo_taxonomy_meta( $value, $option = '' ) {
914
+function geodir_wpseo_taxonomy_meta($value, $option = '') {
915 915
     global $wp_query;
916 916
     
917
-    if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
917
+    if (!empty($value) && (is_category() || is_tax())) {
918 918
         $term = $wp_query->get_queried_object();
919 919
         
920
-        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() ) ) {
921
-            $image  = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) );
920
+        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())) {
921
+            $image = geodir_get_default_catimage($term->term_id, str_replace('category', '', $term->taxonomy));
922 922
             
923
-            if ( !empty( $image['src'] ) ) {
923
+            if (!empty($image['src'])) {
924 924
                 $value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src'];
925 925
                 $value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src'];
926 926
             }
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
     }
929 929
     return $value;
930 930
 }
931
-add_filter( 'option_wpseo_taxonomy_meta', 'geodir_wpseo_taxonomy_meta', 10, 2 );
931
+add_filter('option_wpseo_taxonomy_meta', 'geodir_wpseo_taxonomy_meta', 10, 2);
932 932
 
933 933
 /**
934 934
  * Fix affiliate links for GeoDirectory CPTs listing pages.
@@ -937,24 +937,24 @@  discard block
 block discarded – undo
937 937
  *
938 938
  */
939 939
 function geodir_affiliate_wp_rewrite_fix() {
940
-    if ( !class_exists( 'Affiliate_WP' ) ) {
940
+    if (!class_exists('Affiliate_WP')) {
941 941
         return;
942 942
     }
943 943
 
944
-    $gd_post_types = geodir_get_posttypes( 'array' );
944
+    $gd_post_types = geodir_get_posttypes('array');
945 945
 
946
-    if ( !empty( $gd_post_types ) ) {
946
+    if (!empty($gd_post_types)) {
947 947
         $ref = affiliate_wp()->tracking->get_referral_var();
948
-        if ( empty( $ref ) ) {
948
+        if (empty($ref)) {
949 949
             return;
950 950
         }
951 951
 
952
-        foreach ( $gd_post_types as $key => $post_type ) {
953
-            if ( !empty( $key ) && !empty( $post_type['rewrite']['slug'] ) ) {
954
-                add_rewrite_rule( $post_type['rewrite']['slug'] . '/' . $ref . '(/(.*))?/page/([0-9]{1,})/?$', 'index.php?post_type=' . $key . '&' . $ref . '=$matches[1]&paged=$matches[3]', 'top');
955
-                add_rewrite_rule( $post_type['rewrite']['slug'] . '/' . $ref . '(/(.*))?/?$', 'index.php?post_type=' . $key . '&' . $ref . '=$matches[1]', 'top');
952
+        foreach ($gd_post_types as $key => $post_type) {
953
+            if (!empty($key) && !empty($post_type['rewrite']['slug'])) {
954
+                add_rewrite_rule($post_type['rewrite']['slug'].'/'.$ref.'(/(.*))?/page/([0-9]{1,})/?$', 'index.php?post_type='.$key.'&'.$ref.'=$matches[1]&paged=$matches[3]', 'top');
955
+                add_rewrite_rule($post_type['rewrite']['slug'].'/'.$ref.'(/(.*))?/?$', 'index.php?post_type='.$key.'&'.$ref.'=$matches[1]', 'top');
956 956
             }
957 957
         }
958 958
     }
959 959
 }
960
-add_action( 'init', 'geodir_affiliate_wp_rewrite_fix', 99999 );
960
+add_action('init', 'geodir_affiliate_wp_rewrite_fix', 99999);
Please login to merge, or discard this patch.
geodirectory-functions/taxonomy_functions.php 1 patch
Indentation   +1272 added lines, -1272 removed lines patch added patch discarded remove patch
@@ -33,265 +33,265 @@  discard block
 block discarded – undo
33 33
  */
34 34
 function geodir_add_nav_menu_items()
35 35
 {
36
-    $items = '';
37
-    // apply filter to add more navigations // -Filter-Location-Manager
38
-
39
-    if (get_option('geodir_show_listing_nav')) {
40
-
41
-        $menu_class = '';
42
-        if (geodir_is_page('listing'))
43
-            $menu_class = 'current-menu-item';
44
-
45
-
46
-        //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
47
-        $post_types = geodir_get_posttypes('object');
48
-        $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
49
-        if (!empty($post_types)) {
50
-            foreach ($post_types as $post_type => $args) {
51
-                if (!empty($show_post_type_main_nav)) {
52
-                    if (in_array($post_type, $show_post_type_main_nav)) {
53
-                        if (get_post_type_archive_link($post_type)) {
54
-                            $menu_class = '';
55
-                            if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
-                                $menu_class = 'current-menu-item';
57
-                            /**
58
-                             * Filter the menu li class.
59
-                             *
60
-                             * @since 1.0.0
61
-                             * @param string $menu_class The menu HTML class.
62
-                             */
63
-                            $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
64
-                            /**
65
-                             * Filter the menu a class.
66
-                             *
67
-                             * @since 1.0.0
68
-                             */
69
-                            $a_class = apply_filters('geodir_menu_a_class', '');
70
-                            $items .= '<li class="' . $li_class . '">
36
+	$items = '';
37
+	// apply filter to add more navigations // -Filter-Location-Manager
38
+
39
+	if (get_option('geodir_show_listing_nav')) {
40
+
41
+		$menu_class = '';
42
+		if (geodir_is_page('listing'))
43
+			$menu_class = 'current-menu-item';
44
+
45
+
46
+		//SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
47
+		$post_types = geodir_get_posttypes('object');
48
+		$show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
49
+		if (!empty($post_types)) {
50
+			foreach ($post_types as $post_type => $args) {
51
+				if (!empty($show_post_type_main_nav)) {
52
+					if (in_array($post_type, $show_post_type_main_nav)) {
53
+						if (get_post_type_archive_link($post_type)) {
54
+							$menu_class = '';
55
+							if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
+								$menu_class = 'current-menu-item';
57
+							/**
58
+							 * Filter the menu li class.
59
+							 *
60
+							 * @since 1.0.0
61
+							 * @param string $menu_class The menu HTML class.
62
+							 */
63
+							$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
64
+							/**
65
+							 * Filter the menu a class.
66
+							 *
67
+							 * @since 1.0.0
68
+							 */
69
+							$a_class = apply_filters('geodir_menu_a_class', '');
70
+							$items .= '<li class="' . $li_class . '">
71 71
 									<a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '">
72 72
 										' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . '
73 73
 									</a>
74 74
 								</li>';
75
-                        }
76
-                    }
77
-                }
78
-            }
79
-        }
80
-        //END LISTING OF POST TYPE IN MAIN NAVIGATION
81
-
82
-        $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
83
-        $is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false;
84
-        if ($is_listing_sub_meny_exists) {
85
-            /**
86
-             * Filter the menu li class.
87
-             *
88
-             * @since 1.0.0
89
-             * @param string $menu_class The menu HTML class.
90
-             */
91
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
92
-            /**
93
-             * Filter the sub menu li class.
94
-             *
95
-             * @since 1.0.0
96
-             * @param string $menu_class The menu HTML class.
97
-             */
98
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
99
-            /**
100
-             * Filter the sub menu ul class.
101
-             *
102
-             * @since 1.0.0
103
-             */
104
-            $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
105
-            /**
106
-             * Filter the menu a class.
107
-             *
108
-             * @since 1.0.0
109
-             */
110
-            $a_class = apply_filters('geodir_menu_a_class', '');
111
-            /**
112
-             * Filter the sub menu a class.
113
-             *
114
-             * @since 1.0.0
115
-             */
116
-            $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
117
-            $items .= '<li class="' . $li_class . '">
75
+						}
76
+					}
77
+				}
78
+			}
79
+		}
80
+		//END LISTING OF POST TYPE IN MAIN NAVIGATION
81
+
82
+		$view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
83
+		$is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false;
84
+		if ($is_listing_sub_meny_exists) {
85
+			/**
86
+			 * Filter the menu li class.
87
+			 *
88
+			 * @since 1.0.0
89
+			 * @param string $menu_class The menu HTML class.
90
+			 */
91
+			$li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
92
+			/**
93
+			 * Filter the sub menu li class.
94
+			 *
95
+			 * @since 1.0.0
96
+			 * @param string $menu_class The menu HTML class.
97
+			 */
98
+			$sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
99
+			/**
100
+			 * Filter the sub menu ul class.
101
+			 *
102
+			 * @since 1.0.0
103
+			 */
104
+			$sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
105
+			/**
106
+			 * Filter the menu a class.
107
+			 *
108
+			 * @since 1.0.0
109
+			 */
110
+			$a_class = apply_filters('geodir_menu_a_class', '');
111
+			/**
112
+			 * Filter the sub menu a class.
113
+			 *
114
+			 * @since 1.0.0
115
+			 */
116
+			$sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
117
+			$items .= '<li class="' . $li_class . '">
118 118
 					<a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a>
119 119
 					<ul class="' . $sub_ul_class . '">';
120
-            $post_types = geodir_get_posttypes('object');
120
+			$post_types = geodir_get_posttypes('object');
121 121
 
122
-            $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
122
+			$show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
123 123
 
124
-            if (!empty($post_types)) {
125
-                global $geodir_add_location_url;
126
-                $geodir_add_location_url = true;
127
-                foreach ($post_types as $post_type => $args) {
128
-                    if (!empty($show_listing_post_types)) {
129
-                        if (in_array($post_type, $show_listing_post_types)) {
130
-                            if (get_post_type_archive_link($post_type)) {
124
+			if (!empty($post_types)) {
125
+				global $geodir_add_location_url;
126
+				$geodir_add_location_url = true;
127
+				foreach ($post_types as $post_type => $args) {
128
+					if (!empty($show_listing_post_types)) {
129
+						if (in_array($post_type, $show_listing_post_types)) {
130
+							if (get_post_type_archive_link($post_type)) {
131 131
 
132
-                                $menu_class = '';
133
-                                if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
-                                    $menu_class = 'current-menu-item';
132
+								$menu_class = '';
133
+								if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
+									$menu_class = 'current-menu-item';
135 135
 
136
-                                $items .= '<li class="' . $sub_li_class . '">
136
+								$items .= '<li class="' . $sub_li_class . '">
137 137
 														<a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '">
138 138
 															' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . '
139 139
 														</a>
140 140
 													</li>';
141
-                            }
142
-                        }
143
-                    }
144
-                }
145
-                $geodir_add_location_url = NULL;
146
-            }
141
+							}
142
+						}
143
+					}
144
+				}
145
+				$geodir_add_location_url = NULL;
146
+			}
147 147
 
148
-            $items .= '	</ul> ';
149
-            /**
150
-             * Filter called after the sub menu closing ul tag for dynamic added menu items.
151
-             *
152
-             * @since 1.5.9
153
-             */
154
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
155
-            $items .= '</li>';
156
-        }
157
-    }
158
-
159
-    if (get_option('geodir_show_addlisting_nav')) {
160
-
161
-        $menu_class = '';
162
-        if (geodir_is_page('add-listing'))
163
-            $menu_class = 'current-menu-item';
164
-
165
-        //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166
-        $post_types = geodir_get_posttypes('object');
167
-        $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
168
-        $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
169
-
170
-        if (!empty($post_types)) {
171
-            foreach ($post_types as $post_type => $args) {
172
-                if (!empty($geodir_allow_posttype_frontend)) {
173
-                    if (in_array($post_type, $geodir_allow_posttype_frontend)) {
174
-                        if (!empty($show_add_listing_post_types_main_nav)) {
175
-                            if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
176
-                                if (geodir_get_addlisting_link($post_type)) {
177
-
178
-                                    $menu_class = '';
179
-                                    if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
-                                        $menu_class = 'current-menu-item';
181
-                                    /**
182
-                                     * Filter the menu li class.
183
-                                     *
184
-                                     * @since 1.0.0
185
-                                     * @param string $menu_class The menu HTML class.
186
-                                     */
187
-                                    $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
188
-                                    /**
189
-                                     * Filter the menu a class.
190
-                                     *
191
-                                     * @since 1.0.0
192
-                                     */
193
-                                    $a_class = apply_filters('geodir_menu_a_class', '');
194
-                                    $cpt_name = __($args->labels->singular_name, 'geodirectory');
195
-                                    $items .= '<li class="' . $li_class . '">
148
+			$items .= '	</ul> ';
149
+			/**
150
+			 * Filter called after the sub menu closing ul tag for dynamic added menu items.
151
+			 *
152
+			 * @since 1.5.9
153
+			 */
154
+			$items .= apply_filters('geodir_menu_after_sub_ul','');
155
+			$items .= '</li>';
156
+		}
157
+	}
158
+
159
+	if (get_option('geodir_show_addlisting_nav')) {
160
+
161
+		$menu_class = '';
162
+		if (geodir_is_page('add-listing'))
163
+			$menu_class = 'current-menu-item';
164
+
165
+		//SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166
+		$post_types = geodir_get_posttypes('object');
167
+		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
168
+		$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
169
+
170
+		if (!empty($post_types)) {
171
+			foreach ($post_types as $post_type => $args) {
172
+				if (!empty($geodir_allow_posttype_frontend)) {
173
+					if (in_array($post_type, $geodir_allow_posttype_frontend)) {
174
+						if (!empty($show_add_listing_post_types_main_nav)) {
175
+							if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
176
+								if (geodir_get_addlisting_link($post_type)) {
177
+
178
+									$menu_class = '';
179
+									if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
+										$menu_class = 'current-menu-item';
181
+									/**
182
+									 * Filter the menu li class.
183
+									 *
184
+									 * @since 1.0.0
185
+									 * @param string $menu_class The menu HTML class.
186
+									 */
187
+									$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
188
+									/**
189
+									 * Filter the menu a class.
190
+									 *
191
+									 * @since 1.0.0
192
+									 */
193
+									$a_class = apply_filters('geodir_menu_a_class', '');
194
+									$cpt_name = __($args->labels->singular_name, 'geodirectory');
195
+									$items .= '<li class="' . $li_class . '">
196 196
 											<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '">
197 197
 												' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
198 198
 											</a>
199 199
 										</li>';
200
-                                }
201
-                            }
202
-                        }
203
-                    }
204
-                }
205
-            }
206
-        }
207
-        //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
208
-    }
209
-
210
-    $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
211
-    $is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false;
212
-    if ($is_add_listing_sub_meny_exists) {
213
-
214
-        if (get_option('geodir_show_addlisting_nav')) {
215
-            /**
216
-             * Filter the menu li class.
217
-             *
218
-             * @since 1.0.0
219
-             * @param string $menu_class The menu HTML class.
220
-             */
221
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
222
-            /**
223
-             * Filter the sub menu li class.
224
-             *
225
-             * @since 1.0.0
226
-             * @param string $menu_class The menu HTML class.
227
-             */
228
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
229
-            /**
230
-             * Filter the sub menu ul class.
231
-             *
232
-             * @since 1.0.0
233
-             */
234
-            $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
235
-            /**
236
-             * Filter the menu a class.
237
-             *
238
-             * @since 1.0.0
239
-             */
240
-            $a_class = apply_filters('geodir_menu_a_class', '');
241
-            /**
242
-             * Filter the sub menu a class.
243
-             *
244
-             * @since 1.0.0
245
-             */
246
-            $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
247
-            $items .= '<li  class="' . $li_class . '">
200
+								}
201
+							}
202
+						}
203
+					}
204
+				}
205
+			}
206
+		}
207
+		//END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
208
+	}
209
+
210
+	$view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
211
+	$is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false;
212
+	if ($is_add_listing_sub_meny_exists) {
213
+
214
+		if (get_option('geodir_show_addlisting_nav')) {
215
+			/**
216
+			 * Filter the menu li class.
217
+			 *
218
+			 * @since 1.0.0
219
+			 * @param string $menu_class The menu HTML class.
220
+			 */
221
+			$li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
222
+			/**
223
+			 * Filter the sub menu li class.
224
+			 *
225
+			 * @since 1.0.0
226
+			 * @param string $menu_class The menu HTML class.
227
+			 */
228
+			$sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
229
+			/**
230
+			 * Filter the sub menu ul class.
231
+			 *
232
+			 * @since 1.0.0
233
+			 */
234
+			$sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
235
+			/**
236
+			 * Filter the menu a class.
237
+			 *
238
+			 * @since 1.0.0
239
+			 */
240
+			$a_class = apply_filters('geodir_menu_a_class', '');
241
+			/**
242
+			 * Filter the sub menu a class.
243
+			 *
244
+			 * @since 1.0.0
245
+			 */
246
+			$sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
247
+			$items .= '<li  class="' . $li_class . '">
248 248
 					<a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a>
249 249
 					<ul class="' . $sub_ul_class . '">';
250 250
 
251
-            $post_types = geodir_get_posttypes('object');
252
-
253
-            $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
254
-
255
-            if (!empty($post_types)) {
256
-                foreach ($post_types as $post_type => $args) {
257
-                    if (!empty($geodir_allow_posttype_frontend)) {
258
-                        if (in_array($post_type, $geodir_allow_posttype_frontend)) {
259
-                            if (!empty($show_add_listing_post_types)) {
260
-                                if (in_array($post_type, $show_add_listing_post_types)) {
261
-                                    if (geodir_get_addlisting_link($post_type)) {
262
-
263
-                                        $menu_class = '';
264
-                                        if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
-                                            $menu_class = 'current-menu-item';
266
-                                        /**
267
-                                         * Filter the menu li class.
268
-                                         *
269
-                                         * @since 1.0.0
270
-                                         * @param string $menu_class The menu HTML class.
271
-                                         */
272
-                                        $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
273
-                                        $cpt_name = __($args->labels->singular_name, 'geodirectory');
274
-                                        $items .= '<li class="' . $sub_li_class . '">
251
+			$post_types = geodir_get_posttypes('object');
252
+
253
+			$show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
254
+
255
+			if (!empty($post_types)) {
256
+				foreach ($post_types as $post_type => $args) {
257
+					if (!empty($geodir_allow_posttype_frontend)) {
258
+						if (in_array($post_type, $geodir_allow_posttype_frontend)) {
259
+							if (!empty($show_add_listing_post_types)) {
260
+								if (in_array($post_type, $show_add_listing_post_types)) {
261
+									if (geodir_get_addlisting_link($post_type)) {
262
+
263
+										$menu_class = '';
264
+										if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
+											$menu_class = 'current-menu-item';
266
+										/**
267
+										 * Filter the menu li class.
268
+										 *
269
+										 * @since 1.0.0
270
+										 * @param string $menu_class The menu HTML class.
271
+										 */
272
+										$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
273
+										$cpt_name = __($args->labels->singular_name, 'geodirectory');
274
+										$items .= '<li class="' . $sub_li_class . '">
275 275
 														<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '">
276 276
 															' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
277 277
 														</a>
278 278
 													</li>';
279
-                                    }
280
-                                }
281
-                            }
282
-                        }
283
-                    }
284
-                }
285
-            }
279
+									}
280
+								}
281
+							}
282
+						}
283
+					}
284
+				}
285
+			}
286 286
 
287
-            $items .= '	</ul> ';
288
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
289
-            $items .= '</li>';
287
+			$items .= '	</ul> ';
288
+			$items .= apply_filters('geodir_menu_after_sub_ul','');
289
+			$items .= '</li>';
290 290
 
291
-        }
292
-    }
293
-    // apply filter to add more navigations // -Filter-Location-Manager
294
-    return $items;
291
+		}
292
+	}
293
+	// apply filter to add more navigations // -Filter-Location-Manager
294
+	return $items;
295 295
 }
296 296
 
297 297
 
@@ -309,20 +309,20 @@  discard block
 block discarded – undo
309 309
  */
310 310
 function geodir_pagemenu_items($menu, $args)
311 311
 {
312
-    $locations = get_nav_menu_locations();
313
-    $geodir_theme_location = get_option('geodir_theme_location_nav');
314
-    $geodir_theme_location_nav = array();
315
-    if (empty($locations) && empty($geodir_theme_location)) {
316
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
317
-        $geodir_theme_location_nav[] = $args['theme_location'];
318
-        update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
319
-    }
320
-    //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
312
+	$locations = get_nav_menu_locations();
313
+	$geodir_theme_location = get_option('geodir_theme_location_nav');
314
+	$geodir_theme_location_nav = array();
315
+	if (empty($locations) && empty($geodir_theme_location)) {
316
+		$menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
317
+		$geodir_theme_location_nav[] = $args['theme_location'];
318
+		update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
319
+	}
320
+	//else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
321 321
 //		$menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
322
-    else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
322
+	else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
+		$menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
324 324
 
325
-    return $menu;
325
+	return $menu;
326 326
 
327 327
 }
328 328
 
@@ -342,18 +342,18 @@  discard block
 block discarded – undo
342 342
 function geodir_menu_items($items, $args)
343 343
 {
344 344
 
345
-    $location = $args->theme_location;
345
+	$location = $args->theme_location;
346 346
 
347
-    $geodir_theme_location = get_option('geodir_theme_location_nav');
347
+	$geodir_theme_location = get_option('geodir_theme_location_nav');
348 348
 
349
-    if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
349
+	if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
350 350
 
351
-        $items = $items . geodir_add_nav_menu_items();
352
-        return $items;
351
+		$items = $items . geodir_add_nav_menu_items();
352
+		return $items;
353 353
 
354
-    } else {
355
-        return $items;
356
-    }
354
+	} else {
355
+		return $items;
356
+	}
357 357
 }
358 358
 
359 359
 /**
@@ -368,25 +368,25 @@  discard block
 block discarded – undo
368 368
  */
369 369
 function geodir_get_category_all_array()
370 370
 {
371
-    global $wpdb;
372
-    $return_array = array();
373
-
374
-    $taxonomies = geodir_get_taxonomies();
375
-    $taxonomies = implode("','", $taxonomies);
376
-    $taxonomies = "'" . $taxonomies . "'";
377
-
378
-    $pn_categories = $wpdb->get_results(
379
-        $wpdb->prepare(
380
-            "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy,  $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name",
381
-            array($wpdb->terms . term_id)
382
-        )
383
-    );
384
-
385
-    foreach ($pn_categories as $pn_categories_obj) {
386
-        $return_array[] = array("id" => $pn_categories_obj->cat_ID,
387
-            "title" => $pn_categories_obj->name,);
388
-    }
389
-    return $return_array;
371
+	global $wpdb;
372
+	$return_array = array();
373
+
374
+	$taxonomies = geodir_get_taxonomies();
375
+	$taxonomies = implode("','", $taxonomies);
376
+	$taxonomies = "'" . $taxonomies . "'";
377
+
378
+	$pn_categories = $wpdb->get_results(
379
+		$wpdb->prepare(
380
+			"SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy,  $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name",
381
+			array($wpdb->terms . term_id)
382
+		)
383
+	);
384
+
385
+	foreach ($pn_categories as $pn_categories_obj) {
386
+		$return_array[] = array("id" => $pn_categories_obj->cat_ID,
387
+			"title" => $pn_categories_obj->name,);
388
+	}
389
+	return $return_array;
390 390
 }
391 391
 
392 392
 
@@ -402,49 +402,49 @@  discard block
 block discarded – undo
402 402
  * @return string The post type.
403 403
  */
404 404
 function geodir_get_current_posttype() {
405
-    global $wp_query, $post, $geodir_post_type;
405
+	global $wp_query, $post, $geodir_post_type;
406 406
 
407
-    $geodir_post_type = get_query_var('post_type');
407
+	$geodir_post_type = get_query_var('post_type');
408 408
 
409
-    if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
-            $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
412
-        elseif (isset($_REQUEST['listing_type']))
413
-            $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
414
-    }
409
+	if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
+			$geodir_post_type = get_post_type((int)$_REQUEST['pid']);
412
+		elseif (isset($_REQUEST['listing_type']))
413
+			$geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
414
+	}
415 415
 
416
-    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
417
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
416
+	if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
417
+		$geodir_post_type = sanitize_text_field($_REQUEST['stype']);
418 418
 
419
-    if (is_tax())
420
-        $geodir_post_type = geodir_get_taxonomy_posttype();
419
+	if (is_tax())
420
+		$geodir_post_type = geodir_get_taxonomy_posttype();
421 421
 
422
-    // Retrive post type for map marker html ajax request on preview page.
423
-    if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
424
-        if (!empty($post->post_type)) {
425
-            $geodir_post_type = $post->post_type;
426
-        } else if (!empty($post->listing_type)) {
427
-            $geodir_post_type = $post->listing_type;
428
-        }
429
-    }
422
+	// Retrive post type for map marker html ajax request on preview page.
423
+	if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
424
+		if (!empty($post->post_type)) {
425
+			$geodir_post_type = $post->post_type;
426
+		} else if (!empty($post->listing_type)) {
427
+			$geodir_post_type = $post->listing_type;
428
+		}
429
+	}
430 430
 
431
-    $all_postypes = geodir_get_posttypes();
432
-    $all_postypes = stripslashes_deep($all_postypes);
431
+	$all_postypes = geodir_get_posttypes();
432
+	$all_postypes = stripslashes_deep($all_postypes);
433 433
 
434
-    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435
-        $geodir_post_type = '';
434
+	if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435
+		$geodir_post_type = '';
436 436
 
437
-    if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
438
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
439
-    }
437
+	if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
438
+		$geodir_post_type = sanitize_text_field($_REQUEST['stype']);
439
+	}
440 440
 
441 441
 
442
-    /**
443
-     * Filter the default CPT return.
444
-     *
445
-     * @since 1.6.9
446
-     */
447
-    return apply_filters('geodir_get_current_posttype',$geodir_post_type);
442
+	/**
443
+	 * Filter the default CPT return.
444
+	 *
445
+	 * @since 1.6.9
446
+	 */
447
+	return apply_filters('geodir_get_current_posttype',$geodir_post_type);
448 448
 }
449 449
 
450 450
 /**
@@ -458,22 +458,22 @@  discard block
 block discarded – undo
458 458
  */
459 459
 function geodir_get_default_posttype()
460 460
 {
461
-    $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) );
462
-
463
-    $stype = false;
464
-    foreach ( $post_types as $post_type => $info ) {
465
-        global $wpdb;
466
-        $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
467
-        if ( $has_posts ) {
468
-            $stype = $post_type; break;
469
-        }
470
-    }
471
-
472
-    if(!$stype){
473
-        $stype = 'gd_place';
474
-    }
475
-
476
-    return $stype;
461
+	$post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) );
462
+
463
+	$stype = false;
464
+	foreach ( $post_types as $post_type => $info ) {
465
+		global $wpdb;
466
+		$has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
467
+		if ( $has_posts ) {
468
+			$stype = $post_type; break;
469
+		}
470
+	}
471
+
472
+	if(!$stype){
473
+		$stype = 'gd_place';
474
+	}
475
+
476
+	return $stype;
477 477
 }
478 478
 
479 479
 /**
@@ -487,21 +487,21 @@  discard block
 block discarded – undo
487 487
  */
488 488
 function geodir_get_posttypes($output = 'names')
489 489
 {
490
-    $post_types = array();
491
-    $post_types = get_option('geodir_post_types');
492
-    $post_types = stripslashes_deep($post_types);
493
-    if (!empty($post_types)) {
494
-        switch ($output):
495
-            case 'object':
496
-            case 'Object':
497
-                $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types;
498
-                break;
499
-            case 'array':
500
-            case 'Array':
501
-                $post_types = (array)$post_types;
502
-                break;
490
+	$post_types = array();
491
+	$post_types = get_option('geodir_post_types');
492
+	$post_types = stripslashes_deep($post_types);
493
+	if (!empty($post_types)) {
494
+		switch ($output):
495
+			case 'object':
496
+			case 'Object':
497
+				$post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types;
498
+				break;
499
+			case 'array':
500
+			case 'Array':
501
+				$post_types = (array)$post_types;
502
+				break;
503 503
 			case 'options':
504
-                $post_types = (array)$post_types;
504
+				$post_types = (array)$post_types;
505 505
 				
506 506
 				$options = array();
507 507
 				if (!empty($post_types)) {
@@ -510,17 +510,17 @@  discard block
 block discarded – undo
510 510
 					}
511 511
 				}
512 512
 				$post_types = $options;
513
-                break;
514
-            default:
515
-                $post_types = array_keys($post_types);
516
-                break;
517
-        endswitch;
518
-    }
519
-
520
-    if (!empty($post_types))
521
-        return $post_types;
522
-    else
523
-        return array();
513
+				break;
514
+			default:
515
+				$post_types = array_keys($post_types);
516
+				break;
517
+		endswitch;
518
+	}
519
+
520
+	if (!empty($post_types))
521
+		return $post_types;
522
+	else
523
+		return array();
524 524
 }
525 525
 
526 526
 /**
@@ -533,104 +533,104 @@  discard block
 block discarded – undo
533 533
  */
534 534
 function geodir_get_posttype_info($post_type = '')
535 535
 {
536
-    $post_types = array();
537
-    $post_types = get_option('geodir_post_types');
538
-    $post_types = stripslashes_deep($post_types);
539
-    if (!empty($post_types) && $post_type != '') {
540
-        return $post_types[$post_type];
541
-    } else
542
-        return false;
536
+	$post_types = array();
537
+	$post_types = get_option('geodir_post_types');
538
+	$post_types = stripslashes_deep($post_types);
539
+	if (!empty($post_types) && $post_type != '') {
540
+		return $post_types[$post_type];
541
+	} else
542
+		return false;
543 543
 }
544 544
 
545 545
 if (!function_exists('geodir_get_taxonomies')) {
546
-    /**
547
-     * Get all custom taxonomies.
548
-     *
549
-     * @since 1.0.0
550
-     * @package GeoDirectory
551
-     * @param string $post_type The post type.
552
-     * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
553
-     * @return array|bool Taxonomies on success. false on failure.
554
-     */
555
-    function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) {
556
-        $taxonomies = array();
557
-        $gd_taxonomies = array();
558
-
559
-        if ($taxonomies = get_option('geodir_taxonomies')) {
560
-            $gd_taxonomies = array_keys($taxonomies);
561
-
562
-            if ($post_type != '') {
563
-                $gd_taxonomies = array();
564
-            }
546
+	/**
547
+	 * Get all custom taxonomies.
548
+	 *
549
+	 * @since 1.0.0
550
+	 * @package GeoDirectory
551
+	 * @param string $post_type The post type.
552
+	 * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
553
+	 * @return array|bool Taxonomies on success. false on failure.
554
+	 */
555
+	function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) {
556
+		$taxonomies = array();
557
+		$gd_taxonomies = array();
558
+
559
+		if ($taxonomies = get_option('geodir_taxonomies')) {
560
+			$gd_taxonomies = array_keys($taxonomies);
561
+
562
+			if ($post_type != '') {
563
+				$gd_taxonomies = array();
564
+			}
565 565
 
566
-            $i = 0;
567
-            foreach ($taxonomies as $taxonomy => $args) {
568
-                if ($post_type != '' && $args['object_type'] == $post_type) {
569
-                    $gd_taxonomies[] = $taxonomy;
570
-                }
566
+			$i = 0;
567
+			foreach ($taxonomies as $taxonomy => $args) {
568
+				if ($post_type != '' && $args['object_type'] == $post_type) {
569
+					$gd_taxonomies[] = $taxonomy;
570
+				}
571 571
 
572
-                if ($tages_taxonomies === false && substr($taxonomy , -5) == '_tags') {
573
-                    if (array_search($taxonomy, $gd_taxonomies) !== false) {
574
-                        unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
575
-                    }
576
-                }
577
-            }
572
+				if ($tages_taxonomies === false && substr($taxonomy , -5) == '_tags') {
573
+					if (array_search($taxonomy, $gd_taxonomies) !== false) {
574
+						unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
575
+					}
576
+				}
577
+			}
578 578
 
579
-            $gd_taxonomies = array_values($gd_taxonomies);
580
-        }
581
-
582
-        /**
583
-         * Filter the taxonomies.
584
-         *
585
-         * @since 1.0.0
586
-         * @param array $gd_taxonomies The taxonomy array.
587
-         */
588
-        $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
589
-
590
-        if (!empty($taxonomies)) {
591
-            return $taxonomies;
592
-        } else {
593
-            return false;
594
-        }
595
-    }
579
+			$gd_taxonomies = array_values($gd_taxonomies);
580
+		}
581
+
582
+		/**
583
+		 * Filter the taxonomies.
584
+		 *
585
+		 * @since 1.0.0
586
+		 * @param array $gd_taxonomies The taxonomy array.
587
+		 */
588
+		$taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
589
+
590
+		if (!empty($taxonomies)) {
591
+			return $taxonomies;
592
+		} else {
593
+			return false;
594
+		}
595
+	}
596 596
 }
597 597
 
598 598
 if (!function_exists(' geodir_get_categories_dl')) {
599
-    /**
600
-     * Get categories dropdown HTML.
601
-     *
602
-     * @since 1.0.0
603
-     * @package GeoDirectory
604
-     * @param string $post_type The post type.
605
-     * @param string $selected The selected value.
606
-     * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
607
-     * @param bool $echo Prints the HTML when set to true. Default: true.
608
-     * @return void|string Dropdown HTML.
609
-     */
610
-    function  geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true)
611
-    {
612
-
613
-        $html = '';
614
-        $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies);
615
-
616
-        $categories = get_terms($taxonomies);
617
-
618
-        $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
619
-
620
-        foreach ($categories as $category_obj) {
621
-            $select_opt = '';
622
-            if ($selected == $category_obj->term_id) {
623
-                $select_opt = 'selected="selected"';
624
-            }
625
-            $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">'
626
-                . geodir_utf8_ucfirst($category_obj->name) . '</option>';
627
-        }
628
-
629
-        if ($echo)
630
-            echo $html;
631
-        else
632
-            return $html;
633
-    }
599
+	/**
600
+	 * Get categories dropdown HTML.
601
+	 *
602
+	 * @since 1.0.0
603
+	 * @package GeoDirectory
604
+	 * @param string $post_type The post type.
605
+	 * @param string $selected The selected value.
606
+	 * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
607
+	 * @param bool $echo Prints the HTML when set to true. Default: true.
608
+	 * @return void|string Dropdown HTML.
609
+	 */
610
+	function  geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true)
611
+	{
612
+
613
+		$html = '';
614
+		$taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies);
615
+
616
+		$categories = get_terms($taxonomies);
617
+
618
+		$html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
619
+
620
+		foreach ($categories as $category_obj) {
621
+			$select_opt = '';
622
+			if ($selected == $category_obj->term_id) {
623
+				$select_opt = 'selected="selected"';
624
+			}
625
+			$html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">'
626
+				. geodir_utf8_ucfirst($category_obj->name) . '</option>';
627
+		}
628
+
629
+		if ($echo)
630
+			echo $html;
631
+		else
632
+			return $html;
633
+	}
634 634
 }
635 635
 
636 636
 
@@ -645,28 +645,28 @@  discard block
 block discarded – undo
645 645
 function geodir_get_listing_slug($object_type = '')
646 646
 {
647 647
 
648
-    $listing_slug = '';
648
+	$listing_slug = '';
649 649
 
650
-    $post_types = get_option('geodir_post_types');
651
-    $taxonomies = get_option('geodir_taxonomies');
650
+	$post_types = get_option('geodir_post_types');
651
+	$taxonomies = get_option('geodir_taxonomies');
652 652
 
653 653
 
654
-    if ($object_type != '') {
655
-        if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
654
+	if ($object_type != '') {
655
+		if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
656 656
 
657
-            $object_info = $post_types[$object_type];
658
-            $listing_slug = $object_info['listing_slug'];
659
-        } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
660
-            $object_info = $taxonomies[$object_type];
661
-            $listing_slug = $object_info['listing_slug'];
662
-        }
657
+			$object_info = $post_types[$object_type];
658
+			$listing_slug = $object_info['listing_slug'];
659
+		} elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
660
+			$object_info = $taxonomies[$object_type];
661
+			$listing_slug = $object_info['listing_slug'];
662
+		}
663 663
 
664
-    }
664
+	}
665 665
 
666
-    if (!empty($listing_slug))
667
-        return $listing_slug;
668
-    else
669
-        return false;
666
+	if (!empty($listing_slug))
667
+		return $listing_slug;
668
+	else
669
+		return false;
670 670
 }
671 671
 
672 672
 
@@ -681,212 +681,212 @@  discard block
 block discarded – undo
681 681
  */
682 682
 function geodir_get_taxonomy_posttype($taxonomy = '')
683 683
 {
684
-    global $wp_query;
685
-
686
-    $post_type = array();
687
-    $taxonomies = array();
688
-
689
-    if (!empty($taxonomy)) {
690
-        $taxonomies[] = $taxonomy;
691
-    } elseif (isset($wp_query->tax_query->queries)) {
692
-        $tax_arr = $wp_query->tax_query->queries;
693
-        //if tax query has 'relation' set then it will break wp_list_pluck so we remove it
694
-        if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
695
-        $taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
696
-    }
697
-
698
-    if (!empty($taxonomies)) {
699
-        foreach (geodir_get_posttypes() as $pt) {
700
-            $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
701
-            if (array_intersect($taxonomies, $object_taxonomies))
702
-                $post_type[] = $pt;
703
-        }
704
-    }
705
-
706
-    if (!empty($post_type))
707
-        return $post_type[0];
708
-    else
709
-        return false;
684
+	global $wp_query;
685
+
686
+	$post_type = array();
687
+	$taxonomies = array();
688
+
689
+	if (!empty($taxonomy)) {
690
+		$taxonomies[] = $taxonomy;
691
+	} elseif (isset($wp_query->tax_query->queries)) {
692
+		$tax_arr = $wp_query->tax_query->queries;
693
+		//if tax query has 'relation' set then it will break wp_list_pluck so we remove it
694
+		if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
695
+		$taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
696
+	}
697
+
698
+	if (!empty($taxonomies)) {
699
+		foreach (geodir_get_posttypes() as $pt) {
700
+			$object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
701
+			if (array_intersect($taxonomies, $object_taxonomies))
702
+				$post_type[] = $pt;
703
+		}
704
+	}
705
+
706
+	if (!empty($post_type))
707
+		return $post_type[0];
708
+	else
709
+		return false;
710 710
 }
711 711
 
712 712
 if (!function_exists('geodir_custom_taxonomy_walker')) {
713
-    /**
714
-     * Custom taxonomy walker function.
715
-     *
716
-     * @since 1.0.0
717
-     * @package GeoDirectory
718
-     * @param string $cat_taxonomy The taxonomy name.
719
-     * @param int $cat_parent The parent term ID.
720
-     * @param bool $hide_empty Hide empty taxonomies? Default: false.
721
-     * @param int $pading CSS padding in pixels.
722
-     * @return string|void taxonomy HTML.
723
-     */
724
-    function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0)
725
-    {
726
-        global $cat_display, $post_cat, $exclude_cats;
727
-
728
-        $search_terms = trim($post_cat, ",");
729
-
730
-        $search_terms = explode(",", $search_terms);
731
-
732
-        $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
733
-
734
-        $display = '';
735
-        $onchange = '';
736
-        $term_check = '';
737
-        $main_list_class = '';
738
-        $out = '';
739
-        //If there are terms, start displaying
740
-        if (count($cat_terms) > 0) {
741
-            //Displaying as a list
742
-            $p = $pading * 20;
743
-            $pading++;
744
-
745
-
746
-            if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
747
-                if ($cat_parent == 0) {
748
-                    $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display;
749
-                    $main_list_class = 'class="main_list_selecter"';
750
-                } else {
751
-                    //$display = 'display:none';
752
-                    $list_class = 'sub_list gd-sub-cats-list';
753
-                }
754
-            }
713
+	/**
714
+	 * Custom taxonomy walker function.
715
+	 *
716
+	 * @since 1.0.0
717
+	 * @package GeoDirectory
718
+	 * @param string $cat_taxonomy The taxonomy name.
719
+	 * @param int $cat_parent The parent term ID.
720
+	 * @param bool $hide_empty Hide empty taxonomies? Default: false.
721
+	 * @param int $pading CSS padding in pixels.
722
+	 * @return string|void taxonomy HTML.
723
+	 */
724
+	function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0)
725
+	{
726
+		global $cat_display, $post_cat, $exclude_cats;
727
+
728
+		$search_terms = trim($post_cat, ",");
729
+
730
+		$search_terms = explode(",", $search_terms);
731
+
732
+		$cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
733
+
734
+		$display = '';
735
+		$onchange = '';
736
+		$term_check = '';
737
+		$main_list_class = '';
738
+		$out = '';
739
+		//If there are terms, start displaying
740
+		if (count($cat_terms) > 0) {
741
+			//Displaying as a list
742
+			$p = $pading * 20;
743
+			$pading++;
744
+
745
+
746
+			if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
747
+				if ($cat_parent == 0) {
748
+					$list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display;
749
+					$main_list_class = 'class="main_list_selecter"';
750
+				} else {
751
+					//$display = 'display:none';
752
+					$list_class = 'sub_list gd-sub-cats-list';
753
+				}
754
+			}
755 755
 
756
-            if ($cat_display == 'checkbox' || $cat_display == 'radio') {
757
-                $p = 0;
758
-                $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">';
759
-            }
756
+			if ($cat_display == 'checkbox' || $cat_display == 'radio') {
757
+				$p = 0;
758
+				$out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">';
759
+			}
760 760
 
761
-            foreach ($cat_terms as $cat_term) {
761
+			foreach ($cat_terms as $cat_term) {
762 762
 
763
-                $checked = '';
763
+				$checked = '';
764 764
 
765
-                if (in_array($cat_term->term_id, $search_terms)) {
766
-                    if ($cat_display == 'select' || $cat_display == 'multiselect')
767
-                        $checked = 'selected="selected"';
768
-                    else
769
-                        $checked = 'checked="checked"';
770
-                }
765
+				if (in_array($cat_term->term_id, $search_terms)) {
766
+					if ($cat_display == 'select' || $cat_display == 'multiselect')
767
+						$checked = 'selected="selected"';
768
+					else
769
+						$checked = 'checked="checked"';
770
+				}
771 771
 
772
-                if ($cat_display == 'radio')
773
-                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
774
-                elseif ($cat_display == 'select' || $cat_display == 'multiselect')
775
-                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
772
+				if ($cat_display == 'radio')
773
+					$out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
774
+				elseif ($cat_display == 'select' || $cat_display == 'multiselect')
775
+					$out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
776 776
 
777
-                else {
778
-                    $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
779
-                }
777
+				else {
778
+					$out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
779
+				}
780 780
 
781
-                // Call recurson to print sub cats
782
-                $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading);
781
+				// Call recurson to print sub cats
782
+				$out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading);
783 783
 
784
-            }
784
+			}
785 785
 
786
-            if ($cat_display == 'checkbox' || $cat_display == 'radio')
787
-                $out .= '</div>';
786
+			if ($cat_display == 'checkbox' || $cat_display == 'radio')
787
+				$out .= '</div>';
788 788
 
789
-            return $out;
790
-        }
791
-        return;
792
-    }
789
+			return $out;
790
+		}
791
+		return;
792
+	}
793 793
 }
794 794
 
795 795
 if (!function_exists('geodir_custom_taxonomy_walker2')) {
796
-    /**
797
-     * Custom taxonomy walker function.
798
-     *
799
-     * @since 1.0.0
800
-     * @package GeoDirectory
801
-     * @global object $post WordPress Post object.
802
-     * @global object $gd_session GeoDirectory Session object.
803
-     * @param string $cat_taxonomy The taxonomy name.
804
-     * @param string $cat_limit Number of categories to display.
805
-     */
806
-    function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '')
807
-    {
808
-        $post_category = '';
809
-        $post_category_str = '';
810
-        global $exclude_cats, $gd_session;
811
-
812
-        $cat_exclude = '';
813
-        if (is_array($exclude_cats) && !empty($exclude_cats))
814
-            $cat_exclude = serialize($exclude_cats);
815
-
816
-        if (isset($_REQUEST['backandedit'])) {
817
-            $post = (object)$gd_session->get('listing');
818
-
819
-            if (!is_array($post->post_category[$cat_taxonomy]))
820
-                $post_category = $post->post_category[$cat_taxonomy];
821
-
822
-            $post_categories = $post->post_category_str;
823
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
824
-                $post_category_str = $post_categories[$cat_taxonomy];
825
-
826
-        } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
827
-            global $post;
828
-
829
-            $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true);
830
-            if (empty($post_category) && isset($post->{$cat_taxonomy})) {
831
-                $post_category = $post->{$cat_taxonomy};
832
-            }
796
+	/**
797
+	 * Custom taxonomy walker function.
798
+	 *
799
+	 * @since 1.0.0
800
+	 * @package GeoDirectory
801
+	 * @global object $post WordPress Post object.
802
+	 * @global object $gd_session GeoDirectory Session object.
803
+	 * @param string $cat_taxonomy The taxonomy name.
804
+	 * @param string $cat_limit Number of categories to display.
805
+	 */
806
+	function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '')
807
+	{
808
+		$post_category = '';
809
+		$post_category_str = '';
810
+		global $exclude_cats, $gd_session;
811
+
812
+		$cat_exclude = '';
813
+		if (is_array($exclude_cats) && !empty($exclude_cats))
814
+			$cat_exclude = serialize($exclude_cats);
815
+
816
+		if (isset($_REQUEST['backandedit'])) {
817
+			$post = (object)$gd_session->get('listing');
818
+
819
+			if (!is_array($post->post_category[$cat_taxonomy]))
820
+				$post_category = $post->post_category[$cat_taxonomy];
821
+
822
+			$post_categories = $post->post_category_str;
823
+			if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
824
+				$post_category_str = $post_categories[$cat_taxonomy];
825
+
826
+		} elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
827
+			global $post;
828
+
829
+			$post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true);
830
+			if (empty($post_category) && isset($post->{$cat_taxonomy})) {
831
+				$post_category = $post->{$cat_taxonomy};
832
+			}
833 833
 
834
-            $post_categories = get_post_meta($post->ID, 'post_categories', true);
834
+			$post_categories = get_post_meta($post->ID, 'post_categories', true);
835 835
 
836
-            if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
837
-                foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
838
-                    if (is_numeric($cat_part)) {
839
-                        $cat_part_arr[] = $cat_part;
840
-                    }
841
-                }
842
-                if (is_array($cat_part_arr)) {
843
-                    $post_category = implode(',', $cat_part_arr);
844
-                }
845
-            }
836
+			if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
837
+				foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
838
+					if (is_numeric($cat_part)) {
839
+						$cat_part_arr[] = $cat_part;
840
+					}
841
+				}
842
+				if (is_array($cat_part_arr)) {
843
+					$post_category = implode(',', $cat_part_arr);
844
+				}
845
+			}
846 846
 
847
-            if (!empty($post_category)) {
848
-                $cat1 = array_filter(explode(',', $post_category));
849
-                $post_category = ',' . implode(',', $cat1) . ',';
847
+			if (!empty($post_category)) {
848
+				$cat1 = array_filter(explode(',', $post_category));
849
+				$post_category = ',' . implode(',', $cat1) . ',';
850 850
 
851
-            }
851
+			}
852 852
 
853
-            if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
853
+			if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
854 854
 
855
-                $post_category_upd = explode(',', $post_category);
856
-                $post_category_change = '';
857
-                foreach ($post_category_upd as $cat) {
855
+				$post_category_upd = explode(',', $post_category);
856
+				$post_category_change = '';
857
+				foreach ($post_category_upd as $cat) {
858 858
 
859
-                    if (!in_array($cat, $exclude_cats) && $cat != '') {
860
-                        $post_category_change .= ',' . $cat;
861
-                    }
862
-                }
863
-                $post_category = $post_category_change;
864
-            }
859
+					if (!in_array($cat, $exclude_cats) && $cat != '') {
860
+						$post_category_change .= ',' . $cat;
861
+					}
862
+				}
863
+				$post_category = $post_category_change;
864
+			}
865 865
 
866 866
 
867
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
868
-                $post_category_str = $post_categories[$cat_taxonomy];
869
-            }
870
-        }
867
+			if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
868
+				$post_category_str = $post_categories[$cat_taxonomy];
869
+			}
870
+		}
871 871
 
872
-        echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']"  />';
872
+		echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']"  />';
873 873
 
874
-        echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']"  />';
874
+		echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']"  />';
875 875
 
876
-        echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']"  />';
876
+		echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']"  />';
877 877
 
878 878
 
879
-        ?>
879
+		?>
880 880
         <div class="cat_sublist">
881 881
             <?php
882 882
 
883
-            $post_id = isset($post->ID) ? $post->ID : '';
883
+			$post_id = isset($post->ID) ? $post->ID : '';
884 884
 
885
-            if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
885
+			if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
886 886
 
887
-                geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories);
888
-            }
889
-            ?>
887
+				geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories);
888
+			}
889
+			?>
890 890
         </div>
891 891
         <script type="text/javascript">
892 892
 
@@ -1009,22 +1009,22 @@  discard block
 block discarded – undo
1009 1009
 
1010 1010
         </script>
1011 1011
         <?php
1012
-        if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1013
-            $post_cat_str = $post_categories[$cat_taxonomy];
1014
-            $post_cat_array = explode("#", $post_cat_str);
1015
-            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1016
-                $style = "display:none;";
1017
-        }
1018
-        ?>
1012
+		if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1013
+			$post_cat_str = $post_categories[$cat_taxonomy];
1014
+			$post_cat_array = explode("#", $post_cat_str);
1015
+			if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1016
+				$style = "display:none;";
1017
+		}
1018
+		?>
1019 1019
         <div class="main_cat_list" style=" <?php if (isset($style)) {
1020
-            echo $style;
1021
-        }?> ">
1020
+			echo $style;
1021
+		}?> ">
1022 1022
             <?php geodir_get_catlist($cat_taxonomy, 0);  // print main categories list
1023
-            ?>
1023
+			?>
1024 1024
         </div>
1025 1025
     <?php
1026 1026
 
1027
-    }
1027
+	}
1028 1028
 }
1029 1029
 
1030 1030
 /**
@@ -1041,23 +1041,23 @@  discard block
 block discarded – undo
1041 1041
  */
1042 1042
 function geodir_addpost_categories_html($request_taxonomy, $parrent, $selected = false, $main_selected = true, $default = false, $exclude = '')
1043 1043
 {
1044
-    global $exclude_cats;
1044
+	global $exclude_cats;
1045 1045
 
1046
-    if ($exclude != '') {
1047
-        $exclude_cats = maybe_unserialize(base64_decode($exclude));
1046
+	if ($exclude != '') {
1047
+		$exclude_cats = maybe_unserialize(base64_decode($exclude));
1048 1048
 
1049
-        if(is_array( $exclude_cats)){
1050
-            $exclude_cats = array_map( 'intval', $exclude_cats );
1051
-        }else{
1052
-            $exclude_cats = intval($exclude_cats);
1053
-        }
1049
+		if(is_array( $exclude_cats)){
1050
+			$exclude_cats = array_map( 'intval', $exclude_cats );
1051
+		}else{
1052
+			$exclude_cats = intval($exclude_cats);
1053
+		}
1054 1054
 
1055
-    }
1055
+	}
1056 1056
 
1057
-    if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) ||
1058
-        (!is_array($exclude_cats) || empty($exclude_cats))
1059
-    ) {
1060
-        ?>
1057
+	if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) ||
1058
+		(!is_array($exclude_cats) || empty($exclude_cats))
1059
+	) {
1060
+		?>
1061 1061
 
1062 1062
         <?php $main_cat = get_term($parrent, $request_taxonomy); ?>
1063 1063
 
@@ -1086,8 +1086,8 @@  discard block
 block discarded – undo
1086 1086
 
1087 1087
             <br/>
1088 1088
             <?php
1089
-            $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
1090
-            if (!empty($cat_terms)) { ?>
1089
+			$cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
1090
+			if (!empty($cat_terms)) { ?>
1091 1091
                 <span> <?php printf(__('Add listing in category', 'geodirectory')); ?></span>
1092 1092
                 <?php geodir_get_catlist($request_taxonomy, $parrent, $selected) ?>
1093 1093
             <?php } ?>
@@ -1109,53 +1109,53 @@  discard block
 block discarded – undo
1109 1109
 function geodir_editpost_categories_html($request_taxonomy, $request_postid, $post_categories)
1110 1110
 {
1111 1111
 
1112
-    if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
1113
-        $post_cat_str = $post_categories[$request_taxonomy];
1114
-        $post_cat_array = explode("#", $post_cat_str);
1115
-        if (is_array($post_cat_array)) {
1116
-            $post_cat_array = array_unique( $post_cat_array );
1112
+	if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
1113
+		$post_cat_str = $post_categories[$request_taxonomy];
1114
+		$post_cat_array = explode("#", $post_cat_str);
1115
+		if (is_array($post_cat_array)) {
1116
+			$post_cat_array = array_unique( $post_cat_array );
1117 1117
 
1118 1118
 			foreach ($post_cat_array as $post_cat_html) {
1119 1119
 
1120
-                $post_cat_info = explode(":", $post_cat_html);
1121
-                $post_maincat_str = $post_cat_info[0];
1120
+				$post_cat_info = explode(":", $post_cat_html);
1121
+				$post_maincat_str = $post_cat_info[0];
1122 1122
 
1123
-                if (!empty($post_maincat_str)) {
1124
-                    $post_maincat_info = explode(",", $post_maincat_str);
1125
-                    $post_maincat_id = $post_maincat_info[0];
1126
-                    ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1127
-                    (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1128
-                }
1129
-                $post_sub_catid = '';
1130
-                if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1131
-                    $post_sub_catid = (int)$post_cat_info[1];
1132
-                }
1123
+				if (!empty($post_maincat_str)) {
1124
+					$post_maincat_info = explode(",", $post_maincat_str);
1125
+					$post_maincat_id = $post_maincat_info[0];
1126
+					($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1127
+					(end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1128
+				}
1129
+				$post_sub_catid = '';
1130
+				if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1131
+					$post_sub_catid = (int)$post_cat_info[1];
1132
+				}
1133 1133
 
1134
-                geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1134
+				geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1135 1135
 
1136
-            }
1137
-        } else {
1136
+			}
1137
+		} else {
1138 1138
 
1139
-            $post_cat_info = explode(":", $post_cat_str);
1140
-            $post_maincat_str = $post_cat_info[0];
1139
+			$post_cat_info = explode(":", $post_cat_str);
1140
+			$post_maincat_str = $post_cat_info[0];
1141 1141
 
1142
-            $post_sub_catid = '';
1142
+			$post_sub_catid = '';
1143 1143
 
1144
-            if (!empty($post_maincat_str)) {
1145
-                $post_maincat_info = explode(",", $post_maincat_str);
1146
-                $post_maincat_id = $post_maincat_info[0];
1147
-                ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1148
-                (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1149
-            }
1144
+			if (!empty($post_maincat_str)) {
1145
+				$post_maincat_info = explode(",", $post_maincat_str);
1146
+				$post_maincat_id = $post_maincat_info[0];
1147
+				($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1148
+				(end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1149
+			}
1150 1150
 
1151
-            if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1152
-                $post_sub_catid = (int)$post_cat_info[1];
1153
-            }
1151
+			if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1152
+				$post_sub_catid = (int)$post_cat_info[1];
1153
+			}
1154 1154
 
1155
-            geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1155
+			geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1156 1156
 
1157
-        }
1158
-    }
1157
+		}
1158
+	}
1159 1159
 }
1160 1160
 
1161 1161
 /**
@@ -1169,35 +1169,35 @@  discard block
 block discarded – undo
1169 1169
  */
1170 1170
 function geodir_get_catlist($cat_taxonomy, $parrent = 0, $selected = false)
1171 1171
 {
1172
-    global $exclude_cats;
1172
+	global $exclude_cats;
1173 1173
 
1174
-    $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
1174
+	$cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
1175 1175
 
1176
-    if (!empty($cat_terms)) {
1177
-        $onchange = '';
1178
-        $onchange = ' onchange="show_subcatlist(this.value, this)" ';
1176
+	if (!empty($cat_terms)) {
1177
+		$onchange = '';
1178
+		$onchange = ' onchange="show_subcatlist(this.value, this)" ';
1179 1179
 
1180
-        $option_selected = '';
1181
-        if (!$selected)
1182
-            $option_slected = ' selected="selected" ';
1180
+		$option_selected = '';
1181
+		if (!$selected)
1182
+			$option_slected = ' selected="selected" ';
1183 1183
 
1184
-        echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1184
+		echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1185 1185
 
1186
-        echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
1186
+		echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
1187 1187
 
1188
-        foreach ($cat_terms as $cat_term) {
1189
-            $option_selected = '';
1190
-            if ($selected == $cat_term->term_id)
1191
-                $option_selected = ' selected="selected" ';
1188
+		foreach ($cat_terms as $cat_term) {
1189
+			$option_selected = '';
1190
+			if ($selected == $cat_term->term_id)
1191
+				$option_selected = ' selected="selected" ';
1192 1192
 
1193
-            // Count child terms
1194
-            $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
1195
-            $has_child = !empty( $child_terms ) ? 't' : 'f';
1193
+			// Count child terms
1194
+			$child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
1195
+			$has_child = !empty( $child_terms ) ? 't' : 'f';
1196 1196
 
1197
-            echo '<option  ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>';
1198
-        }
1199
-        echo '</select>';
1200
-    }
1197
+			echo '<option  ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>';
1198
+		}
1199
+		echo '</select>';
1200
+	}
1201 1201
 }
1202 1202
 
1203 1203
 /**
@@ -1213,28 +1213,28 @@  discard block
 block discarded – undo
1213 1213
  */
1214 1214
 function geodir_custom_update_messages($messages)
1215 1215
 {
1216
-    global $post, $post_ID;
1217
-
1218
-    $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
1219
-
1220
-    foreach ($post_types as $post_type => $post_object) {
1221
-
1222
-        $messages[$post_type] = array(
1223
-            0 => '', // Unused. Messages start at index 1.
1224
-            1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1225
-            2 => __('Custom field updated.', 'geodirectory'),
1226
-            3 => __('Custom field deleted.', 'geodirectory'),
1227
-            4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
1228
-            5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
1229
-            6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1230
-            7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
1231
-            8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1232
-            9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1233
-            10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1234
-        );
1235
-    }
1236
-
1237
-    return $messages;
1216
+	global $post, $post_ID;
1217
+
1218
+	$post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
1219
+
1220
+	foreach ($post_types as $post_type => $post_object) {
1221
+
1222
+		$messages[$post_type] = array(
1223
+			0 => '', // Unused. Messages start at index 1.
1224
+			1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1225
+			2 => __('Custom field updated.', 'geodirectory'),
1226
+			3 => __('Custom field deleted.', 'geodirectory'),
1227
+			4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
1228
+			5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
1229
+			6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1230
+			7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
1231
+			8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1232
+			9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1233
+			10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1234
+		);
1235
+	}
1236
+
1237
+	return $messages;
1238 1238
 }
1239 1239
 
1240 1240
 
@@ -1249,182 +1249,182 @@  discard block
 block discarded – undo
1249 1249
 function geodir_register_defaults()
1250 1250
 {
1251 1251
 
1252
-    global $wpdb;
1253
-
1254
-    $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1255
-
1256
-    if (!$listing_slug = get_option('geodir_listing_prefix'))
1257
-        $listing_slug = 'places';
1258
-
1259
-    /**
1260
-     * Taxonomies
1261
-     **/
1262
-    //if ( ! taxonomy_exists('gd_place_tags') )
1263
-    {
1264
-
1265
-        $gd_placetags = array();
1266
-        $gd_placetags['object_type'] = 'gd_place';
1267
-        $gd_placetags['listing_slug'] = $listing_slug . '/tags';
1268
-        $gd_placetags['args'] = array(
1269
-            'public' => true,
1270
-            'hierarchical' => false,
1271
-            'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
1272
-            'query_var' => true,
1273
-
1274
-            'labels' => array(
1275
-                'name' => __('Place Tags', 'geodirectory'),
1276
-                'singular_name' => __('Place Tag', 'geodirectory'),
1277
-                'search_items' => __('Search Place Tags', 'geodirectory'),
1278
-                'popular_items' => __('Popular Place Tags', 'geodirectory'),
1279
-                'all_items' => __('All Place Tags', 'geodirectory'),
1280
-                'edit_item' => __('Edit Place Tag', 'geodirectory'),
1281
-                'update_item' => __('Update Place Tag', 'geodirectory'),
1282
-                'add_new_item' => __('Add New Place Tag', 'geodirectory'),
1283
-                'new_item_name' => __('New Place Tag Name', 'geodirectory'),
1284
-                'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
1285
-                'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
1286
-                'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
1287
-            ),
1288
-        );
1289
-
1290
-
1291
-        $geodir_taxonomies = get_option('geodir_taxonomies');
1292
-        $geodir_taxonomies['gd_place_tags'] = $gd_placetags;
1293
-        update_option('geodir_taxonomies', $geodir_taxonomies);
1294
-
1295
-
1296
-        // Update post types and delete tmp options
1297
-        flush_rewrite_rules();
1298
-
1299
-    }
1300
-
1301
-    //if ( ! taxonomy_exists('gd_placecategory') )
1302
-    {
1303
-
1304
-        $gd_placecategory = array();
1305
-        $gd_placecategory['object_type'] = 'gd_place';
1306
-        $gd_placecategory['listing_slug'] = $listing_slug;
1307
-        $gd_placecategory['args'] = array(
1308
-            'public' => true,
1309
-            'hierarchical' => true,
1310
-            'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
1311
-            'query_var' => true,
1312
-            'labels' => array(
1313
-                'name' => __('Place Categories', 'geodirectory'),
1314
-                'singular_name' => __('Place Category', 'geodirectory'),
1315
-                'search_items' => __('Search Place Categories', 'geodirectory'),
1316
-                'popular_items' => __('Popular Place Categories', 'geodirectory'),
1317
-                'all_items' => __('All Place Categories', 'geodirectory'),
1318
-                'edit_item' => __('Edit Place Category', 'geodirectory'),
1319
-                'update_item' => __('Update Place Category', 'geodirectory'),
1320
-                'add_new_item' => __('Add New Place Category', 'geodirectory'),
1321
-                'new_item_name' => __('New Place Category', 'geodirectory'),
1322
-                'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
1323
-            ),
1324
-        );
1325
-
1326
-
1327
-        $geodir_taxonomies = get_option('geodir_taxonomies');
1328
-        $geodir_taxonomies['gd_placecategory'] = $gd_placecategory;
1329
-        update_option('geodir_taxonomies', $geodir_taxonomies);
1330
-
1331
-
1332
-        flush_rewrite_rules();
1333
-    }
1334
-
1335
-    /**
1336
-     * Post Types
1337
-     **/
1338
-
1339
-    //if ( ! post_type_exists('gd_place') )
1340
-    {
1341
-
1342
-        $labels = array(
1343
-            'name' => __('Places', 'geodirectory'),
1344
-            'singular_name' => __('Place', 'geodirectory'),
1345
-            'add_new' => __('Add New', 'geodirectory'),
1346
-            'add_new_item' => __('Add New Place', 'geodirectory'),
1347
-            'edit_item' => __('Edit Place', 'geodirectory'),
1348
-            'new_item' => __('New Place', 'geodirectory'),
1349
-            'view_item' => __('View Place', 'geodirectory'),
1350
-            'search_items' => __('Search Places', 'geodirectory'),
1351
-            'not_found' => __('No Place Found', 'geodirectory'),
1352
-            'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
1353
-
1354
-        $place_default = array(
1355
-            'labels' => $labels,
1356
-            'can_export' => true,
1357
-            'capability_type' => 'post',
1358
-            'description' => 'Place post type.',
1359
-            'has_archive' => $listing_slug,
1360
-            'hierarchical' => false,
1361
-            'map_meta_cap' => true,
1362
-            'menu_icon' => $menu_icon,
1363
-            'public' => true,
1364
-            'query_var' => true,
1365
-            'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1366
-            'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
1367
-            'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
1368
-
1369
-        //Update custom post types
1370
-        $geodir_post_types = get_option('geodir_post_types');
1371
-        $geodir_post_types['gd_place'] = $place_default;
1372
-        update_option('geodir_post_types', $geodir_post_types);
1373
-
1374
-        // Update post types and delete tmp options
1375
-        flush_rewrite_rules();
1376
-    }
1377
-
1378
-
1379
-    geodir_register_taxonomies();
1380
-    geodir_register_post_types();
1381
-
1382
-    //die;
1252
+	global $wpdb;
1253
+
1254
+	$menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1255
+
1256
+	if (!$listing_slug = get_option('geodir_listing_prefix'))
1257
+		$listing_slug = 'places';
1258
+
1259
+	/**
1260
+	 * Taxonomies
1261
+	 **/
1262
+	//if ( ! taxonomy_exists('gd_place_tags') )
1263
+	{
1264
+
1265
+		$gd_placetags = array();
1266
+		$gd_placetags['object_type'] = 'gd_place';
1267
+		$gd_placetags['listing_slug'] = $listing_slug . '/tags';
1268
+		$gd_placetags['args'] = array(
1269
+			'public' => true,
1270
+			'hierarchical' => false,
1271
+			'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
1272
+			'query_var' => true,
1273
+
1274
+			'labels' => array(
1275
+				'name' => __('Place Tags', 'geodirectory'),
1276
+				'singular_name' => __('Place Tag', 'geodirectory'),
1277
+				'search_items' => __('Search Place Tags', 'geodirectory'),
1278
+				'popular_items' => __('Popular Place Tags', 'geodirectory'),
1279
+				'all_items' => __('All Place Tags', 'geodirectory'),
1280
+				'edit_item' => __('Edit Place Tag', 'geodirectory'),
1281
+				'update_item' => __('Update Place Tag', 'geodirectory'),
1282
+				'add_new_item' => __('Add New Place Tag', 'geodirectory'),
1283
+				'new_item_name' => __('New Place Tag Name', 'geodirectory'),
1284
+				'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
1285
+				'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
1286
+				'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
1287
+			),
1288
+		);
1289
+
1290
+
1291
+		$geodir_taxonomies = get_option('geodir_taxonomies');
1292
+		$geodir_taxonomies['gd_place_tags'] = $gd_placetags;
1293
+		update_option('geodir_taxonomies', $geodir_taxonomies);
1294
+
1295
+
1296
+		// Update post types and delete tmp options
1297
+		flush_rewrite_rules();
1298
+
1299
+	}
1300
+
1301
+	//if ( ! taxonomy_exists('gd_placecategory') )
1302
+	{
1303
+
1304
+		$gd_placecategory = array();
1305
+		$gd_placecategory['object_type'] = 'gd_place';
1306
+		$gd_placecategory['listing_slug'] = $listing_slug;
1307
+		$gd_placecategory['args'] = array(
1308
+			'public' => true,
1309
+			'hierarchical' => true,
1310
+			'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
1311
+			'query_var' => true,
1312
+			'labels' => array(
1313
+				'name' => __('Place Categories', 'geodirectory'),
1314
+				'singular_name' => __('Place Category', 'geodirectory'),
1315
+				'search_items' => __('Search Place Categories', 'geodirectory'),
1316
+				'popular_items' => __('Popular Place Categories', 'geodirectory'),
1317
+				'all_items' => __('All Place Categories', 'geodirectory'),
1318
+				'edit_item' => __('Edit Place Category', 'geodirectory'),
1319
+				'update_item' => __('Update Place Category', 'geodirectory'),
1320
+				'add_new_item' => __('Add New Place Category', 'geodirectory'),
1321
+				'new_item_name' => __('New Place Category', 'geodirectory'),
1322
+				'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
1323
+			),
1324
+		);
1325
+
1326
+
1327
+		$geodir_taxonomies = get_option('geodir_taxonomies');
1328
+		$geodir_taxonomies['gd_placecategory'] = $gd_placecategory;
1329
+		update_option('geodir_taxonomies', $geodir_taxonomies);
1330
+
1331
+
1332
+		flush_rewrite_rules();
1333
+	}
1334
+
1335
+	/**
1336
+	 * Post Types
1337
+	 **/
1338
+
1339
+	//if ( ! post_type_exists('gd_place') )
1340
+	{
1341
+
1342
+		$labels = array(
1343
+			'name' => __('Places', 'geodirectory'),
1344
+			'singular_name' => __('Place', 'geodirectory'),
1345
+			'add_new' => __('Add New', 'geodirectory'),
1346
+			'add_new_item' => __('Add New Place', 'geodirectory'),
1347
+			'edit_item' => __('Edit Place', 'geodirectory'),
1348
+			'new_item' => __('New Place', 'geodirectory'),
1349
+			'view_item' => __('View Place', 'geodirectory'),
1350
+			'search_items' => __('Search Places', 'geodirectory'),
1351
+			'not_found' => __('No Place Found', 'geodirectory'),
1352
+			'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
1353
+
1354
+		$place_default = array(
1355
+			'labels' => $labels,
1356
+			'can_export' => true,
1357
+			'capability_type' => 'post',
1358
+			'description' => 'Place post type.',
1359
+			'has_archive' => $listing_slug,
1360
+			'hierarchical' => false,
1361
+			'map_meta_cap' => true,
1362
+			'menu_icon' => $menu_icon,
1363
+			'public' => true,
1364
+			'query_var' => true,
1365
+			'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1366
+			'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
1367
+			'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
1368
+
1369
+		//Update custom post types
1370
+		$geodir_post_types = get_option('geodir_post_types');
1371
+		$geodir_post_types['gd_place'] = $place_default;
1372
+		update_option('geodir_post_types', $geodir_post_types);
1373
+
1374
+		// Update post types and delete tmp options
1375
+		flush_rewrite_rules();
1376
+	}
1377
+
1378
+
1379
+	geodir_register_taxonomies();
1380
+	geodir_register_post_types();
1381
+
1382
+	//die;
1383 1383
 
1384 1384
 }
1385 1385
 
1386 1386
 $gd_wpml_get_languages = "";
1387 1387
 function gd_wpml_get_lang_from_url($url) {
1388
-    global $sitepress, $gd_wpml_get_languages;
1388
+	global $sitepress, $gd_wpml_get_languages;
1389 1389
     
1390
-    if (geodir_is_wpml()) {
1391
-        return $sitepress->get_language_from_url($url);
1392
-    }
1390
+	if (geodir_is_wpml()) {
1391
+		return $sitepress->get_language_from_url($url);
1392
+	}
1393 1393
     
1394
-    if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
1395
-        return $_REQUEST['lang'];
1396
-    }
1394
+	if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
1395
+		return $_REQUEST['lang'];
1396
+	}
1397 1397
 
1398
-    $url = str_replace(array("http://","https://"),"",$url);
1398
+	$url = str_replace(array("http://","https://"),"",$url);
1399 1399
 
1400
-    // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
1401
-    $site_url = str_replace(array("http://","https://"),"",site_url());
1400
+	// site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
1401
+	$site_url = str_replace(array("http://","https://"),"",site_url());
1402 1402
 
1403
-    $url = str_replace($site_url,"",$url);
1403
+	$url = str_replace($site_url,"",$url);
1404 1404
 
1405
-    $segments = explode('/', trim($url, '/'));
1405
+	$segments = explode('/', trim($url, '/'));
1406 1406
 
1407
-    if ($gd_wpml_get_languages) {
1408
-        $langs = $gd_wpml_get_languages;
1409
-    } else {
1410
-        $gd_wpml_get_languages = $sitepress->get_active_languages();
1411
-    }
1407
+	if ($gd_wpml_get_languages) {
1408
+		$langs = $gd_wpml_get_languages;
1409
+	} else {
1410
+		$gd_wpml_get_languages = $sitepress->get_active_languages();
1411
+	}
1412 1412
 
1413
-    if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
1414
-        return $segments[0];
1415
-    }
1413
+	if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
1414
+		return $segments[0];
1415
+	}
1416 1416
 
1417
-    return false;
1417
+	return false;
1418 1418
 }
1419 1419
 
1420 1420
 function gd_wpml_slug_translation_turned_on($post_type) {
1421 1421
 
1422
-    global $sitepress;
1423
-    $settings = $sitepress->get_settings();
1424
-    return isset($settings['posts_slug_translation']['types'][$post_type])
1425
-    && $settings['posts_slug_translation']['types'][$post_type]
1426
-    && isset($settings['posts_slug_translation']['on'])
1427
-    && $settings['posts_slug_translation']['on'];
1422
+	global $sitepress;
1423
+	$settings = $sitepress->get_settings();
1424
+	return isset($settings['posts_slug_translation']['types'][$post_type])
1425
+	&& $settings['posts_slug_translation']['types'][$post_type]
1426
+	&& isset($settings['posts_slug_translation']['on'])
1427
+	&& $settings['posts_slug_translation']['on'];
1428 1428
 }
1429 1429
 
1430 1430
 
@@ -1451,158 +1451,158 @@  discard block
 block discarded – undo
1451 1451
  */
1452 1452
 function geodir_listing_permalink_structure($post_link, $post_obj, $leavename, $sample)
1453 1453
 {
1454
-    //echo $post_link."<br />".$sample ;
1454
+	//echo $post_link."<br />".$sample ;
1455 1455
 
1456 1456
 
1457
-    global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache;
1458
-    if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
1459
-    } elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
1460
-        return $post_link;
1461
-    } else {
1462
-        $orig_post = $post;
1463
-        $post = $post_obj;
1464
-    }
1457
+	global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache;
1458
+	if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
1459
+	} elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
1460
+		return $post_link;
1461
+	} else {
1462
+		$orig_post = $post;
1463
+		$post = $post_obj;
1464
+	}
1465 1465
 
1466
-    if (in_array($post->post_type, geodir_get_posttypes())) {
1466
+	if (in_array($post->post_type, geodir_get_posttypes())) {
1467 1467
 
1468
-        // if we dont have a GD post then try to grab it
1469
-        if(!isset($post->default_category)){
1470
-            $gd_post = geodir_get_post_info($post->ID);
1471
-            if(!empty($gd_post)){
1472
-                $post = $gd_post;
1473
-            }
1474
-        }
1468
+		// if we dont have a GD post then try to grab it
1469
+		if(!isset($post->default_category)){
1470
+			$gd_post = geodir_get_post_info($post->ID);
1471
+			if(!empty($gd_post)){
1472
+				$post = $gd_post;
1473
+			}
1474
+		}
1475 1475
 
1476 1476
 
1477
-        $post_types = get_option('geodir_post_types');
1478
-        $slug = $post_types[$post->post_type]['rewrite']['slug'];
1477
+		$post_types = get_option('geodir_post_types');
1478
+		$slug = $post_types[$post->post_type]['rewrite']['slug'];
1479 1479
 
1480
-        // Alter the CPT slug if WPML is set to do so
1481
-        if(geodir_wpml_is_post_type_translated($post->post_type)){
1482
-            if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1480
+		// Alter the CPT slug if WPML is set to do so
1481
+		if(geodir_wpml_is_post_type_translated($post->post_type)){
1482
+			if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1483 1483
 
1484
-                $org_slug = $slug;
1485
-                $slug = apply_filters( 'wpml_translate_single_string',
1486
-                    $slug,
1487
-                    'WordPress',
1488
-                    'URL slug: ' . $slug,
1489
-                    $language_code);
1484
+				$org_slug = $slug;
1485
+				$slug = apply_filters( 'wpml_translate_single_string',
1486
+					$slug,
1487
+					'WordPress',
1488
+					'URL slug: ' . $slug,
1489
+					$language_code);
1490 1490
 
1491
-                if(!$slug){$slug = $org_slug;}
1491
+				if(!$slug){$slug = $org_slug;}
1492 1492
 
1493
-            }
1494
-        }
1493
+			}
1494
+		}
1495 1495
 
1496
-        if (function_exists('geodir_location_geo_home_link')) {
1497
-            remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1498
-        }
1496
+		if (function_exists('geodir_location_geo_home_link')) {
1497
+			remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1498
+		}
1499 1499
         
1500
-        // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz.
1501
-        $site_url = trailingslashit(get_bloginfo('url'));
1500
+		// Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz.
1501
+		$site_url = trailingslashit(get_bloginfo('url'));
1502 1502
         
1503
-        if (function_exists('geodir_location_geo_home_link')) {
1504
-            add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1505
-        }
1506
-
1507
-        $fix_url = strpos($post_link, $site_url) === 0 ? true : false;
1508
-        if ($fix_url) {
1509
-            $post_link = str_replace($site_url, '', $post_link);
1510
-        }
1511
-
1512
-        $post_link = trailingslashit(
1513
-            preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1514
-        );
1515
-
1516
-        if ($fix_url) {
1517
-            $post_link = $site_url . $post_link;
1518
-        }
1519
-
1520
-        if (isset($comment_post_cache[$post->ID])) {
1521
-            $post = $comment_post_cache[$post->ID];
1522
-        }
1523
-        if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
1524
-            $post_id = $post->ID;
1525
-            if (isset($orig_post)) {
1526
-                $post = $orig_post;
1527
-            }
1528
-            return $gd_permalink_cache[$post_id];
1529
-        }
1503
+		if (function_exists('geodir_location_geo_home_link')) {
1504
+			add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1505
+		}
1530 1506
 
1531
-        if (!isset($post->post_locations)) {
1532
-            $post_type = $post->post_type;
1533
-            $ID = $post->ID;
1534
-            $post2 = $wpdb->get_row(
1535
-                $wpdb->prepare(
1536
-                    "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1537
-                    array($post->ID)
1538
-                )
1539
-            );
1507
+		$fix_url = strpos($post_link, $site_url) === 0 ? true : false;
1508
+		if ($fix_url) {
1509
+			$post_link = str_replace($site_url, '', $post_link);
1510
+		}
1540 1511
 
1541
-            $post = (object)array_merge((array)$post, (array)$post2);
1512
+		$post_link = trailingslashit(
1513
+			preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1514
+		);
1542 1515
 
1543
-            $comment_post_cache[$post->ID] = $post;
1544
-        }
1516
+		if ($fix_url) {
1517
+			$post_link = $site_url . $post_link;
1518
+		}
1545 1519
 
1520
+		if (isset($comment_post_cache[$post->ID])) {
1521
+			$post = $comment_post_cache[$post->ID];
1522
+		}
1523
+		if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
1524
+			$post_id = $post->ID;
1525
+			if (isset($orig_post)) {
1526
+				$post = $orig_post;
1527
+			}
1528
+			return $gd_permalink_cache[$post_id];
1529
+		}
1546 1530
 
1531
+		if (!isset($post->post_locations)) {
1532
+			$post_type = $post->post_type;
1533
+			$ID = $post->ID;
1534
+			$post2 = $wpdb->get_row(
1535
+				$wpdb->prepare(
1536
+					"SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1537
+					array($post->ID)
1538
+				)
1539
+			);
1547 1540
 
1548
-        if (false !== strpos($post_link, '%gd_taxonomy%')) {
1541
+			$post = (object)array_merge((array)$post, (array)$post2);
1549 1542
 
1550
-            if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1551
-                $location_request = '';
1543
+			$comment_post_cache[$post->ID] = $post;
1544
+		}
1552 1545
 
1553 1546
 
1554
-                if (!empty($post->post_locations)) {
1555
-                    $geodir_arr_locations = explode(',', $post->post_locations);
1556
-                    if (count($geodir_arr_locations) == 3) {
1557
-                        $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1558
-                        $post->city_slug = str_replace(']', '', $post->city_slug);
1559
-                        $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1560
-                        $post->region_slug = str_replace(']', '', $post->region_slug);
1561
-                        $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1562
-                        $post->country_slug = str_replace(']', '', $post->country_slug);
1563 1547
 
1564
-                        $post_location = (object)array('country_slug' => $post->country_slug,
1565
-                            'region_slug' => $post->region_slug,
1566
-                            'city_slug' => $post->city_slug
1567
-                        );
1548
+		if (false !== strpos($post_link, '%gd_taxonomy%')) {
1568 1549
 
1569
-                    } else
1570
-                        $post_location = geodir_get_location();
1550
+			if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1551
+				$location_request = '';
1571 1552
 
1572 1553
 
1573
-                } else {
1554
+				if (!empty($post->post_locations)) {
1555
+					$geodir_arr_locations = explode(',', $post->post_locations);
1556
+					if (count($geodir_arr_locations) == 3) {
1557
+						$post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1558
+						$post->city_slug = str_replace(']', '', $post->city_slug);
1559
+						$post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1560
+						$post->region_slug = str_replace(']', '', $post->region_slug);
1561
+						$post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1562
+						$post->country_slug = str_replace(']', '', $post->country_slug);
1574 1563
 
1575
-                    $post_location_sql = $wpdb->get_results(
1576
-                        $wpdb->prepare(
1577
-                            "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1578
-                            array($post->ID)
1579
-                        )
1580
-                    );
1581
-
1582
-                    if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
1583
-
1584
-                        $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
1585
-                        if (count($geodir_arr_locations) == 3) {
1586
-                            $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1587
-                            $post->city_slug = str_replace(']', '', $post->city_slug);
1588
-                            $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1589
-                            $post->region_slug = str_replace(']', '', $post->region_slug);
1590
-                            $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1591
-                            $post->country_slug = str_replace(']', '', $post->country_slug);
1592
-
1593
-                            $post_location = (object)array('country_slug' => $post->country_slug,
1594
-                                'region_slug' => $post->region_slug,
1595
-                                'city_slug' => $post->city_slug
1596
-                            );
1564
+						$post_location = (object)array('country_slug' => $post->country_slug,
1565
+							'region_slug' => $post->region_slug,
1566
+							'city_slug' => $post->city_slug
1567
+						);
1597 1568
 
1598
-                        }
1599
-                    } else
1600
-                        $post_location = geodir_get_location();
1601
-                }
1569
+					} else
1570
+						$post_location = geodir_get_location();
1571
+
1572
+
1573
+				} else {
1574
+
1575
+					$post_location_sql = $wpdb->get_results(
1576
+						$wpdb->prepare(
1577
+							"SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1578
+							array($post->ID)
1579
+						)
1580
+					);
1581
+
1582
+					if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
1583
+
1584
+						$geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
1585
+						if (count($geodir_arr_locations) == 3) {
1586
+							$post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1587
+							$post->city_slug = str_replace(']', '', $post->city_slug);
1588
+							$post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1589
+							$post->region_slug = str_replace(']', '', $post->region_slug);
1590
+							$post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1591
+							$post->country_slug = str_replace(']', '', $post->country_slug);
1592
+
1593
+							$post_location = (object)array('country_slug' => $post->country_slug,
1594
+								'region_slug' => $post->region_slug,
1595
+								'city_slug' => $post->city_slug
1596
+							);
1597
+
1598
+						}
1599
+					} else
1600
+						$post_location = geodir_get_location();
1601
+				}
1602 1602
 
1603 1603
 
1604
-                if (!empty($post_location)) {
1605
-                    $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : '';
1604
+				if (!empty($post_location)) {
1605
+					$country_slug = isset($post_location->country_slug) ? $post_location->country_slug : '';
1606 1606
 					$region_slug = isset($post_location->region_slug) ? $post_location->region_slug : '';
1607 1607
 					$city_slug = isset($post_location->city_slug) ? $post_location->city_slug : '';
1608 1608
 					
@@ -1620,88 +1620,88 @@  discard block
 block discarded – undo
1620 1620
 					$location_slug[] = $city_slug;
1621 1621
 					
1622 1622
 					$location_request .= implode('/', $location_slug) . '/';
1623
-                }
1624
-            }
1623
+				}
1624
+			}
1625 1625
 
1626
-            if (get_option('geodir_add_categories_url')) {
1626
+			if (get_option('geodir_add_categories_url')) {
1627 1627
 
1628
-                $term_request = '';
1629
-                $taxonomies = geodir_get_taxonomies($post->post_type);
1630
-                $taxonomies = !empty($taxonomies) && is_array($taxonomies) ? end($taxonomies) : '';
1628
+				$term_request = '';
1629
+				$taxonomies = geodir_get_taxonomies($post->post_type);
1630
+				$taxonomies = !empty($taxonomies) && is_array($taxonomies) ? end($taxonomies) : '';
1631 1631
 
1632
-                if (!empty($post->default_category)) {
1633
-                    $post_terms = $post->default_category;
1634
-                } else {
1635
-                    $post_terms = '';
1636
-
1637
-                    if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1638
-                        $post_terms = absint($_POST['post_default_category']);
1639
-                    }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1640
-                        $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
1641
-                        $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0;
1642
-                    }elseif (isset($post->{$taxonomies})) {
1643
-                        $post_terms = explode(",", trim($post->{$taxonomies}, ","));
1644
-                        $post_terms = $post_terms[0];
1645
-                    }
1632
+				if (!empty($post->default_category)) {
1633
+					$post_terms = $post->default_category;
1634
+				} else {
1635
+					$post_terms = '';
1636
+
1637
+					if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1638
+						$post_terms = absint($_POST['post_default_category']);
1639
+					}elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1640
+						$post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
1641
+						$post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0;
1642
+					}elseif (isset($post->{$taxonomies})) {
1643
+						$post_terms = explode(",", trim($post->{$taxonomies}, ","));
1644
+						$post_terms = $post_terms[0];
1645
+					}
1646 1646
 
1647
-                    if (!$post_terms)
1648
-                        $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1647
+					if (!$post_terms)
1648
+						$post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1649 1649
 
1650
-                    if (!$post_terms) {
1651
-                        $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
1650
+					if (!$post_terms) {
1651
+						$post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
1652 1652
 
1653
-                        if ($post_terms) {
1654
-                            $post_terms = explode(",", trim($post_terms, ","));
1655
-                            $post_terms = $post_terms[0];
1656
-                        }
1657
-                    }
1658
-                }
1653
+						if ($post_terms) {
1654
+							$post_terms = explode(",", trim($post_terms, ","));
1655
+							$post_terms = $post_terms[0];
1656
+						}
1657
+					}
1658
+				}
1659 1659
 
1660
-                $term = get_term_by('id', $post_terms, $taxonomies);
1660
+				$term = get_term_by('id', $post_terms, $taxonomies);
1661 1661
 
1662
-                if (!empty($term))
1663
-                    $term_request = $term->slug;
1664
-                //$term_request = $term->slug.'/';
1665
-            }
1662
+				if (!empty($term))
1663
+					$term_request = $term->slug;
1664
+				//$term_request = $term->slug.'/';
1665
+			}
1666 1666
 
1667
-            $request_term = '';
1668
-            $listingurl_separator = '';
1669
-            //$detailurl_separator = get_option('geodir_detailurl_separator');
1670
-            $detailurl_separator = '';
1671
-            if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
1672
-                $request_term = $location_request;
1673
-                //$listingurl_separator = get_option('geodir_listingurl_separator');
1674
-                //$request_term .= $listingurl_separator.'/'.$term_request;
1675
-                $request_term .= $term_request;
1667
+			$request_term = '';
1668
+			$listingurl_separator = '';
1669
+			//$detailurl_separator = get_option('geodir_detailurl_separator');
1670
+			$detailurl_separator = '';
1671
+			if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
1672
+				$request_term = $location_request;
1673
+				//$listingurl_separator = get_option('geodir_listingurl_separator');
1674
+				//$request_term .= $listingurl_separator.'/'.$term_request;
1675
+				$request_term .= $term_request;
1676 1676
 
1677
-            } else {
1678
-                if (isset($location_request) && $location_request != '') $request_term = $location_request;
1677
+			} else {
1678
+				if (isset($location_request) && $location_request != '') $request_term = $location_request;
1679 1679
 
1680
-                if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1681
-            }
1682
-            $request_term = trim($request_term, '/');
1680
+				if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1681
+			}
1682
+			$request_term = trim($request_term, '/');
1683 1683
             
1684
-            // Fix with WPML the location terms added twice when CPT slug is translated.
1685
-            if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1686
-                $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1687
-            }
1684
+			// Fix with WPML the location terms added twice when CPT slug is translated.
1685
+			if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1686
+				$post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1687
+			}
1688 1688
             
1689
-            if (!empty($request_term))
1690
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1691
-            else
1692
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1693
-            //echo $post_link ;
1694
-        }
1695
-        // temp cache the permalink
1696
-        if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
1697
-            $gd_permalink_cache[$post->ID] = $post_link;
1698
-        }
1699
-    }
1700
-    if (isset($orig_post)) {
1701
-        $post = $orig_post;
1702
-    }
1703
-
1704
-    return $post_link;
1689
+			if (!empty($request_term))
1690
+				$post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1691
+			else
1692
+				$post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1693
+			//echo $post_link ;
1694
+		}
1695
+		// temp cache the permalink
1696
+		if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
1697
+			$gd_permalink_cache[$post->ID] = $post_link;
1698
+		}
1699
+	}
1700
+	if (isset($orig_post)) {
1701
+		$post = $orig_post;
1702
+	}
1703
+
1704
+	return $post_link;
1705 1705
 }
1706 1706
 
1707 1707
 /**
@@ -1717,117 +1717,117 @@  discard block
 block discarded – undo
1717 1717
  * @return string The term link.
1718 1718
  */
1719 1719
 function geodir_term_link($termlink, $term, $taxonomy) {
1720
-    $geodir_taxonomies = geodir_get_taxonomies('', true);
1720
+	$geodir_taxonomies = geodir_get_taxonomies('', true);
1721 1721
 
1722
-    if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
1723
-        global $geodir_add_location_url, $gd_session;
1724
-        $include_location = false;
1725
-        $request_term = array();
1726
-        $add_location_url = get_option('geodir_add_location_url');
1727
-        $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
1722
+	if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
1723
+		global $geodir_add_location_url, $gd_session;
1724
+		$include_location = false;
1725
+		$request_term = array();
1726
+		$add_location_url = get_option('geodir_add_location_url');
1727
+		$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
1728 1728
 
1729
-        $listing_slug = geodir_get_listing_slug($taxonomy);
1729
+		$listing_slug = geodir_get_listing_slug($taxonomy);
1730 1730
 
1731
-        if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
1732
-            if ($geodir_add_location_url && $add_location_url) {
1733
-                $include_location = true;
1734
-            }
1735
-        } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
1736
-            $include_location = true;
1737
-        } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
1738
-            $include_location = true;
1739
-        }
1740
-
1741
-        if ($include_location) {
1742
-            global $post;
1743
-            $location_terms = array();
1731
+		if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
1732
+			if ($geodir_add_location_url && $add_location_url) {
1733
+				$include_location = true;
1734
+			}
1735
+		} elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
1736
+			$include_location = true;
1737
+		} elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
1738
+			$include_location = true;
1739
+		}
1740
+
1741
+		if ($include_location) {
1742
+			global $post;
1743
+			$location_terms = array();
1744 1744
             
1745
-            $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
1745
+			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
1746 1746
             
1747
-            if (geodir_is_page('detail')) {
1748
-                if (!isset($post->country_slug) && !empty($post->post_locations)) {
1749
-                    $post_locations = explode(',', $post->post_locations);
1750
-
1751
-                    if (count($post_locations) == 3) {
1752
-                        $post->city_slug = str_replace('[', '', $post_locations[0]);
1753
-                        $post->city_slug = str_replace(']', '', $post->city_slug);
1754
-                        $post->region_slug = str_replace('[', '', $post_locations[1]);
1755
-                        $post->region_slug = str_replace(']', '', $post->region_slug);
1756
-                        $post->country_slug = str_replace('[', '', $post_locations[2]);
1757
-                        $post->country_slug = str_replace(']', '', $post->country_slug);
1758
-                    }
1759
-                }
1747
+			if (geodir_is_page('detail')) {
1748
+				if (!isset($post->country_slug) && !empty($post->post_locations)) {
1749
+					$post_locations = explode(',', $post->post_locations);
1750
+
1751
+					if (count($post_locations) == 3) {
1752
+						$post->city_slug = str_replace('[', '', $post_locations[0]);
1753
+						$post->city_slug = str_replace(']', '', $post->city_slug);
1754
+						$post->region_slug = str_replace('[', '', $post_locations[1]);
1755
+						$post->region_slug = str_replace(']', '', $post->region_slug);
1756
+						$post->country_slug = str_replace('[', '', $post_locations[2]);
1757
+						$post->country_slug = str_replace(']', '', $post->country_slug);
1758
+					}
1759
+				}
1760 1760
 
1761
-                if (isset($post->country_slug)) {
1762
-                    $location_terms = array(
1763
-                        'gd_country' => $post->country_slug,
1764
-                        'gd_region' => $post->region_slug,
1765
-                        'gd_city' => $post->city_slug
1766
-                    );
1761
+				if (isset($post->country_slug)) {
1762
+					$location_terms = array(
1763
+						'gd_country' => $post->country_slug,
1764
+						'gd_region' => $post->region_slug,
1765
+						'gd_city' => $post->city_slug
1766
+					);
1767 1767
 
1768
-                    if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
1769
-                        $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
1770
-                    }
1771
-                }
1772
-            }
1768
+					if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
1769
+						$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
1770
+					}
1771
+				}
1772
+			}
1773 1773
             
1774
-            if (empty($location_terms)) {
1775
-                $location_terms = geodir_get_current_location_terms('query_vars');
1776
-            }
1774
+			if (empty($location_terms)) {
1775
+				$location_terms = geodir_get_current_location_terms('query_vars');
1776
+			}
1777 1777
 
1778
-            $geodir_show_location_url = get_option('geodir_show_location_url');
1779
-            $location_terms = geodir_remove_location_terms($location_terms);
1778
+			$geodir_show_location_url = get_option('geodir_show_location_url');
1779
+			$location_terms = geodir_remove_location_terms($location_terms);
1780 1780
 
1781
-            if (!empty($location_terms)) {
1782
-                $url_separator = '';
1781
+			if (!empty($location_terms)) {
1782
+				$url_separator = '';
1783 1783
 
1784
-                if (get_option('permalink_structure') != '') {
1785
-                    $old_listing_slug = '/' . $listing_slug . '/';
1786
-                    $request_term = implode("/", $location_terms);
1787
-                    $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/';
1784
+				if (get_option('permalink_structure') != '') {
1785
+					$old_listing_slug = '/' . $listing_slug . '/';
1786
+					$request_term = implode("/", $location_terms);
1787
+					$new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/';
1788 1788
 
1789
-                    $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1790
-                } else {
1791
-                    $termlink = geodir_getlink($termlink, $request_term);
1792
-                }
1793
-            }
1794
-        }
1789
+					$termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1790
+				} else {
1791
+					$termlink = geodir_getlink($termlink, $request_term);
1792
+				}
1793
+			}
1794
+		}
1795 1795
 
1796
-        // Alter the CPT slug is WPML is set to do so
1797
-        /* we can replace this with the below function
1796
+		// Alter the CPT slug is WPML is set to do so
1797
+		/* we can replace this with the below function
1798 1798
         if(geodir_is_wpml()){
1799 1799
             global $sitepress;
1800 1800
             $post_type = str_replace("category","",$taxonomy);
1801 1801
             $termlink = $sitepress->post_type_archive_link_filter( $termlink, $post_type);
1802 1802
         }*/
1803 1803
 
1804
-        // Alter the CPT slug if WPML is set to do so
1805
-        if (geodir_is_wpml()) {
1806
-            $post_types = get_option('geodir_post_types');
1807
-            $post_type = str_replace("category","",$taxonomy);
1808
-            $post_type = str_replace("_tags","",$post_type);
1809
-            $slug = $post_types[$post_type]['rewrite']['slug'];
1810
-            if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) {
1811
-                global $sitepress;
1812
-                $default_lang = $sitepress->get_default_language();
1813
-                $language_code = gd_wpml_get_lang_from_url($termlink);
1814
-                if (!$language_code ) {
1815
-                    $language_code  = $default_lang;
1816
-                }
1804
+		// Alter the CPT slug if WPML is set to do so
1805
+		if (geodir_is_wpml()) {
1806
+			$post_types = get_option('geodir_post_types');
1807
+			$post_type = str_replace("category","",$taxonomy);
1808
+			$post_type = str_replace("_tags","",$post_type);
1809
+			$slug = $post_types[$post_type]['rewrite']['slug'];
1810
+			if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) {
1811
+				global $sitepress;
1812
+				$default_lang = $sitepress->get_default_language();
1813
+				$language_code = gd_wpml_get_lang_from_url($termlink);
1814
+				if (!$language_code ) {
1815
+					$language_code  = $default_lang;
1816
+				}
1817 1817
 
1818
-                $org_slug = $slug;
1819
-                $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1818
+				$org_slug = $slug;
1819
+				$slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1820 1820
 
1821
-                if (!$slug) {
1822
-                    $slug = $org_slug;
1823
-                }
1821
+				if (!$slug) {
1822
+					$slug = $org_slug;
1823
+				}
1824 1824
 
1825
-                $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1826
-            }
1827
-        }
1828
-    }
1825
+				$termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1826
+			}
1827
+		}
1828
+	}
1829 1829
     
1830
-    return $termlink;
1830
+	return $termlink;
1831 1831
 }
1832 1832
 
1833 1833
 /**
@@ -1853,14 +1853,14 @@  discard block
 block discarded – undo
1853 1853
 	if (in_array($post_type, geodir_get_posttypes())) {
1854 1854
 		if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
1855 1855
 			if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
1856
-                $location_terms = array(
1857
-                    'gd_country' => $post->country_slug,
1858
-                    'gd_region' => $post->region_slug,
1859
-                    'gd_city' => $post->city_slug
1860
-                );
1861
-            } else {
1862
-                $location_terms = geodir_get_current_location_terms('query_vars');
1863
-            }
1856
+				$location_terms = array(
1857
+					'gd_country' => $post->country_slug,
1858
+					'gd_region' => $post->region_slug,
1859
+					'gd_city' => $post->city_slug
1860
+				);
1861
+			} else {
1862
+				$location_terms = geodir_get_current_location_terms('query_vars');
1863
+			}
1864 1864
 			
1865 1865
 			$location_terms = geodir_remove_location_terms($location_terms);
1866 1866
 			
@@ -1892,17 +1892,17 @@  discard block
 block discarded – undo
1892 1892
  * @return void|string Label.
1893 1893
  */
1894 1894
 function get_post_type_singular_label($post_type, $echo = false, $translate = false) {
1895
-    $obj_post_type = get_post_type_object($post_type);
1896
-    if (!is_object($obj_post_type)) {
1897
-        return;
1898
-    }
1895
+	$obj_post_type = get_post_type_object($post_type);
1896
+	if (!is_object($obj_post_type)) {
1897
+		return;
1898
+	}
1899 1899
     
1900
-    $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1900
+	$label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1901 1901
     
1902
-    if ($echo)
1903
-        echo $label;
1904
-    else
1905
-        return $label;
1902
+	if ($echo)
1903
+		echo $label;
1904
+	else
1905
+		return $label;
1906 1906
 }
1907 1907
 
1908 1908
 /**
@@ -1917,19 +1917,19 @@  discard block
 block discarded – undo
1917 1917
  * @return void|string Label.
1918 1918
  */
1919 1919
 function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
1920
-    $all_postypes = geodir_get_posttypes();
1920
+	$all_postypes = geodir_get_posttypes();
1921 1921
 
1922
-    if (!in_array($post_type, $all_postypes))
1923
-        return false;
1922
+	if (!in_array($post_type, $all_postypes))
1923
+		return false;
1924 1924
 
1925
-    $obj_post_type = get_post_type_object($post_type);
1925
+	$obj_post_type = get_post_type_object($post_type);
1926 1926
     
1927
-    $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1927
+	$label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1928 1928
     
1929
-    if ($echo)
1930
-        echo $label;
1931
-    else
1932
-        return $label;
1929
+	if ($echo)
1930
+		echo $label;
1931
+	else
1932
+		return $label;
1933 1933
 }
1934 1934
 
1935 1935
 /**
@@ -1947,51 +1947,51 @@  discard block
 block discarded – undo
1947 1947
  */
1948 1948
 function geodir_term_exists($term, $taxonomy = '', $parent = 0)
1949 1949
 {
1950
-    global $wpdb;
1951
-
1952
-    $select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1953
-    $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1954
-
1955
-    if (is_int($term)) {
1956
-        if (0 == $term)
1957
-            return 0;
1958
-        $where = 't.term_id = %d';
1959
-        if (!empty($taxonomy))
1960
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1961
-        else
1962
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1963
-    }
1950
+	global $wpdb;
1951
+
1952
+	$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1953
+	$tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1954
+
1955
+	if (is_int($term)) {
1956
+		if (0 == $term)
1957
+			return 0;
1958
+		$where = 't.term_id = %d';
1959
+		if (!empty($taxonomy))
1960
+			return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1961
+		else
1962
+			return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1963
+	}
1964 1964
 
1965
-    $term = trim(wp_unslash($term));
1965
+	$term = trim(wp_unslash($term));
1966 1966
 
1967
-    if ('' === $slug = sanitize_title($term))
1968
-        return 0;
1967
+	if ('' === $slug = sanitize_title($term))
1968
+		return 0;
1969 1969
 
1970
-    $where = 't.slug = %s';
1970
+	$where = 't.slug = %s';
1971 1971
 
1972
-    $where_fields = array($slug);
1973
-    if (!empty($taxonomy)) {
1974
-        $parent = (int)$parent;
1975
-        if ($parent > 0) {
1976
-            $where_fields[] = $parent;
1977
-            $else_where_fields[] = $parent;
1978
-            $where .= ' AND tt.parent = %d';
1972
+	$where_fields = array($slug);
1973
+	if (!empty($taxonomy)) {
1974
+		$parent = (int)$parent;
1975
+		if ($parent > 0) {
1976
+			$where_fields[] = $parent;
1977
+			$else_where_fields[] = $parent;
1978
+			$where .= ' AND tt.parent = %d';
1979 1979
 
1980
-        }
1980
+		}
1981 1981
 
1982
-        $where_fields[] = $taxonomy;
1982
+		$where_fields[] = $taxonomy;
1983 1983
 
1984 1984
 
1985
-        if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1986
-            return $result;
1985
+		if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1986
+			return $result;
1987 1987
 
1988
-        return false;
1989
-    }
1988
+		return false;
1989
+	}
1990 1990
 
1991
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1992
-        return $result;
1991
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1992
+		return $result;
1993 1993
 
1994
-    return false;
1994
+	return false;
1995 1995
 }
1996 1996
 
1997 1997
 /**
@@ -2003,7 +2003,7 @@  discard block
 block discarded – undo
2003 2003
 function geodir_get_term_icon_rebuild()
2004 2004
 {
2005 2005
 
2006
-    update_option('gd_term_icons', '');
2006
+	update_option('gd_term_icons', '');
2007 2007
 
2008 2008
 }
2009 2009
 
@@ -2021,61 +2021,61 @@  discard block
 block discarded – undo
2021 2021
  */
2022 2022
 function geodir_get_term_icon($term_id = false, $rebuild = false)
2023 2023
 {
2024
-    global $wpdb;
2025
-    if (!$rebuild) {
2026
-        $terms_icons = get_option('gd_term_icons');
2027
-    } else {
2028
-        $terms_icons = array();
2029
-    }
2030
-
2031
-    if (empty($terms_icons)) {
2032
-        $terms_icons = array();
2033
-        $default_icon_url = get_option('geodir_default_marker_icon');
2034
-        $taxonomy = geodir_get_taxonomies();
2035
-        $post_types = geodir_get_posttypes();
2036
-        $tax_arr = array();
2037
-        foreach ($post_types as $post_type) {
2038
-            $tax_arr[] = "'" . $post_type . "category'";
2039
-        }
2040
-        $tax_c = implode(',', $tax_arr);
2041
-        $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2042
-        //$terms = get_terms( $taxonomy );
2043
-
2044
-        if($terms) {
2045
-            foreach ($terms as $term) {
2046
-                $post_type = str_replace("category", "", $term->taxonomy);
2047
-                $a_terms[$post_type][] = $term;
2024
+	global $wpdb;
2025
+	if (!$rebuild) {
2026
+		$terms_icons = get_option('gd_term_icons');
2027
+	} else {
2028
+		$terms_icons = array();
2029
+	}
2048 2030
 
2049
-            }
2050
-        }
2031
+	if (empty($terms_icons)) {
2032
+		$terms_icons = array();
2033
+		$default_icon_url = get_option('geodir_default_marker_icon');
2034
+		$taxonomy = geodir_get_taxonomies();
2035
+		$post_types = geodir_get_posttypes();
2036
+		$tax_arr = array();
2037
+		foreach ($post_types as $post_type) {
2038
+			$tax_arr[] = "'" . $post_type . "category'";
2039
+		}
2040
+		$tax_c = implode(',', $tax_arr);
2041
+		$terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2042
+		//$terms = get_terms( $taxonomy );
2051 2043
 
2052
-        if($a_terms) {
2053
-            foreach ($a_terms as $pt => $t2) {
2044
+		if($terms) {
2045
+			foreach ($terms as $term) {
2046
+				$post_type = str_replace("category", "", $term->taxonomy);
2047
+				$a_terms[$post_type][] = $term;
2054 2048
 
2055
-                foreach ($t2 as $term) {
2056
-                    $term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2057
-                    if ($term_icon) {
2058
-                        $term_icon_url = $term_icon["src"];
2059
-                    } else {
2060
-                        $term_icon_url = $default_icon_url;
2061
-                    }
2062
-                    $terms_icons[$term->term_id] = $term_icon_url;
2063
-                }
2064
-            }
2065
-        }
2049
+			}
2050
+		}
2051
+
2052
+		if($a_terms) {
2053
+			foreach ($a_terms as $pt => $t2) {
2066 2054
 
2067
-        update_option('gd_term_icons', $terms_icons);
2068
-    }
2055
+				foreach ($t2 as $term) {
2056
+					$term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2057
+					if ($term_icon) {
2058
+						$term_icon_url = $term_icon["src"];
2059
+					} else {
2060
+						$term_icon_url = $default_icon_url;
2061
+					}
2062
+					$terms_icons[$term->term_id] = $term_icon_url;
2063
+				}
2064
+			}
2065
+		}
2069 2066
 
2070
-    if ($term_id && isset($terms_icons[$term_id])) {
2071
-        return $terms_icons[$term_id];
2072
-    } elseif ($term_id && !isset($terms_icons[$term_id])) {
2073
-        return get_option('geodir_default_marker_icon');
2074
-    }
2067
+		update_option('gd_term_icons', $terms_icons);
2068
+	}
2069
+
2070
+	if ($term_id && isset($terms_icons[$term_id])) {
2071
+		return $terms_icons[$term_id];
2072
+	} elseif ($term_id && !isset($terms_icons[$term_id])) {
2073
+		return get_option('geodir_default_marker_icon');
2074
+	}
2075 2075
 
2076
-    if (is_ssl()) {
2077
-        $terms_icons = str_replace("http:","https:",$terms_icons );
2078
-    }
2076
+	if (is_ssl()) {
2077
+		$terms_icons = str_replace("http:","https:",$terms_icons );
2078
+	}
2079 2079
 
2080
-    return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2080
+	return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2081 2081
 }
2082 2082
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/signup_function.php 2 patches
Indentation   +624 added lines, -624 removed lines patch added patch discarded remove patch
@@ -17,18 +17,18 @@  discard block
 block discarded – undo
17 17
  */
18 18
 function geodir_is_login($redirect = false)
19 19
 {
20
-    global $current_user;
21
-    if (!$current_user->ID) {
22
-        if ($redirect) {
23
-            ?>
20
+	global $current_user;
21
+	if (!$current_user->ID) {
22
+		if ($redirect) {
23
+			?>
24 24
             <script type="text/javascript">
25 25
                 window.location.href = '<?php echo geodir_login_url();?>';
26 26
             </script>
27 27
         <?php
28
-        } else
29
-            return false;
30
-    } else
31
-        return true;
28
+		} else
29
+			return false;
30
+	} else
31
+		return true;
32 32
 }
33 33
 
34 34
 /**
@@ -42,25 +42,25 @@  discard block
 block discarded – undo
42 42
 {
43 43
 
44 44
 // Redirect to https login if forced to use SSL
45
-    if (force_ssl_admin() && !is_ssl()) {
46
-        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
47
-            wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
48
-            exit();
49
-        } else {
50
-            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
51
-            exit();
52
-        }
53
-    }
54
-
55
-    /**
56
-     * Filter the login message.
57
-     *
58
-     * @since 1.0.0
59
-     *
60
-     * @param string $message Login message.
61
-     */
62
-    $message = apply_filters('login_message', $message);
63
-    if (!empty($message)) echo $message . "\n";
45
+	if (force_ssl_admin() && !is_ssl()) {
46
+		if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
47
+			wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
48
+			exit();
49
+		} else {
50
+			wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
51
+			exit();
52
+		}
53
+	}
54
+
55
+	/**
56
+	 * Filter the login message.
57
+	 *
58
+	 * @since 1.0.0
59
+	 *
60
+	 * @param string $message Login message.
61
+	 */
62
+	$message = apply_filters('login_message', $message);
63
+	if (!empty($message)) echo $message . "\n";
64 64
 
65 65
 }
66 66
 
@@ -73,59 +73,59 @@  discard block
 block discarded – undo
73 73
  */
74 74
 function geodir_get_site_email_id()
75 75
 {
76
-    if (get_option('site_email')) {
76
+	if (get_option('site_email')) {
77 77
 
78
-        return get_option('site_email');
78
+		return get_option('site_email');
79 79
 
80
-    } else {
80
+	} else {
81 81
 
82
-        return get_option('admin_email');
82
+		return get_option('admin_email');
83 83
 
84
-    }
84
+	}
85 85
 
86 86
 }
87 87
 
88 88
 
89 89
 if (!function_exists('get_site_emailName')) {
90
-    /**
91
-     * Get site name for sending emails.
92
-     *
93
-     * @since 1.0.0
94
-     * @package GeoDirectory
95
-     * @return string Site name.
96
-     */
97
-    function get_site_emailName()
90
+	/**
91
+	 * Get site name for sending emails.
92
+	 *
93
+	 * @since 1.0.0
94
+	 * @package GeoDirectory
95
+	 * @return string Site name.
96
+	 */
97
+	function get_site_emailName()
98 98
 
99
-    {
99
+	{
100 100
 
101
-        if (get_option('site_email_name')) {
101
+		if (get_option('site_email_name')) {
102 102
 
103
-            return stripslashes(get_option('site_email_name'));
103
+			return stripslashes(get_option('site_email_name'));
104 104
 
105
-        } else {
105
+		} else {
106 106
 
107
-            return stripslashes(get_option('blogname'));
107
+			return stripslashes(get_option('blogname'));
108 108
 
109
-        }
109
+		}
110 110
 
111
-    }
111
+	}
112 112
 }
113 113
 
114 114
 if (!function_exists('is_allow_user_register')) {
115
-    /**
116
-     * Checks whether the site allowing user registration or not.
117
-     *
118
-     * @since 1.0.0
119
-     * @package GeoDirectory
120
-     * @return bool|string
121
-     */
122
-    function is_allow_user_register()
115
+	/**
116
+	 * Checks whether the site allowing user registration or not.
117
+	 *
118
+	 * @since 1.0.0
119
+	 * @package GeoDirectory
120
+	 * @return bool|string
121
+	 */
122
+	function is_allow_user_register()
123 123
 
124
-    {
124
+	{
125 125
 
126
-        return get_option('users_can_register');
126
+		return get_option('users_can_register');
127 127
 
128
-    }
128
+	}
129 129
 }
130 130
 
131 131
 /**
@@ -138,107 +138,107 @@  discard block
 block discarded – undo
138 138
  */
139 139
 function geodir_retrieve_password()
140 140
 {
141
-    global $wpdb;
142
-
143
-    $errors = new WP_Error();
144
-    if (empty($_POST['user_login']) && empty($_POST['user_email']))
145
-        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'geodirectory'));
146
-
147
-    if (strpos($_POST['user_login'], '@')) {
148
-        //$user_data = get_user_by_email(trim($_POST['user_login']));
149
-        $user_data = get_user_by('email', trim($_POST['user_login']));
150
-        if (empty($user_data))
151
-            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'geodirectory'));
152
-    } else {
153
-        $login = trim($_POST['user_login']);
154
-        $user_data = get_user_by('email', $login);
155
-    }
156
-
157
-    /**
158
-     * Called in the geodir_retrieve_password() function before any errors are set or any emails are sent.
159
-     *
160
-     * @since 1.0.0
161
-     */
162
-    do_action('lostpassword_post');
163
-
164
-    if ($errors->get_error_code())
165
-        return $errors;
166
-
167
-    if (!$user_data) {
168
-        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'geodirectory'));
169
-        return $errors;
170
-    }
171
-
172
-    // redefining user_login ensures we return the right case in the email
173
-    $user_login = $user_data->user_login;
174
-    $user_email = $user_data->user_email;
175
-
176
-    /**
177
-     * Called in the geodir_retrieve_password() function before any emails are sent.
178
-     *
179
-     * @since 1.0.0
180
-     * @param string $user_login The users username.
181
-     */
182
-    do_action('retrieve_password', $user_login);
183
-
184
-    ////////////////////////////////////
185
-    $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : '';
186
-    $user_login = $_POST['user_login'];
187
-
188
-    $user = $wpdb->get_row(
189
-        $wpdb->prepare(
190
-            "SELECT * FROM $wpdb->users WHERE user_login like %s or user_email like %s",
191
-            array($user_login, $user_login)
192
-        )
193
-    );
194
-
195
-    if (empty($user))
196
-        return new WP_Error('invalid_key', __('Invalid key', 'geodirectory'));
197
-
198
-    $new_pass = wp_generate_password(12, false);
199
-
200
-    /**
201
-     * Called in the geodir_retrieve_password() function before any emails are sent.
202
-     *
203
-     * @since 1.0.0
204
-     * @param object $user The user object.
205
-     * @param string $new_pass The new pass being sent to the user.
206
-     */
207
-    do_action('password_reset', $user, $new_pass);
208
-
209
-    wp_set_password($new_pass, $user->ID);
210
-    update_user_meta($user->ID, 'default_password_nag', true); //Set up the Password change nag.
211
-    $message = '<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>';
212
-    $message .= '<p>' . sprintf(__('Username: %s', 'geodirectory'), $user->user_login) . "</p>";
213
-    $message .= '<p>' . sprintf(__('Password: %s', 'geodirectory'), $new_pass) . "</p>";
214
-    //$message .= '<p>You can login to : <a href="'.home_url().'/?ptype=login' . "\">Login</a> or the URL is :  ".home_url()."/?ptype=login</p>";
215
-    //$message .= '<p>Thank You,<br> '.get_option('blogname').'</p>';
216
-    $user_email = $user_data->user_email;
217
-    $user_name = geodir_get_client_name($user->ID);
218
-    $fromEmail = geodir_get_site_email_id();
219
-    $fromEmailName = get_site_emailName();
220
-    $title = sprintf(__('[%s] Your new password', 'geodirectory'), get_option('blogname'));
221
-    /**
222
-     * Filter the password reset email subject part.
223
-     *
224
-     * @since 1.0.0
225
-     *
226
-     * @param string $title Password reset email subject.
227
-     */
228
-    $title = apply_filters('password_reset_title', $title);
229
-    /**
230
-     * Filter the password reset email message part.
231
-     *
232
-     * @since 1.0.0
233
-     *
234
-     * @param string $message Password reset email message.
235
-     * @param string $new_pass The new password string.
236
-     */
237
-    $message = apply_filters('password_reset_message', $message, $new_pass);
238
-    //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$user_name,$title,$message,$extra='');///forgot password email
239
-    geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID);///forgot password email
240
-
241
-    return true;
141
+	global $wpdb;
142
+
143
+	$errors = new WP_Error();
144
+	if (empty($_POST['user_login']) && empty($_POST['user_email']))
145
+		$errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'geodirectory'));
146
+
147
+	if (strpos($_POST['user_login'], '@')) {
148
+		//$user_data = get_user_by_email(trim($_POST['user_login']));
149
+		$user_data = get_user_by('email', trim($_POST['user_login']));
150
+		if (empty($user_data))
151
+			$errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'geodirectory'));
152
+	} else {
153
+		$login = trim($_POST['user_login']);
154
+		$user_data = get_user_by('email', $login);
155
+	}
156
+
157
+	/**
158
+	 * Called in the geodir_retrieve_password() function before any errors are set or any emails are sent.
159
+	 *
160
+	 * @since 1.0.0
161
+	 */
162
+	do_action('lostpassword_post');
163
+
164
+	if ($errors->get_error_code())
165
+		return $errors;
166
+
167
+	if (!$user_data) {
168
+		$errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'geodirectory'));
169
+		return $errors;
170
+	}
171
+
172
+	// redefining user_login ensures we return the right case in the email
173
+	$user_login = $user_data->user_login;
174
+	$user_email = $user_data->user_email;
175
+
176
+	/**
177
+	 * Called in the geodir_retrieve_password() function before any emails are sent.
178
+	 *
179
+	 * @since 1.0.0
180
+	 * @param string $user_login The users username.
181
+	 */
182
+	do_action('retrieve_password', $user_login);
183
+
184
+	////////////////////////////////////
185
+	$user_email = isset($_POST['user_email']) ? $_POST['user_email'] : '';
186
+	$user_login = $_POST['user_login'];
187
+
188
+	$user = $wpdb->get_row(
189
+		$wpdb->prepare(
190
+			"SELECT * FROM $wpdb->users WHERE user_login like %s or user_email like %s",
191
+			array($user_login, $user_login)
192
+		)
193
+	);
194
+
195
+	if (empty($user))
196
+		return new WP_Error('invalid_key', __('Invalid key', 'geodirectory'));
197
+
198
+	$new_pass = wp_generate_password(12, false);
199
+
200
+	/**
201
+	 * Called in the geodir_retrieve_password() function before any emails are sent.
202
+	 *
203
+	 * @since 1.0.0
204
+	 * @param object $user The user object.
205
+	 * @param string $new_pass The new pass being sent to the user.
206
+	 */
207
+	do_action('password_reset', $user, $new_pass);
208
+
209
+	wp_set_password($new_pass, $user->ID);
210
+	update_user_meta($user->ID, 'default_password_nag', true); //Set up the Password change nag.
211
+	$message = '<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>';
212
+	$message .= '<p>' . sprintf(__('Username: %s', 'geodirectory'), $user->user_login) . "</p>";
213
+	$message .= '<p>' . sprintf(__('Password: %s', 'geodirectory'), $new_pass) . "</p>";
214
+	//$message .= '<p>You can login to : <a href="'.home_url().'/?ptype=login' . "\">Login</a> or the URL is :  ".home_url()."/?ptype=login</p>";
215
+	//$message .= '<p>Thank You,<br> '.get_option('blogname').'</p>';
216
+	$user_email = $user_data->user_email;
217
+	$user_name = geodir_get_client_name($user->ID);
218
+	$fromEmail = geodir_get_site_email_id();
219
+	$fromEmailName = get_site_emailName();
220
+	$title = sprintf(__('[%s] Your new password', 'geodirectory'), get_option('blogname'));
221
+	/**
222
+	 * Filter the password reset email subject part.
223
+	 *
224
+	 * @since 1.0.0
225
+	 *
226
+	 * @param string $title Password reset email subject.
227
+	 */
228
+	$title = apply_filters('password_reset_title', $title);
229
+	/**
230
+	 * Filter the password reset email message part.
231
+	 *
232
+	 * @since 1.0.0
233
+	 *
234
+	 * @param string $message Password reset email message.
235
+	 * @param string $new_pass The new password string.
236
+	 */
237
+	$message = apply_filters('password_reset_message', $message, $new_pass);
238
+	//geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$user_name,$title,$message,$extra='');///forgot password email
239
+	geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID);///forgot password email
240
+
241
+	return true;
242 242
 }
243 243
 
244 244
 /**
@@ -253,80 +253,80 @@  discard block
 block discarded – undo
253 253
  */
254 254
 function geodir_register_new_user($user_login, $user_email)
255 255
 {
256
-    global $wpdb;
257
-    $errors = new WP_Error();
258
-
259
-
260
-    $user_login = sanitize_user($user_login);
261
-    $user_login = str_replace(",", "", $user_login);
262
-    $user_email = str_replace(",", "", $user_email);
263
-    /**
264
-     * Filter the user registration email.
265
-     *
266
-     * @since 1.0.0
267
-     *
268
-     * @param string $user_email User registration email.
269
-     */
270
-    $user_email = apply_filters('user_registration_email', $user_email);
271
-
272
-
273
-    if (get_option('geodir_allow_cpass')) {
274
-        $user_pass = $_REQUEST['user_pass'];
275
-        $user_pass2 = $_REQUEST['user_pass2'];
276
-        // Check the password
277
-        if ($user_pass != $user_pass2) {
278
-            $errors->add('pass_match', __('ERROR: Passwords do not match.', 'geodirectory'));
279
-        } elseif (strlen($user_pass) < 7) {
280
-            $errors->add('pass_match', __('ERROR: Password must be 7 characters or more.', 'geodirectory'));
281
-        }
282
-    }
283
-
284
-    // Check the username
285
-    if ($user_login == '')
286
-        $errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory'));
287
-    elseif (!validate_username($user_login)) {
288
-        $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.', 'geodirectory'));
289
-        $user_login = '';
290
-    } elseif (username_exists($user_login))
291
-        $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory'));
292
-
293
-    // Check the e-mail address
294
-    if ($user_email == '') {
295
-        $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.', 'geodirectory'));
296
-    } elseif (!is_email($user_email)) {
297
-        $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.', 'geodirectory'));
298
-        $user_email = '';
299
-    } elseif (email_exists($user_email))
300
-        $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory'));
301
-
302
-    /**
303
-     * Called when registering a new user.
304
-     *
305
-     * This is a WordPress core hook.
306
-     *
307
-     * @link https://codex.wordpress.org/Plugin_API/Action_Reference/register_post
308
-     * @since 1.0.0
309
-     */
310
-    do_action('register_post', $user_login, $user_email, $errors);
311
-    /**
312
-     * Filter the registration error messages.
313
-     *
314
-     * @since 1.0.0
315
-     *
316
-     * @param object $errors Registration error messages.
317
-     */
318
-    $errors = apply_filters('registration_errors', $errors,$user_login,$user_email);
319
-
320
-    if ($errors->get_error_code())
321
-        return $errors;
322
-
323
-
324
-    if (!isset($user_pass) || $user_pass == '') {
325
-        $user_pass = wp_generate_password(12, false);
326
-    }
327
-    $user_id = wp_create_user($user_login, $user_pass, $user_email);
328
-    $user_web = '';
329
-    /*$user_add1 = $_POST['user_add1'];
256
+	global $wpdb;
257
+	$errors = new WP_Error();
258
+
259
+
260
+	$user_login = sanitize_user($user_login);
261
+	$user_login = str_replace(",", "", $user_login);
262
+	$user_email = str_replace(",", "", $user_email);
263
+	/**
264
+	 * Filter the user registration email.
265
+	 *
266
+	 * @since 1.0.0
267
+	 *
268
+	 * @param string $user_email User registration email.
269
+	 */
270
+	$user_email = apply_filters('user_registration_email', $user_email);
271
+
272
+
273
+	if (get_option('geodir_allow_cpass')) {
274
+		$user_pass = $_REQUEST['user_pass'];
275
+		$user_pass2 = $_REQUEST['user_pass2'];
276
+		// Check the password
277
+		if ($user_pass != $user_pass2) {
278
+			$errors->add('pass_match', __('ERROR: Passwords do not match.', 'geodirectory'));
279
+		} elseif (strlen($user_pass) < 7) {
280
+			$errors->add('pass_match', __('ERROR: Password must be 7 characters or more.', 'geodirectory'));
281
+		}
282
+	}
283
+
284
+	// Check the username
285
+	if ($user_login == '')
286
+		$errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory'));
287
+	elseif (!validate_username($user_login)) {
288
+		$errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.', 'geodirectory'));
289
+		$user_login = '';
290
+	} elseif (username_exists($user_login))
291
+		$errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory'));
292
+
293
+	// Check the e-mail address
294
+	if ($user_email == '') {
295
+		$errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.', 'geodirectory'));
296
+	} elseif (!is_email($user_email)) {
297
+		$errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.', 'geodirectory'));
298
+		$user_email = '';
299
+	} elseif (email_exists($user_email))
300
+		$errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory'));
301
+
302
+	/**
303
+	 * Called when registering a new user.
304
+	 *
305
+	 * This is a WordPress core hook.
306
+	 *
307
+	 * @link https://codex.wordpress.org/Plugin_API/Action_Reference/register_post
308
+	 * @since 1.0.0
309
+	 */
310
+	do_action('register_post', $user_login, $user_email, $errors);
311
+	/**
312
+	 * Filter the registration error messages.
313
+	 *
314
+	 * @since 1.0.0
315
+	 *
316
+	 * @param object $errors Registration error messages.
317
+	 */
318
+	$errors = apply_filters('registration_errors', $errors,$user_login,$user_email);
319
+
320
+	if ($errors->get_error_code())
321
+		return $errors;
322
+
323
+
324
+	if (!isset($user_pass) || $user_pass == '') {
325
+		$user_pass = wp_generate_password(12, false);
326
+	}
327
+	$user_id = wp_create_user($user_login, $user_pass, $user_email);
328
+	$user_web = '';
329
+	/*$user_add1 = $_POST['user_add1'];
330 330
     $user_add2 = $_POST['user_add2'];
331 331
     $user_city = $_POST['user_city'];
332 332
     $user_state = $_POST['user_state'];
@@ -335,77 +335,77 @@  discard block
 block discarded – undo
335 335
     $user_web = $_POST['user_web'];
336 336
     $user_phone = $_POST['user_phone'];
337 337
     $user_twitter = $_POST['user_twitter'];	*/
338
-    $user_fname = sanitize_user($_POST['user_fname']);
339
-    $user_fname = str_replace(",", "", $user_fname);
340
-
341
-    /**
342
-     * Filter the submitted user meta.
343
-     *
344
-     * @since 1.0.0
345
-     *
346
-     * @param int $user_id User ID.
347
-     */
348
-    $user_address_info = apply_filters('geodir_manage_user_meta', array(
349
-        "user_add1" => '',
350
-        "user_add2" => '',
351
-        "user_city" => '',
352
-        "user_state" => '',
353
-        "user_country" => '',
354
-        "user_postalcode" => '',
355
-        "user_phone" => '',
356
-        "user_twitter" => '',
357
-        "first_name" => $user_fname,
358
-        "last_name" => '',
359
-    ), $user_id);
360
-    foreach ($user_address_info as $key => $val) {
361
-        update_user_meta($user_id, $key, $val); // User Address Information Here
362
-    }
363
-    //update_user_meta($user_id, 'user_address_info', ($user_address_info)); // User Address Information Here
364
-    $userName = $user_fname;
365
-    update_user_meta($user_id, 'first_name', $userName); // User Address Information Here
366
-    //update_user_meta($user_id, 'last_name', $_POST['user_lname']); // User Address Information Here
367
-
368
-    // Changed by vikas sharma to enable all type of characters in author permalink...
369
-    $user_nicename = sanitize_title($userName);
370
-
371
-    $updateUsersql = $wpdb->prepare("update $wpdb->users set user_url=%s, user_nicename=%s, display_name=%s  where ID=%d", array($user_web, $user_nicename, $userName, $user_id));
372
-
373
-    $wpdb->query($updateUsersql);
374
-
375
-    if (!$user_id) {
376
-        $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'geodirectory'), get_option('admin_email')));
377
-        return $errors;
378
-    }
379
-    global $upload_folder_path;
380
-
381
-    if ($user_id) {
382
-
383
-        /**
384
-         * Called after registering a user and before the registration email is sent.
385
-         *
386
-         * @since 1.0.0
387
-         * @param int $user_id The user ID of the registered user.
388
-         */
389
-        do_action('geodir_user_register', $user_id);
390
-        ///////REGISTRATION EMAIL START//////
391
-        $fromEmail = geodir_get_site_email_id();
392
-        $fromEmailName = get_site_emailName();
393
-        $message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>
338
+	$user_fname = sanitize_user($_POST['user_fname']);
339
+	$user_fname = str_replace(",", "", $user_fname);
340
+
341
+	/**
342
+	 * Filter the submitted user meta.
343
+	 *
344
+	 * @since 1.0.0
345
+	 *
346
+	 * @param int $user_id User ID.
347
+	 */
348
+	$user_address_info = apply_filters('geodir_manage_user_meta', array(
349
+		"user_add1" => '',
350
+		"user_add2" => '',
351
+		"user_city" => '',
352
+		"user_state" => '',
353
+		"user_country" => '',
354
+		"user_postalcode" => '',
355
+		"user_phone" => '',
356
+		"user_twitter" => '',
357
+		"first_name" => $user_fname,
358
+		"last_name" => '',
359
+	), $user_id);
360
+	foreach ($user_address_info as $key => $val) {
361
+		update_user_meta($user_id, $key, $val); // User Address Information Here
362
+	}
363
+	//update_user_meta($user_id, 'user_address_info', ($user_address_info)); // User Address Information Here
364
+	$userName = $user_fname;
365
+	update_user_meta($user_id, 'first_name', $userName); // User Address Information Here
366
+	//update_user_meta($user_id, 'last_name', $_POST['user_lname']); // User Address Information Here
367
+
368
+	// Changed by vikas sharma to enable all type of characters in author permalink...
369
+	$user_nicename = sanitize_title($userName);
370
+
371
+	$updateUsersql = $wpdb->prepare("update $wpdb->users set user_url=%s, user_nicename=%s, display_name=%s  where ID=%d", array($user_web, $user_nicename, $userName, $user_id));
372
+
373
+	$wpdb->query($updateUsersql);
374
+
375
+	if (!$user_id) {
376
+		$errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'geodirectory'), get_option('admin_email')));
377
+		return $errors;
378
+	}
379
+	global $upload_folder_path;
380
+
381
+	if ($user_id) {
382
+
383
+		/**
384
+		 * Called after registering a user and before the registration email is sent.
385
+		 *
386
+		 * @since 1.0.0
387
+		 * @param int $user_id The user ID of the registered user.
388
+		 */
389
+		do_action('geodir_user_register', $user_id);
390
+		///////REGISTRATION EMAIL START//////
391
+		$fromEmail = geodir_get_site_email_id();
392
+		$fromEmailName = get_site_emailName();
393
+		$message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>
394 394
 <p>' . __('Username:', 'geodirectory') . ' ' . $user_login . '</p>
395 395
 <p>' . __('Password:', 'geodirectory') . ' ' . $user_pass . '</p>');
396 396
 
397
-        /////////////customer email//////////////
398
-        //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email
399
-        geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id);/// registration email
400
-        //////REGISTRATION EMAIL END////////
401
-    }
397
+		/////////////customer email//////////////
398
+		//geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email
399
+		geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id);/// registration email
400
+		//////REGISTRATION EMAIL END////////
401
+	}
402 402
 
403
-    if (get_option('ptthemes_auto_login')) {
404
-        $errors->add('auto_login', __('<strong>SUCCESS</strong>: Thank you for registering, please check your email for your login details.', 'geodirectory'));
405
-        return $errors;
406
-    }
403
+	if (get_option('ptthemes_auto_login')) {
404
+		$errors->add('auto_login', __('<strong>SUCCESS</strong>: Thank you for registering, please check your email for your login details.', 'geodirectory'));
405
+		return $errors;
406
+	}
407 407
 
408
-    return array($user_id, $user_pass);
408
+	return array($user_id, $user_pass);
409 409
 }
410 410
 
411 411
 /**
@@ -418,331 +418,331 @@  discard block
 block discarded – undo
418 418
  */
419 419
 function geodir_user_signup()
420 420
 {
421
-    global $errors;
422
-    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
423
-
424
-    $errors = new WP_Error();
425
-
426
-    if (isset($_GET['key']))
427
-        $action = 'resetpass';
428
-
429
-    // validate action so as to default to the login screen
430
-    if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action))
431
-        $action = 'login';
432
-
433
-    nocache_headers();
434
-
435
-    if (defined('RELOCATE')) { // Move flag is set
436
-        if (isset($_SERVER['PATH_INFO']) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']))
437
-            $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']);
438
-
439
-        $schema = (isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://';
440
-        if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url())
441
-            update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']));
442
-    }
443
-
444
-    //Set a cookie now to see if they are supported by the browser.
445
-    //setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
446
-    if (SITECOOKIEPATH != COOKIEPATH)
447
-        setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
448
-
449
-    /**
450
-     * Allow plugins to override the default actions, and to add extra actions if they want on the register/signin page.
451
-     *
452
-     * Used dynamic hook login_form_$action
453
-     *
454
-     * @since 1.0.0
455
-     */
456
-    do_action('login_form_' . $action);
457
-
458
-    $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
459
-
460
-    switch ($action):
461
-
462
-        case 'logout' :
463
-            //check_admin_referer('log-out');
464
-            wp_logout();
465
-
466
-            $redirect_to = $_SERVER['HTTP_REFERER'];
467
-            //$redirect_to = home_url().'/?ptype=login&loggedout=true';
468
-            if (isset($_REQUEST['redirect_to']))
469
-                $redirect_to = $_REQUEST['redirect_to'];
470
-            $redirect_to = home_url();
471
-            wp_safe_redirect($redirect_to);
472
-            exit();
473
-
474
-            break;
475
-
476
-        case 'lostpassword' :
477
-        case 'retrievepassword' :
478
-            if ($http_post) {
479
-                $errors = geodir_retrieve_password();
480
-                $error_message = isset($errors->errors['invalid_email'][0]) ? $errors->errors['invalid_email'][0] : '';
481
-                if (!is_wp_error($errors)) {
482
-                    wp_redirect(geodir_login_url(array('checkemail'=>'confirm')));
483
-                    gd_die();
484
-                } else {
485
-                    wp_redirect(geodir_login_url(array('forgot' => 1, 'emsg'=>'fw')));
486
-                    gd_die();
487
-                }
488
-            }
489
-            if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'geodirectory'));
490
-        /**
491
-         * Called in the geodir_user_signup() function during the lostpassword case.
492
-         *
493
-         * @since 1.0.0
494
-         */
495
-        do_action('lost_password');
496
-            $message = '<div class="sucess_msg">' . ENTER_USER_EMAIL_NEW_PW_MSG . '</div>';
497
-            $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : '';
498
-
499
-            break;
500
-
501
-        case 'resetpass' :
502
-        case 'rp' :
503
-            $errors = reset_password($_GET['key'], $_GET['login']);
504
-
505
-            if (!is_wp_error($errors)) {
506
-                wp_redirect(geodir_login_url(array('checkemail'=>'newpass')));
507
-                exit();
508
-            }
509
-
510
-            wp_redirect(geodir_login_url(array('error'=>'invalidkey','action'=>'lostpassword')));
511
-            exit();
512
-
513
-            break;
514
-
515
-        case 'register' :
516
-            ############################### fix by Stiofan -  HebTech.co.uk ### SECURITY FIX ##############################
517
-            if (!get_option('users_can_register')) {
518
-                wp_redirect(geodir_login_url(array('emsg'=>'regnewusr')));
519
-                exit();
520
-            }
521
-            ############################### fix by Stiofan -  HebTech.co.uk ### SECURITY FIX ##############################
522
-            global $user_email, $user_fname;
523
-            $user_login = '';
524
-            $user_email = '';
525
-            if ($http_post) {
526
-                $user_login = $_POST['user_email'];
527
-                $user_email = $_POST['user_email'];
528
-                $user_fname = $_POST['user_fname'];
529
-
530
-                $errors = geodir_register_new_user($user_login, $user_email);
531
-
532
-                /* display error in registration form */
533
-                if (is_wp_error($errors)) {
534
-                    $error_code = $errors->get_error_code();
535
-                    $error_message = $errors->get_error_message($error_code);
536
-                    if (!isset($_POST['user_login']) && ($error_code == 'empty_username' || $error_code == 'invalid_username' || $error_code == 'username_exists')) {
537
-                        if ($error_code == 'empty_username') {
538
-                            $error_code = 'empty_email';
539
-                        } else if ($error_code == 'invalid_username') {
540
-                            $error_code = 'invalid_email';
541
-                        } else if ($error_code == 'username_exists') {
542
-                            $error_code = 'email_exists';
543
-                        }
544
-
545
-                        $error_message = $errors->get_error_message($error_code);
546
-                    }
547
-                    global $geodir_signup_error;
548
-                    $geodir_signup_error = $error_message;
549
-                }
550
-
551
-                if (!is_wp_error($errors)) {
552
-                    $_POST['log'] = $user_login;
553
-                    $_POST['pwd'] = $errors[1];
554
-                    $_POST['testcookie'] = 1;
555
-
556
-                    $secure_cookie = '';
557
-                    // If the user wants ssl but the session is not ssl, force a secure cookie.
558
-                    if (!empty($_POST['log'])) {
559
-                        $user_name = sanitize_user($_POST['log']);
560
-                        if ($user = get_user_by('email', $user_name)) {
561
-                            if (get_user_option('use_ssl', $user->ID)) {
562
-                                $secure_cookie = true;
563
-                                force_ssl_admin(true);
564
-                            }
565
-                        }
566
-                    }
567
-
568
-                    $redirect_to = $_REQUEST['redirect_to'];
569
-
570
-                    if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') {
571
-                        if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], home_url())) {
572
-                            $redirect_to = $_SERVER['HTTP_REFERER'];
573
-                        } else {
574
-                            $redirect_to = home_url();
575
-                        }
576
-
577
-                    }
578
-
579
-                    if (isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '') {
580
-
581
-                        $redirect_to = $_REQUEST['redirect_add_listing'];
582
-                    }
583
-
584
-
585
-                    if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http')))
586
-                        $secure_cookie = false;
587
-
588
-                    $user = wp_signon('', $secure_cookie);
589
-
590
-                    $requested_redirect_to = isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '' ? $_REQUEST['redirect_add_listing'] : (isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '');
591
-                    /**
592
-                     * Filter the login redirect URL.
593
-                     *
594
-                     * @since 1.4.9
595
-                     * @param string $redirect_to The redirect destination URL.
596
-                     * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter.
597
-                     * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise.
598
-                     */
599
-                    $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
600
-
601
-
602
-                    if (!is_wp_error($user)) {
603
-                        wp_safe_redirect($redirect_to);
604
-                        exit();
605
-                    }
606
-                    exit();
607
-                }
608
-            }
609
-
610
-            break;
611
-
612
-        case 'login' :
613
-        default:
614
-            $secure_cookie = '';
615
-
616
-            if (!empty($_POST['log'])) {
617
-                $user_name = sanitize_user($_POST['log']);
618
-                if ($user = get_user_by('login', $user_name)) {
619
-
620
-                    if (get_user_option('use_ssl', $user->ID)) {
621
-                        $secure_cookie = true;
622
-                        force_ssl_admin(true);
623
-                    }
624
-                } elseif ($user = get_user_by('email', $user_name)) {
625
-                    $_POST['log'] = $user->user_login; // If signing in by email, set the username for normal WP login
626
-                    if (get_user_option('use_ssl', $user->ID)) {
627
-                        $secure_cookie = true;
628
-                        force_ssl_admin(true);
629
-                    }
630
-                }
631
-            }
632
-            ///////////////////////////
633
-            if (isset($_REQUEST['redirect_add_listing'])) {
634
-                $_REQUEST['redirect_to'] = $_REQUEST['redirect_add_listing'];
635
-            }
636
-
637
-
638
-            if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') {
639
-                if (is_user_logged_in()) :
640
-                    $user_ID = !empty($user->ID) ? $user->ID : get_current_user_id();
641
-                    $post_types = geodir_get_posttypes();
421
+	global $errors;
422
+	$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
423
+
424
+	$errors = new WP_Error();
425
+
426
+	if (isset($_GET['key']))
427
+		$action = 'resetpass';
428
+
429
+	// validate action so as to default to the login screen
430
+	if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action))
431
+		$action = 'login';
432
+
433
+	nocache_headers();
434
+
435
+	if (defined('RELOCATE')) { // Move flag is set
436
+		if (isset($_SERVER['PATH_INFO']) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']))
437
+			$_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']);
438
+
439
+		$schema = (isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://';
440
+		if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url())
441
+			update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']));
442
+	}
443
+
444
+	//Set a cookie now to see if they are supported by the browser.
445
+	//setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
446
+	if (SITECOOKIEPATH != COOKIEPATH)
447
+		setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
448
+
449
+	/**
450
+	 * Allow plugins to override the default actions, and to add extra actions if they want on the register/signin page.
451
+	 *
452
+	 * Used dynamic hook login_form_$action
453
+	 *
454
+	 * @since 1.0.0
455
+	 */
456
+	do_action('login_form_' . $action);
457
+
458
+	$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
459
+
460
+	switch ($action):
461
+
462
+		case 'logout' :
463
+			//check_admin_referer('log-out');
464
+			wp_logout();
465
+
466
+			$redirect_to = $_SERVER['HTTP_REFERER'];
467
+			//$redirect_to = home_url().'/?ptype=login&loggedout=true';
468
+			if (isset($_REQUEST['redirect_to']))
469
+				$redirect_to = $_REQUEST['redirect_to'];
470
+			$redirect_to = home_url();
471
+			wp_safe_redirect($redirect_to);
472
+			exit();
473
+
474
+			break;
475
+
476
+		case 'lostpassword' :
477
+		case 'retrievepassword' :
478
+			if ($http_post) {
479
+				$errors = geodir_retrieve_password();
480
+				$error_message = isset($errors->errors['invalid_email'][0]) ? $errors->errors['invalid_email'][0] : '';
481
+				if (!is_wp_error($errors)) {
482
+					wp_redirect(geodir_login_url(array('checkemail'=>'confirm')));
483
+					gd_die();
484
+				} else {
485
+					wp_redirect(geodir_login_url(array('forgot' => 1, 'emsg'=>'fw')));
486
+					gd_die();
487
+				}
488
+			}
489
+			if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'geodirectory'));
490
+		/**
491
+		 * Called in the geodir_user_signup() function during the lostpassword case.
492
+		 *
493
+		 * @since 1.0.0
494
+		 */
495
+		do_action('lost_password');
496
+			$message = '<div class="sucess_msg">' . ENTER_USER_EMAIL_NEW_PW_MSG . '</div>';
497
+			$user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : '';
498
+
499
+			break;
500
+
501
+		case 'resetpass' :
502
+		case 'rp' :
503
+			$errors = reset_password($_GET['key'], $_GET['login']);
504
+
505
+			if (!is_wp_error($errors)) {
506
+				wp_redirect(geodir_login_url(array('checkemail'=>'newpass')));
507
+				exit();
508
+			}
509
+
510
+			wp_redirect(geodir_login_url(array('error'=>'invalidkey','action'=>'lostpassword')));
511
+			exit();
512
+
513
+			break;
514
+
515
+		case 'register' :
516
+			############################### fix by Stiofan -  HebTech.co.uk ### SECURITY FIX ##############################
517
+			if (!get_option('users_can_register')) {
518
+				wp_redirect(geodir_login_url(array('emsg'=>'regnewusr')));
519
+				exit();
520
+			}
521
+			############################### fix by Stiofan -  HebTech.co.uk ### SECURITY FIX ##############################
522
+			global $user_email, $user_fname;
523
+			$user_login = '';
524
+			$user_email = '';
525
+			if ($http_post) {
526
+				$user_login = $_POST['user_email'];
527
+				$user_email = $_POST['user_email'];
528
+				$user_fname = $_POST['user_fname'];
529
+
530
+				$errors = geodir_register_new_user($user_login, $user_email);
531
+
532
+				/* display error in registration form */
533
+				if (is_wp_error($errors)) {
534
+					$error_code = $errors->get_error_code();
535
+					$error_message = $errors->get_error_message($error_code);
536
+					if (!isset($_POST['user_login']) && ($error_code == 'empty_username' || $error_code == 'invalid_username' || $error_code == 'username_exists')) {
537
+						if ($error_code == 'empty_username') {
538
+							$error_code = 'empty_email';
539
+						} else if ($error_code == 'invalid_username') {
540
+							$error_code = 'invalid_email';
541
+						} else if ($error_code == 'username_exists') {
542
+							$error_code = 'email_exists';
543
+						}
544
+
545
+						$error_message = $errors->get_error_message($error_code);
546
+					}
547
+					global $geodir_signup_error;
548
+					$geodir_signup_error = $error_message;
549
+				}
550
+
551
+				if (!is_wp_error($errors)) {
552
+					$_POST['log'] = $user_login;
553
+					$_POST['pwd'] = $errors[1];
554
+					$_POST['testcookie'] = 1;
555
+
556
+					$secure_cookie = '';
557
+					// If the user wants ssl but the session is not ssl, force a secure cookie.
558
+					if (!empty($_POST['log'])) {
559
+						$user_name = sanitize_user($_POST['log']);
560
+						if ($user = get_user_by('email', $user_name)) {
561
+							if (get_user_option('use_ssl', $user->ID)) {
562
+								$secure_cookie = true;
563
+								force_ssl_admin(true);
564
+							}
565
+						}
566
+					}
567
+
568
+					$redirect_to = $_REQUEST['redirect_to'];
569
+
570
+					if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') {
571
+						if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], home_url())) {
572
+							$redirect_to = $_SERVER['HTTP_REFERER'];
573
+						} else {
574
+							$redirect_to = home_url();
575
+						}
576
+
577
+					}
578
+
579
+					if (isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '') {
580
+
581
+						$redirect_to = $_REQUEST['redirect_add_listing'];
582
+					}
583
+
584
+
585
+					if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http')))
586
+						$secure_cookie = false;
587
+
588
+					$user = wp_signon('', $secure_cookie);
589
+
590
+					$requested_redirect_to = isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '' ? $_REQUEST['redirect_add_listing'] : (isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '');
591
+					/**
592
+					 * Filter the login redirect URL.
593
+					 *
594
+					 * @since 1.4.9
595
+					 * @param string $redirect_to The redirect destination URL.
596
+					 * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter.
597
+					 * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise.
598
+					 */
599
+					$redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
600
+
601
+
602
+					if (!is_wp_error($user)) {
603
+						wp_safe_redirect($redirect_to);
604
+						exit();
605
+					}
606
+					exit();
607
+				}
608
+			}
609
+
610
+			break;
611
+
612
+		case 'login' :
613
+		default:
614
+			$secure_cookie = '';
615
+
616
+			if (!empty($_POST['log'])) {
617
+				$user_name = sanitize_user($_POST['log']);
618
+				if ($user = get_user_by('login', $user_name)) {
619
+
620
+					if (get_user_option('use_ssl', $user->ID)) {
621
+						$secure_cookie = true;
622
+						force_ssl_admin(true);
623
+					}
624
+				} elseif ($user = get_user_by('email', $user_name)) {
625
+					$_POST['log'] = $user->user_login; // If signing in by email, set the username for normal WP login
626
+					if (get_user_option('use_ssl', $user->ID)) {
627
+						$secure_cookie = true;
628
+						force_ssl_admin(true);
629
+					}
630
+				}
631
+			}
632
+			///////////////////////////
633
+			if (isset($_REQUEST['redirect_add_listing'])) {
634
+				$_REQUEST['redirect_to'] = $_REQUEST['redirect_add_listing'];
635
+			}
636
+
637
+
638
+			if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') {
639
+				if (is_user_logged_in()) :
640
+					$user_ID = !empty($user->ID) ? $user->ID : get_current_user_id();
641
+					$post_types = geodir_get_posttypes();
642 642
                     
643
-                    if ( !empty( $_REQUEST['stype'] ) ) {
644
-                        $dashboard_post_type = sanitize_text_field($_REQUEST['stype']);
645
-                    } else {
646
-                        $user_listings = geodir_user_post_listing_count( $user_ID );
647
-                        if ( !empty( $user_listings ) && $dashboard_post_types = array_keys( $user_listings ) ) {
648
-                            $dashboard_post_type = $dashboard_post_types[0];
649
-                        }
650
-                    }
651
-                    if ( !( !empty( $dashboard_post_type ) && in_array( $dashboard_post_type, $post_types ) ) ) {
652
-                        $dashboard_post_type = $post_types[0];
653
-                    }
643
+					if ( !empty( $_REQUEST['stype'] ) ) {
644
+						$dashboard_post_type = sanitize_text_field($_REQUEST['stype']);
645
+					} else {
646
+						$user_listings = geodir_user_post_listing_count( $user_ID );
647
+						if ( !empty( $user_listings ) && $dashboard_post_types = array_keys( $user_listings ) ) {
648
+							$dashboard_post_type = $dashboard_post_types[0];
649
+						}
650
+					}
651
+					if ( !( !empty( $dashboard_post_type ) && in_array( $dashboard_post_type, $post_types ) ) ) {
652
+						$dashboard_post_type = $post_types[0];
653
+					}
654 654
                     
655
-                    $author_link = get_author_posts_url($user_ID);
656
-                    $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $dashboard_post_type), false);
657
-
658
-                    /**
659
-                     * Filter the author link.
660
-                     *
661
-                     * @since 1.0.0
662
-                     *
663
-                     * @param string $default_author_link Default author link.
664
-                     * @param int $user_ID The user ID.
665
-                     */
666
-                    $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_ID);
667
-
668
-                    $_REQUEST['redirect_to'] = $default_author_link;
669
-                else:
670
-                    $_REQUEST['redirect_to'] = home_url();
671
-                endif;
672
-
673
-            }
674
-            if (isset($_REQUEST['redirect_to'])) {
675
-                $redirect_to = $_REQUEST['redirect_to'];
676
-                // Redirect to https if user wants ssl
677
-                if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin'))
678
-                    $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
679
-            } else {
680
-                $redirect_to = admin_url();
681
-            }
682
-
683
-            if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http')))
684
-                $secure_cookie = false;
685
-            $user = wp_signon('', $secure_cookie);
686
-
687
-
688
-            /**
689
-             * Filter the login redirect URL.
690
-             *
691
-             * @since 1.4.9
692
-             * @param string $redirect_to The redirect destination URL.
693
-             * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise.
694
-             */
695
-            $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
696
-
697
-            if (is_wp_error($user)) {
698
-                if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'ptype=property_submit') && $_POST['log'] != '' && $_POST['pwd'] != '') {
699
-                    wp_redirect($_SERVER['HTTP_REFERER'] . '&emsg=1');
700
-                }
701
-            }
702
-            if (!is_wp_error($user)) {
703
-
704
-                // Some servers are not logging the user in properly after wp_signon, se we set the user here.
705
-                //wp_set_current_user($user->ID);
706
-                //echo '###';exit;
707
-
708
-                if ($redirect_to) {
709
-                    wp_redirect($redirect_to);
710
-                } else {
711
-                    wp_redirect(home_url());
712
-                }
713
-                gd_die();
714
-            }
715
-
716
-            $errors = $user;
717
-
718
-            // Clear errors if loggedout is set.
719
-            if (!empty($_GET['loggedout']))
720
-                $errors = new WP_Error();
721
-            // If cookies are disabled we can't log in even with a valid user+pass
722
-            if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]))
723
-                $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'geodirectory'));
724
-
725
-            // Some parts of this script use the main login form to display a message
726
-            if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
727
-                $successmsg = '<div class="sucess_msg">' . YOU_ARE_LOGED_OUT_MSG . '</div>';
728
-            } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
729
-                $successmsg = USER_REG_NOT_ALLOW_MSG;
730
-            } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
731
-                $successmsg = EMAIL_CONFIRM_LINK_MSG;
732
-            } elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) {
733
-                $successmsg = NEW_PW_EMAIL_MSG;
734
-            } elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) {
735
-                $successmsg = REG_COMPLETE_MSG;
736
-            }
737
-
738
-            if ((isset($_POST['log']) && $_POST['log'] != '' && $errors) || ((!isset($_POST['log']) || $_POST['log'] == '') && isset($_REQUEST['testcookie']) && $_REQUEST['testcookie'])) {
739
-                if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') {
740
-                    wp_redirect($_REQUEST['pagetype'] . '&emsg=1');
741
-                } else {
742
-                    wp_redirect(geodir_login_url(array('logemsg'=>'1','redirect_to'=>urlencode($_REQUEST['redirect_to']))));
743
-                }
744
-                gd_die();
745
-            }
746
-            break;
747
-    endswitch; // end action switch
655
+					$author_link = get_author_posts_url($user_ID);
656
+					$default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $dashboard_post_type), false);
657
+
658
+					/**
659
+					 * Filter the author link.
660
+					 *
661
+					 * @since 1.0.0
662
+					 *
663
+					 * @param string $default_author_link Default author link.
664
+					 * @param int $user_ID The user ID.
665
+					 */
666
+					$default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_ID);
667
+
668
+					$_REQUEST['redirect_to'] = $default_author_link;
669
+				else:
670
+					$_REQUEST['redirect_to'] = home_url();
671
+				endif;
672
+
673
+			}
674
+			if (isset($_REQUEST['redirect_to'])) {
675
+				$redirect_to = $_REQUEST['redirect_to'];
676
+				// Redirect to https if user wants ssl
677
+				if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin'))
678
+					$redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
679
+			} else {
680
+				$redirect_to = admin_url();
681
+			}
682
+
683
+			if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http')))
684
+				$secure_cookie = false;
685
+			$user = wp_signon('', $secure_cookie);
686
+
687
+
688
+			/**
689
+			 * Filter the login redirect URL.
690
+			 *
691
+			 * @since 1.4.9
692
+			 * @param string $redirect_to The redirect destination URL.
693
+			 * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise.
694
+			 */
695
+			$redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
696
+
697
+			if (is_wp_error($user)) {
698
+				if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'ptype=property_submit') && $_POST['log'] != '' && $_POST['pwd'] != '') {
699
+					wp_redirect($_SERVER['HTTP_REFERER'] . '&emsg=1');
700
+				}
701
+			}
702
+			if (!is_wp_error($user)) {
703
+
704
+				// Some servers are not logging the user in properly after wp_signon, se we set the user here.
705
+				//wp_set_current_user($user->ID);
706
+				//echo '###';exit;
707
+
708
+				if ($redirect_to) {
709
+					wp_redirect($redirect_to);
710
+				} else {
711
+					wp_redirect(home_url());
712
+				}
713
+				gd_die();
714
+			}
715
+
716
+			$errors = $user;
717
+
718
+			// Clear errors if loggedout is set.
719
+			if (!empty($_GET['loggedout']))
720
+				$errors = new WP_Error();
721
+			// If cookies are disabled we can't log in even with a valid user+pass
722
+			if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]))
723
+				$errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'geodirectory'));
724
+
725
+			// Some parts of this script use the main login form to display a message
726
+			if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
727
+				$successmsg = '<div class="sucess_msg">' . YOU_ARE_LOGED_OUT_MSG . '</div>';
728
+			} elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
729
+				$successmsg = USER_REG_NOT_ALLOW_MSG;
730
+			} elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
731
+				$successmsg = EMAIL_CONFIRM_LINK_MSG;
732
+			} elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) {
733
+				$successmsg = NEW_PW_EMAIL_MSG;
734
+			} elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) {
735
+				$successmsg = REG_COMPLETE_MSG;
736
+			}
737
+
738
+			if ((isset($_POST['log']) && $_POST['log'] != '' && $errors) || ((!isset($_POST['log']) || $_POST['log'] == '') && isset($_REQUEST['testcookie']) && $_REQUEST['testcookie'])) {
739
+				if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') {
740
+					wp_redirect($_REQUEST['pagetype'] . '&emsg=1');
741
+				} else {
742
+					wp_redirect(geodir_login_url(array('logemsg'=>'1','redirect_to'=>urlencode($_REQUEST['redirect_to']))));
743
+				}
744
+				gd_die();
745
+			}
746
+			break;
747
+	endswitch; // end action switch
748 748
 }
749 749
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
         if ($redirect) {
23 23
             ?>
24 24
             <script type="text/javascript">
25
-                window.location.href = '<?php echo geodir_login_url();?>';
25
+                window.location.href = '<?php echo geodir_login_url(); ?>';
26 26
             </script>
27 27
         <?php
28 28
         } else
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
48 48
             exit();
49 49
         } else {
50
-            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
50
+            wp_redirect('https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
51 51
             exit();
52 52
         }
53 53
     }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      * @param string $message Login message.
61 61
      */
62 62
     $message = apply_filters('login_message', $message);
63
-    if (!empty($message)) echo $message . "\n";
63
+    if (!empty($message)) echo $message."\n";
64 64
 
65 65
 }
66 66
 
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 
209 209
     wp_set_password($new_pass, $user->ID);
210 210
     update_user_meta($user->ID, 'default_password_nag', true); //Set up the Password change nag.
211
-    $message = '<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>';
212
-    $message .= '<p>' . sprintf(__('Username: %s', 'geodirectory'), $user->user_login) . "</p>";
213
-    $message .= '<p>' . sprintf(__('Password: %s', 'geodirectory'), $new_pass) . "</p>";
211
+    $message = '<p><b>'.__('Your login Information :', 'geodirectory').'</b></p>';
212
+    $message .= '<p>'.sprintf(__('Username: %s', 'geodirectory'), $user->user_login)."</p>";
213
+    $message .= '<p>'.sprintf(__('Password: %s', 'geodirectory'), $new_pass)."</p>";
214 214
     //$message .= '<p>You can login to : <a href="'.home_url().'/?ptype=login' . "\">Login</a> or the URL is :  ".home_url()."/?ptype=login</p>";
215 215
     //$message .= '<p>Thank You,<br> '.get_option('blogname').'</p>';
216 216
     $user_email = $user_data->user_email;
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      */
237 237
     $message = apply_filters('password_reset_message', $message, $new_pass);
238 238
     //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$user_name,$title,$message,$extra='');///forgot password email
239
-    geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID);///forgot password email
239
+    geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID); ///forgot password email
240 240
 
241 241
     return true;
242 242
 }
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
      *
316 316
      * @param object $errors Registration error messages.
317 317
      */
318
-    $errors = apply_filters('registration_errors', $errors,$user_login,$user_email);
318
+    $errors = apply_filters('registration_errors', $errors, $user_login, $user_email);
319 319
 
320 320
     if ($errors->get_error_code())
321 321
         return $errors;
@@ -390,13 +390,13 @@  discard block
 block discarded – undo
390 390
         ///////REGISTRATION EMAIL START//////
391 391
         $fromEmail = geodir_get_site_email_id();
392 392
         $fromEmailName = get_site_emailName();
393
-        $message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>
394
-<p>' . __('Username:', 'geodirectory') . ' ' . $user_login . '</p>
395
-<p>' . __('Password:', 'geodirectory') . ' ' . $user_pass . '</p>');
393
+        $message = __('<p><b>'.__('Your login Information :', 'geodirectory').'</b></p>
394
+<p>' . __('Username:', 'geodirectory').' '.$user_login.'</p>
395
+<p>' . __('Password:', 'geodirectory').' '.$user_pass.'</p>');
396 396
 
397 397
         /////////////customer email//////////////
398 398
         //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email
399
-        geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id);/// registration email
399
+        geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id); /// registration email
400 400
         //////REGISTRATION EMAIL END////////
401 401
     }
402 402
 
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
         $action = 'resetpass';
428 428
 
429 429
     // validate action so as to default to the login screen
430
-    if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action))
430
+    if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_'.$action))
431 431
         $action = 'login';
432 432
 
433 433
     nocache_headers();
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
             $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']);
438 438
 
439 439
         $schema = (isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://';
440
-        if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url())
441
-            update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']));
440
+        if (dirname($schema.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']) != home_url())
441
+            update_option('siteurl', dirname($schema.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']));
442 442
     }
443 443
 
444 444
     //Set a cookie now to see if they are supported by the browser.
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
      *
454 454
      * @since 1.0.0
455 455
      */
456
-    do_action('login_form_' . $action);
456
+    do_action('login_form_'.$action);
457 457
 
458 458
     $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
459 459
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
          * @since 1.0.0
494 494
          */
495 495
         do_action('lost_password');
496
-            $message = '<div class="sucess_msg">' . ENTER_USER_EMAIL_NEW_PW_MSG . '</div>';
496
+            $message = '<div class="sucess_msg">'.ENTER_USER_EMAIL_NEW_PW_MSG.'</div>';
497 497
             $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : '';
498 498
 
499 499
             break;
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
                 exit();
508 508
             }
509 509
 
510
-            wp_redirect(geodir_login_url(array('error'=>'invalidkey','action'=>'lostpassword')));
510
+            wp_redirect(geodir_login_url(array('error'=>'invalidkey', 'action'=>'lostpassword')));
511 511
             exit();
512 512
 
513 513
             break;
@@ -640,15 +640,15 @@  discard block
 block discarded – undo
640 640
                     $user_ID = !empty($user->ID) ? $user->ID : get_current_user_id();
641 641
                     $post_types = geodir_get_posttypes();
642 642
                     
643
-                    if ( !empty( $_REQUEST['stype'] ) ) {
643
+                    if (!empty($_REQUEST['stype'])) {
644 644
                         $dashboard_post_type = sanitize_text_field($_REQUEST['stype']);
645 645
                     } else {
646
-                        $user_listings = geodir_user_post_listing_count( $user_ID );
647
-                        if ( !empty( $user_listings ) && $dashboard_post_types = array_keys( $user_listings ) ) {
646
+                        $user_listings = geodir_user_post_listing_count($user_ID);
647
+                        if (!empty($user_listings) && $dashboard_post_types = array_keys($user_listings)) {
648 648
                             $dashboard_post_type = $dashboard_post_types[0];
649 649
                         }
650 650
                     }
651
-                    if ( !( !empty( $dashboard_post_type ) && in_array( $dashboard_post_type, $post_types ) ) ) {
651
+                    if (!(!empty($dashboard_post_type) && in_array($dashboard_post_type, $post_types))) {
652 652
                         $dashboard_post_type = $post_types[0];
653 653
                     }
654 654
                     
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 
697 697
             if (is_wp_error($user)) {
698 698
                 if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'ptype=property_submit') && $_POST['log'] != '' && $_POST['pwd'] != '') {
699
-                    wp_redirect($_SERVER['HTTP_REFERER'] . '&emsg=1');
699
+                    wp_redirect($_SERVER['HTTP_REFERER'].'&emsg=1');
700 700
                 }
701 701
             }
702 702
             if (!is_wp_error($user)) {
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 
725 725
             // Some parts of this script use the main login form to display a message
726 726
             if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
727
-                $successmsg = '<div class="sucess_msg">' . YOU_ARE_LOGED_OUT_MSG . '</div>';
727
+                $successmsg = '<div class="sucess_msg">'.YOU_ARE_LOGED_OUT_MSG.'</div>';
728 728
             } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
729 729
                 $successmsg = USER_REG_NOT_ALLOW_MSG;
730 730
             } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
@@ -737,9 +737,9 @@  discard block
 block discarded – undo
737 737
 
738 738
             if ((isset($_POST['log']) && $_POST['log'] != '' && $errors) || ((!isset($_POST['log']) || $_POST['log'] == '') && isset($_REQUEST['testcookie']) && $_REQUEST['testcookie'])) {
739 739
                 if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') {
740
-                    wp_redirect($_REQUEST['pagetype'] . '&emsg=1');
740
+                    wp_redirect($_REQUEST['pagetype'].'&emsg=1');
741 741
                 } else {
742
-                    wp_redirect(geodir_login_url(array('logemsg'=>'1','redirect_to'=>urlencode($_REQUEST['redirect_to']))));
742
+                    wp_redirect(geodir_login_url(array('logemsg'=>'1', 'redirect_to'=>urlencode($_REQUEST['redirect_to']))));
743 743
                 }
744 744
                 gd_die();
745 745
             }
Please login to merge, or discard this patch.