Test Failed
Push — master ( 026a78...23f747 )
by Stiofan
25:43
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.
geodirectory_hooks_actions.php 1 patch
Indentation   +1212 added lines, -1212 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  */
20 20
 function geodir_get_ajax_url()
21 21
 {
22
-    return admin_url('admin-ajax.php?action=geodir_ajax_action');
22
+	return admin_url('admin-ajax.php?action=geodir_ajax_action');
23 23
 }
24 24
 
25 25
 /////////////////////
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 add_filter('query_vars', 'geodir_add_geodir_page_var');
88 88
 add_action('wp', 'geodir_add_page_id_in_query_var'); // problem fix in wordpress 3.8
89 89
 if (get_option('permalink_structure') != '')
90
-    add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
90
+	add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
91 91
 
92 92
 add_filter('parse_query', 'geodir_modified_query');
93 93
 
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
 /* POST AND LOOP ACTIONS */
155 155
 ////////////////////////
156 156
 if (!is_admin()) {
157
-    add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtual page from everywhere
158
-    add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100);
159
-    /** Exclude Virtual Pages From Pages List **/
160
-    add_action('pre_get_posts', 'set_listing_request', 0);
161
-    add_action('pre_get_posts', 'geodir_listing_loop_filter', 1);
162
-    add_filter('excerpt_more', 'geodir_excerpt_more', 1000);
163
-    add_filter('excerpt_length', 'geodir_excerpt_length', 1000);
164
-    add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter
157
+	add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtual page from everywhere
158
+	add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100);
159
+	/** Exclude Virtual Pages From Pages List **/
160
+	add_action('pre_get_posts', 'set_listing_request', 0);
161
+	add_action('pre_get_posts', 'geodir_listing_loop_filter', 1);
162
+	add_filter('excerpt_more', 'geodir_excerpt_more', 1000);
163
+	add_filter('excerpt_length', 'geodir_excerpt_length', 1000);
164
+	add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter
165 165
 }
166 166
 
167 167
 
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
  */
224 224
 function geodir_unset_prev_theme_nav_location($newname)
225 225
 {
226
-    $geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname);
227
-    if ($geodir_theme_location) {
228
-        update_option('geodir_theme_location_nav', $geodir_theme_location);
229
-    } else {
230
-        update_option('geodir_theme_location_nav', '');
231
-    }
226
+	$geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname);
227
+	if ($geodir_theme_location) {
228
+		update_option('geodir_theme_location_nav', $geodir_theme_location);
229
+	} else {
230
+		update_option('geodir_theme_location_nav', '');
231
+	}
232 232
 }
233 233
 
234 234
 /// add action for theme switch to blank previous theme navigation location setting
@@ -249,42 +249,42 @@  discard block
 block discarded – undo
249 249
  */
250 250
 function geodir_add_post_filters()
251 251
 {
252
-    /**
253
-     * Contains all function for filtering listing.
254
-     *
255
-     * @since 1.0.0
256
-     * @package GeoDirectory
257
-     */
258
-    include_once('geodirectory-functions/listing_filters.php');
252
+	/**
253
+	 * Contains all function for filtering listing.
254
+	 *
255
+	 * @since 1.0.0
256
+	 * @package GeoDirectory
257
+	 */
258
+	include_once('geodirectory-functions/listing_filters.php');
259 259
     
260
-    // Theme My Login compatibility fix
261
-    if ( isset( $_REQUEST['geodir_search'] ) && class_exists( 'Theme_My_Login' ) ) {
262
-        remove_action( 'pre_get_posts', array( Theme_My_Login::get_object(), 'pre_get_posts' ) );
263
-    }
260
+	// Theme My Login compatibility fix
261
+	if ( isset( $_REQUEST['geodir_search'] ) && class_exists( 'Theme_My_Login' ) ) {
262
+		remove_action( 'pre_get_posts', array( Theme_My_Login::get_object(), 'pre_get_posts' ) );
263
+	}
264 264
     
265
-    if ( isset( $_REQUEST['geodir_search'] ) ) {
266
-        add_filter( 'geodir_filter_widget_listings_fields', 'geodir_search_widget_location_filter_fields', 100, 3 );
267
-        add_filter( 'geodir_filter_widget_listings_orderby', 'geodir_search_widget_location_filter_orderby', 100, 3 );
268
-    }
265
+	if ( isset( $_REQUEST['geodir_search'] ) ) {
266
+		add_filter( 'geodir_filter_widget_listings_fields', 'geodir_search_widget_location_filter_fields', 100, 3 );
267
+		add_filter( 'geodir_filter_widget_listings_orderby', 'geodir_search_widget_location_filter_orderby', 100, 3 );
268
+	}
269 269
 }
270 270
 
271 271
 
272 272
 if (!function_exists('geodir_init_defaults')) {
273
-    /**
274
-     * Calls the function to register the GeoDirectory default CPT and taxonomies.
275
-     *
276
-     * @since 1.0.0
277
-     * @package GeoDirectory
278
-     */
279
-    function geodir_init_defaults()
280
-    {
281
-        if (function_exists('geodir_register_defaults')) {
273
+	/**
274
+	 * Calls the function to register the GeoDirectory default CPT and taxonomies.
275
+	 *
276
+	 * @since 1.0.0
277
+	 * @package GeoDirectory
278
+	 */
279
+	function geodir_init_defaults()
280
+	{
281
+		if (function_exists('geodir_register_defaults')) {
282 282
 
283
-            geodir_register_defaults();
283
+			geodir_register_defaults();
284 284
 
285
-        }
285
+		}
286 286
 
287
-    }
287
+	}
288 288
 }
289 289
 
290 290
 
@@ -306,26 +306,26 @@  discard block
 block discarded – undo
306 306
 // CALLED ON 'sidebars_widgets' FILTER
307 307
 
308 308
 if (!function_exists('geodir_restrict_widget')) {
309
-    /**
310
-     * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page.
311
-     *
312
-     * @global bool $is_listing Sets the global value to true if on a GD category page. False if not.
313
-     * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not.
314
-     * @since 1.0.0
315
-     * @package GeoDirectory
316
-     */
317
-    function geodir_restrict_widget()
318
-    {
319
-        global $is_listing, $is_single_place;
309
+	/**
310
+	 * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page.
311
+	 *
312
+	 * @global bool $is_listing Sets the global value to true if on a GD category page. False if not.
313
+	 * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not.
314
+	 * @since 1.0.0
315
+	 * @package GeoDirectory
316
+	 */
317
+	function geodir_restrict_widget()
318
+	{
319
+		global $is_listing, $is_single_place;
320 320
 
321
-        // set is listing	
322
-        (geodir_is_page('listing')) ? $is_listing = true : $is_listing = false;
321
+		// set is listing	
322
+		(geodir_is_page('listing')) ? $is_listing = true : $is_listing = false;
323 323
 
324
-        // set is single place
325
-        (geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false;
324
+		// set is single place
325
+		(geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false;
326 326
 
327 327
 
328
-    }
328
+	}
329 329
 }
330 330
 
331 331
 
@@ -346,31 +346,31 @@  discard block
 block discarded – undo
346 346
  */
347 347
 function geodir_detail_page_sidebar_content_sorting()
348 348
 {
349
-    $arr_detail_page_sidebar_content =
350
-        /**
351
-         * An array of functions to be called to be displayed on the details (post) page sidebar.
352
-         *
353
-         * This filter can be used to remove sections of the details page sidebar,
354
-         * add new sections or rearrange the order of the sections.
355
-         *
356
-         * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called.
357
-         * @since 1.0.0
358
-         */
359
-        apply_filters('geodir_detail_page_sidebar_content',
360
-            array('geodir_social_sharing_buttons',
361
-                'geodir_detail_page_google_analytics',
362
-                'geodir_edit_post_link',
363
-                'geodir_detail_page_review_rating',
364
-                'geodir_detail_page_more_info'
365
-            ) // end of array 
366
-        ); // end of apply filter
367
-    if (!empty($arr_detail_page_sidebar_content)) {
368
-        foreach ($arr_detail_page_sidebar_content as $content_function) {
369
-            if (function_exists($content_function)) {
370
-                add_action('geodir_detail_page_sidebar', $content_function);
371
-            }
372
-        }
373
-    }
349
+	$arr_detail_page_sidebar_content =
350
+		/**
351
+		 * An array of functions to be called to be displayed on the details (post) page sidebar.
352
+		 *
353
+		 * This filter can be used to remove sections of the details page sidebar,
354
+		 * add new sections or rearrange the order of the sections.
355
+		 *
356
+		 * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called.
357
+		 * @since 1.0.0
358
+		 */
359
+		apply_filters('geodir_detail_page_sidebar_content',
360
+			array('geodir_social_sharing_buttons',
361
+				'geodir_detail_page_google_analytics',
362
+				'geodir_edit_post_link',
363
+				'geodir_detail_page_review_rating',
364
+				'geodir_detail_page_more_info'
365
+			) // end of array 
366
+		); // end of apply filter
367
+	if (!empty($arr_detail_page_sidebar_content)) {
368
+		foreach ($arr_detail_page_sidebar_content as $content_function) {
369
+			if (function_exists($content_function)) {
370
+				add_action('geodir_detail_page_sidebar', $content_function);
371
+			}
372
+		}
373
+	}
374 374
 }
375 375
 
376 376
 add_action('geodir_after_edit_post_link', 'geodir_add_to_favourite_link', 1);
@@ -385,14 +385,14 @@  discard block
 block discarded – undo
385 385
  */
386 386
 function geodir_add_to_favourite_link()
387 387
 {
388
-    global $post, $preview;
389
-    if (!$preview && geodir_is_page('detail')) {
390
-        ?>
388
+	global $post, $preview;
389
+	if (!$preview && geodir_is_page('detail')) {
390
+		?>
391 391
         <p class="edit_link">
392 392
             <?php geodir_favourite_html($post->post_author, $post->ID); ?>
393 393
         </p>
394 394
     <?php
395
-    }
395
+	}
396 396
 }
397 397
 
398 398
 /**
@@ -406,41 +406,41 @@  discard block
 block discarded – undo
406 406
  */
407 407
 function geodir_social_sharing_buttons()
408 408
 {
409
-    global $preview;
410
-    ob_start(); // Start  buffering;
411
-    /**
412
-     * This action is called before the social buttons twitter,facebook and google plus are output in a containing div.
413
-     *
414
-     * @since 1.0.0
415
-     */
416
-    do_action('geodir_before_social_sharing_buttons');
417
-    if (!$preview) {
418
-        ?>
409
+	global $preview;
410
+	ob_start(); // Start  buffering;
411
+	/**
412
+	 * This action is called before the social buttons twitter,facebook and google plus are output in a containing div.
413
+	 *
414
+	 * @since 1.0.0
415
+	 */
416
+	do_action('geodir_before_social_sharing_buttons');
417
+	if (!$preview) {
418
+		?>
419 419
         <div class="likethis">
420 420
             <?php geodir_twitter_tweet_button(); ?>
421 421
             <?php geodir_fb_like_button(); ?>
422 422
             <?php geodir_google_plus_button(); ?>
423 423
         </div>
424 424
     <?php
425
-    }// end of if, if its a preview or not
426
-
427
-    /**
428
-     * This action is called after the social buttons twitter,facebook and google plus are output in a containing div.
429
-     *
430
-     * @since 1.0.0
431
-     */
432
-    do_action('geodir_after_social_sharing_buttons');
433
-    $content_html = ob_get_clean();
434
-    if (trim($content_html) != '')
435
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
436
-    if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
437
-        /**
438
-         * Filter the geodir_social_sharing_buttons() function content.
439
-         *
440
-         * @param string $content_html The output html of the geodir_social_sharing_buttons() function.
441
-         */
442
-        echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html);
443
-    }
425
+	}// end of if, if its a preview or not
426
+
427
+	/**
428
+	 * This action is called after the social buttons twitter,facebook and google plus are output in a containing div.
429
+	 *
430
+	 * @since 1.0.0
431
+	 */
432
+	do_action('geodir_after_social_sharing_buttons');
433
+	$content_html = ob_get_clean();
434
+	if (trim($content_html) != '')
435
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
436
+	if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
437
+		/**
438
+		 * Filter the geodir_social_sharing_buttons() function content.
439
+		 *
440
+		 * @param string $content_html The output html of the geodir_social_sharing_buttons() function.
441
+		 */
442
+		echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html);
443
+	}
444 444
 
445 445
 
446 446
 }
@@ -458,46 +458,46 @@  discard block
 block discarded – undo
458 458
  */
459 459
 function geodir_edit_post_link()
460 460
 {
461
-    global $post, $preview;
462
-    ob_start(); // Start buffering;
463
-    /**
464
-     * This is called before the edit post link html in the function geodir_edit_post_link()
465
-     *
466
-     * @since 1.0.0
467
-     */
468
-    do_action('geodir_before_edit_post_link');
469
-    if (!$preview) {
470
-        $is_current_user_owner = geodir_listing_belong_to_current_user();
461
+	global $post, $preview;
462
+	ob_start(); // Start buffering;
463
+	/**
464
+	 * This is called before the edit post link html in the function geodir_edit_post_link()
465
+	 *
466
+	 * @since 1.0.0
467
+	 */
468
+	do_action('geodir_before_edit_post_link');
469
+	if (!$preview) {
470
+		$is_current_user_owner = geodir_listing_belong_to_current_user();
471 471
         
472
-        if ($is_current_user_owner) {
473
-            $post_id = $post->ID;
472
+		if ($is_current_user_owner) {
473
+			$post_id = $post->ID;
474 474
             
475
-            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
476
-                $post_id = (int)$_REQUEST['pid'];
477
-            }
475
+			if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
476
+				$post_id = (int)$_REQUEST['pid'];
477
+			}
478 478
 
479
-            $postlink = get_permalink(geodir_add_listing_page_id());
480
-            $editlink = geodir_getlink($postlink, array('pid' => $post_id), false);
481
-            echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>';
482
-        }
483
-    }// end of if, if its a preview or not
484
-    /**
485
-     * This is called after the edit post link html in the function geodir_edit_post_link()
486
-     *
487
-     * @since 1.0.0
488
-     */
489
-    do_action('geodir_after_edit_post_link');
490
-    $content_html = ob_get_clean();
491
-    if (trim($content_html) != '')
492
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
493
-    if ((int)get_option('geodir_disable_user_links_section') != 1) {
494
-        /**
495
-         * Filter the geodir_edit_post_link() function content.
496
-         *
497
-         * @param string $content_html The output html of the geodir_edit_post_link() function.
498
-         */
499
-        echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html);
500
-    }
479
+			$postlink = get_permalink(geodir_add_listing_page_id());
480
+			$editlink = geodir_getlink($postlink, array('pid' => $post_id), false);
481
+			echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>';
482
+		}
483
+	}// end of if, if its a preview or not
484
+	/**
485
+	 * This is called after the edit post link html in the function geodir_edit_post_link()
486
+	 *
487
+	 * @since 1.0.0
488
+	 */
489
+	do_action('geodir_after_edit_post_link');
490
+	$content_html = ob_get_clean();
491
+	if (trim($content_html) != '')
492
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
493
+	if ((int)get_option('geodir_disable_user_links_section') != 1) {
494
+		/**
495
+		 * Filter the geodir_edit_post_link() function content.
496
+		 *
497
+		 * @param string $content_html The output html of the geodir_edit_post_link() function.
498
+		 */
499
+		echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html);
500
+	}
501 501
 }
502 502
 
503 503
 /**
@@ -511,42 +511,42 @@  discard block
 block discarded – undo
511 511
  */
512 512
 function geodir_detail_page_google_analytics()
513 513
 {
514
-    global $post,$preview;
515
-    if($preview){return '';}
516
-    $package_info = array();
517
-    $package_info = geodir_post_package_info($package_info, $post);
514
+	global $post,$preview;
515
+	if($preview){return '';}
516
+	$package_info = array();
517
+	$package_info = geodir_post_package_info($package_info, $post);
518 518
 
519
-    $id = trim(get_option('geodir_ga_account_id'));
519
+	$id = trim(get_option('geodir_ga_account_id'));
520 520
 
521
-    if (!$id) {
522
-        return; //if no Google Analytics ID then bail.
523
-    }
521
+	if (!$id) {
522
+		return; //if no Google Analytics ID then bail.
523
+	}
524 524
 
525
-    ob_start(); // Start buffering;
526
-    /**
527
-     * This is called before the edit post link html in the function geodir_detail_page_google_analytics()
528
-     *
529
-     * @since 1.0.0
530
-     */
531
-    do_action('geodir_before_google_analytics');
525
+	ob_start(); // Start buffering;
526
+	/**
527
+	 * This is called before the edit post link html in the function geodir_detail_page_google_analytics()
528
+	 *
529
+	 * @since 1.0.0
530
+	 */
531
+	do_action('geodir_before_google_analytics');
532 532
     
533
-    $refresh_time = get_option('geodir_ga_refresh_time', 5);
534
-    /**
535
-     * Filter the time interval to check & refresh new users results.
536
-     *
537
-     * @since 1.5.9
538
-     *
539
-     * @param int $refresh_time Time interval to check & refresh new users results.
540
-     */
541
-    $refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time);
542
-    $refresh_time = absint($refresh_time * 1000);
533
+	$refresh_time = get_option('geodir_ga_refresh_time', 5);
534
+	/**
535
+	 * Filter the time interval to check & refresh new users results.
536
+	 *
537
+	 * @since 1.5.9
538
+	 *
539
+	 * @param int $refresh_time Time interval to check & refresh new users results.
540
+	 */
541
+	$refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time);
542
+	$refresh_time = absint($refresh_time * 1000);
543 543
     
544
-    $hide_refresh = get_option('geodir_ga_auto_refresh');
544
+	$hide_refresh = get_option('geodir_ga_auto_refresh');
545 545
     
546
-    $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0;
547
-    if (get_option('geodir_ga_stats') && is_user_logged_in() &&  (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
548
-        $page_url = urlencode($_SERVER['REQUEST_URI']);
549
-        ?>
546
+	$auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0;
547
+	if (get_option('geodir_ga_stats') && is_user_logged_in() &&  (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
548
+		$page_url = urlencode($_SERVER['REQUEST_URI']);
549
+		?>
550 550
         <script type="text/javascript">
551 551
             var gd_gaTimeOut;
552 552
             var gd_gaTime = parseInt('<?php echo $refresh_time;?>');
@@ -798,15 +798,15 @@  discard block
 block discarded – undo
798 798
                     var labels = results[1].rows.map(function(row) { return +row[0]; });
799 799
 
800 800
                     <?php
801
-                    // Here we list the shorthand days of the week so it can be used in translation.
802
-                    __("Mon",'geodirectory');
803
-                    __("Tue",'geodirectory');
804
-                    __("Wed",'geodirectory');
805
-                    __("Thu",'geodirectory');
806
-                    __("Fri",'geodirectory');
807
-                    __("Sat",'geodirectory');
808
-                    __("Sun",'geodirectory');
809
-                    ?>
801
+					// Here we list the shorthand days of the week so it can be used in translation.
802
+					__("Mon",'geodirectory');
803
+					__("Tue",'geodirectory');
804
+					__("Wed",'geodirectory');
805
+					__("Thu",'geodirectory');
806
+					__("Fri",'geodirectory');
807
+					__("Sat",'geodirectory');
808
+					__("Sun",'geodirectory');
809
+					?>
810 810
 
811 811
                     labels = [
812 812
                         "<?php _e(date('D', strtotime("+1 day")),'geodirectory'); ?>",
@@ -1055,24 +1055,24 @@  discard block
 block discarded – undo
1055 1055
         </span>
1056 1056
 
1057 1057
     <?php
1058
-    }
1059
-    /**
1060
-     * This is called after the edit post link html in the function geodir_detail_page_google_analytics()
1061
-     *
1062
-     * @since 1.0.0
1063
-     */
1064
-    do_action('geodir_after_google_analytics');
1065
-    $content_html = ob_get_clean();
1066
-    if (trim($content_html) != '')
1067
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1068
-    if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
1069
-        /**
1070
-         * Filter the geodir_edit_post_link() function content.
1071
-         *
1072
-         * @param string $content_html The output html of the geodir_edit_post_link() function.
1073
-         */
1074
-        echo $content_html = apply_filters('geodir_google_analytic_html', $content_html);
1075
-    }
1058
+	}
1059
+	/**
1060
+	 * This is called after the edit post link html in the function geodir_detail_page_google_analytics()
1061
+	 *
1062
+	 * @since 1.0.0
1063
+	 */
1064
+	do_action('geodir_after_google_analytics');
1065
+	$content_html = ob_get_clean();
1066
+	if (trim($content_html) != '')
1067
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1068
+	if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
1069
+		/**
1070
+		 * Filter the geodir_edit_post_link() function content.
1071
+		 *
1072
+		 * @param string $content_html The output html of the geodir_edit_post_link() function.
1073
+		 */
1074
+		echo $content_html = apply_filters('geodir_google_analytic_html', $content_html);
1075
+	}
1076 1076
 }
1077 1077
 
1078 1078
 /**
@@ -1089,94 +1089,94 @@  discard block
 block discarded – undo
1089 1089
  */
1090 1090
 function geodir_detail_page_review_rating()
1091 1091
 {
1092
-    global $post, $preview, $post_images;
1092
+	global $post, $preview, $post_images;
1093 1093
     
1094
-    if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) {
1095
-        return;
1096
-    }
1097
-    ob_start(); // Start  buffering;
1098
-    /**
1099
-     * This is called before the rating html in the function geodir_detail_page_review_rating().
1100
-     *
1101
-     * This is called outside the check for an actual rating and the check for preview page.
1102
-     *
1103
-     * @since 1.0.0
1104
-     */
1105
-    do_action('geodir_before_detail_page_review_rating');
1106
-
1107
-    $comment_count = geodir_get_review_count_total($post->ID);
1108
-    $post_avgratings = geodir_get_post_rating($post->ID);
1109
-
1110
-    if ($post_avgratings != 0 && !$preview) {
1111
-        /**
1112
-         * This is called before the rating html in the function geodir_detail_page_review_rating().
1113
-         *
1114
-         * This is called inside the check for an actual rating and the check for preview page.
1115
-         *
1116
-         * @since 1.0.0
1117
-         * @param float $post_avgratings Average rating for the current post.
1118
-         * @param int $post->ID Current post ID.
1119
-         */
1120
-        do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1121
-
1122
-        $html = '<p style=" float:left;">';
1123
-        $html .= geodir_get_rating_stars($post_avgratings, $post->ID);
1124
-        $html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">';
1125
-        $post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings;
1094
+	if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) {
1095
+		return;
1096
+	}
1097
+	ob_start(); // Start  buffering;
1098
+	/**
1099
+	 * This is called before the rating html in the function geodir_detail_page_review_rating().
1100
+	 *
1101
+	 * This is called outside the check for an actual rating and the check for preview page.
1102
+	 *
1103
+	 * @since 1.0.0
1104
+	 */
1105
+	do_action('geodir_before_detail_page_review_rating');
1106
+
1107
+	$comment_count = geodir_get_review_count_total($post->ID);
1108
+	$post_avgratings = geodir_get_post_rating($post->ID);
1109
+
1110
+	if ($post_avgratings != 0 && !$preview) {
1111
+		/**
1112
+		 * This is called before the rating html in the function geodir_detail_page_review_rating().
1113
+		 *
1114
+		 * This is called inside the check for an actual rating and the check for preview page.
1115
+		 *
1116
+		 * @since 1.0.0
1117
+		 * @param float $post_avgratings Average rating for the current post.
1118
+		 * @param int $post->ID Current post ID.
1119
+		 */
1120
+		do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1121
+
1122
+		$html = '<p style=" float:left;">';
1123
+		$html .= geodir_get_rating_stars($post_avgratings, $post->ID);
1124
+		$html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">';
1125
+		$post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings;
1126 1126
        
1127 1127
 	   $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory');
1128 1128
 	   
1129 1129
 	   $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />';
1130 1130
 
1131
-        $html .= '<span class="item">';
1132
-        $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>';
1131
+		$html .= '<span class="item">';
1132
+		$html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>';
1133 1133
 
1134
-        if ($post_images) {
1135
-            foreach ($post_images as $img) {
1136
-                $post_img = $img->src;
1137
-                break;
1138
-            }
1139
-        }
1140
-
1141
-        if (isset($post_img) && $post_img) {
1142
-            $html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />';
1143
-        }
1144
-
1145
-        $html .= '</span>';
1146
-
1147
-        echo $html .= '</div>';
1148
-        /**
1149
-         * This is called after the rating html in the function geodir_detail_page_review_rating().
1150
-         *
1151
-         * This is called inside the check for an actual rating and the check for preview page.
1152
-         *
1153
-         * @since 1.0.0
1154
-         * @param float $post_avgratings Average rating for the current post.
1155
-         * @param int $post->ID Current post ID.
1156
-         */
1157
-        do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1158
-    }
1159
-    /**
1160
-     * This is called before the rating html in the function geodir_detail_page_review_rating().
1161
-     *
1162
-     * This is called outside the check for an actual rating and the check for preview page.
1163
-     *
1164
-     * @since 1.0.0
1165
-     */
1166
-    do_action('geodir_after_detail_page_review_rating');
1167
-    $content_html = ob_get_clean();
1168
-    if (trim($content_html) != '') {
1169
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>';
1170
-    }
1171
-    if ((int)get_option('geodir_disable_rating_info_section') != 1) {
1172
-        /**
1173
-         * Filter the geodir_detail_page_review_rating() function content.
1174
-         *
1175
-         * @since 1.0.0
1176
-         * @param string $content_html The output html of the geodir_detail_page_review_rating() function.
1177
-         */
1178
-        echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html);
1179
-    }
1134
+		if ($post_images) {
1135
+			foreach ($post_images as $img) {
1136
+				$post_img = $img->src;
1137
+				break;
1138
+			}
1139
+		}
1140
+
1141
+		if (isset($post_img) && $post_img) {
1142
+			$html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />';
1143
+		}
1144
+
1145
+		$html .= '</span>';
1146
+
1147
+		echo $html .= '</div>';
1148
+		/**
1149
+		 * This is called after the rating html in the function geodir_detail_page_review_rating().
1150
+		 *
1151
+		 * This is called inside the check for an actual rating and the check for preview page.
1152
+		 *
1153
+		 * @since 1.0.0
1154
+		 * @param float $post_avgratings Average rating for the current post.
1155
+		 * @param int $post->ID Current post ID.
1156
+		 */
1157
+		do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1158
+	}
1159
+	/**
1160
+	 * This is called before the rating html in the function geodir_detail_page_review_rating().
1161
+	 *
1162
+	 * This is called outside the check for an actual rating and the check for preview page.
1163
+	 *
1164
+	 * @since 1.0.0
1165
+	 */
1166
+	do_action('geodir_after_detail_page_review_rating');
1167
+	$content_html = ob_get_clean();
1168
+	if (trim($content_html) != '') {
1169
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>';
1170
+	}
1171
+	if ((int)get_option('geodir_disable_rating_info_section') != 1) {
1172
+		/**
1173
+		 * Filter the geodir_detail_page_review_rating() function content.
1174
+		 *
1175
+		 * @since 1.0.0
1176
+		 * @param string $content_html The output html of the geodir_detail_page_review_rating() function.
1177
+		 */
1178
+		echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html);
1179
+	}
1180 1180
 }
1181 1181
 
1182 1182
 /**
@@ -1188,35 +1188,35 @@  discard block
 block discarded – undo
1188 1188
  */
1189 1189
 function geodir_detail_page_more_info()
1190 1190
 {
1191
-    ob_start(); // Start  buffering;
1192
-    /**
1193
-     * This is called before the info section html.
1194
-     *
1195
-     * @since 1.0.0
1196
-     */
1197
-    do_action('geodir_before_detail_page_more_info');
1198
-    if ($geodir_post_detail_fields = geodir_show_listing_info('detail')) {
1199
-        echo $geodir_post_detail_fields;
1200
-    }
1201
-    /**
1202
-     * This is called after the info section html.
1203
-     *
1204
-     * @since 1.0.0
1205
-     */
1206
-    do_action('geodir_after_detail_page_more_info');
1207
-
1208
-    $content_html = ob_get_clean();
1209
-    if (trim($content_html) != '')
1210
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1211
-    if ((int)get_option('geodir_disable_listing_info_section') != 1) {
1212
-        /**
1213
-         * Filter the output html for function geodir_detail_page_more_info().
1214
-         *
1215
-         * @since 1.0.0
1216
-         * @param string $content_html The output html of the geodir_detail_page_more_info() function.
1217
-         */
1218
-        echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html);
1219
-    }
1191
+	ob_start(); // Start  buffering;
1192
+	/**
1193
+	 * This is called before the info section html.
1194
+	 *
1195
+	 * @since 1.0.0
1196
+	 */
1197
+	do_action('geodir_before_detail_page_more_info');
1198
+	if ($geodir_post_detail_fields = geodir_show_listing_info('detail')) {
1199
+		echo $geodir_post_detail_fields;
1200
+	}
1201
+	/**
1202
+	 * This is called after the info section html.
1203
+	 *
1204
+	 * @since 1.0.0
1205
+	 */
1206
+	do_action('geodir_after_detail_page_more_info');
1207
+
1208
+	$content_html = ob_get_clean();
1209
+	if (trim($content_html) != '')
1210
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1211
+	if ((int)get_option('geodir_disable_listing_info_section') != 1) {
1212
+		/**
1213
+		 * Filter the output html for function geodir_detail_page_more_info().
1214
+		 *
1215
+		 * @since 1.0.0
1216
+		 * @param string $content_html The output html of the geodir_detail_page_more_info() function.
1217
+		 */
1218
+		echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html);
1219
+	}
1220 1220
 }
1221 1221
 
1222 1222
 
@@ -1230,15 +1230,15 @@  discard block
 block discarded – undo
1230 1230
  */
1231 1231
 function geodir_localize_all_js_msg()
1232 1232
 {// check_ajax_referer function is used to make sure no files are uploaded remotely but it will fail if used between https and non https so we do the check below of the urls
1233
-    if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1234
-        $ajax_url = admin_url('admin-ajax.php');
1235
-    } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1236
-        $ajax_url = admin_url('admin-ajax.php');
1237
-    } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1238
-        $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
1239
-    } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1240
-        $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
1241
-    }
1233
+	if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1234
+		$ajax_url = admin_url('admin-ajax.php');
1235
+	} elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1236
+		$ajax_url = admin_url('admin-ajax.php');
1237
+	} elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1238
+		$ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
1239
+	} elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1240
+		$ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
1241
+	}
1242 1242
 	
1243 1243
 	/**
1244 1244
 	 * Filter the allowed image type extensions for post images.
@@ -1248,62 +1248,62 @@  discard block
 block discarded – undo
1248 1248
 	 */
1249 1249
 	$allowed_img_types = apply_filters('geodir_allowed_post_image_exts', array('jpg', 'jpeg', 'jpe', 'gif', 'png'));
1250 1250
 	
1251
-    $default_marker_icon = get_option('geodir_default_marker_icon');
1252
-    $default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34));
1253
-    $default_marker_width = $default_marker_size['w'];
1254
-    $default_marker_height = $default_marker_size['h'];
1251
+	$default_marker_icon = get_option('geodir_default_marker_icon');
1252
+	$default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34));
1253
+	$default_marker_width = $default_marker_size['w'];
1254
+	$default_marker_height = $default_marker_size['h'];
1255 1255
     
1256
-    $arr_alert_msg = array(
1257
-        'geodir_plugin_url' => geodir_plugin_url(),
1258
-        'geodir_admin_ajax_url' => $ajax_url,
1259
-        'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'),
1260
-        'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'),
1261
-        'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'),
1262
-        'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'),
1263
-        //start not show alert msg
1264
-        'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'),
1265
-        'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'),
1266
-        'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'),
1267
-        'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'),
1268
-        'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'),
1269
-        // end not show alert msg
1270
-        'my_place_listing_del' => __('Are you sure you wish to delete this listing?', 'geodirectory'),
1271
-        'my_main_listing_del' => __('Deleting the main listing of a franchise will turn all franchises in regular listings. Are you sure wish to delete this main listing?', 'geodirectory'),
1272
-        //start not show alert msg
1273
-        'rating_error_msg' => __('Error : please retry', 'geodirectory'),
1274
-        'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'),
1275
-        'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'),
1276
-        'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'),
1277
-        'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'),
1278
-        'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'),
1279
-        'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'),
1280
-        'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'),
1281
-        'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'),
1282
-        'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'),
1283
-        'geodir_field_id_required' => __('This field is required.', 'geodirectory'),
1284
-        'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'),
1285
-        'geodir_default_marker_icon' => $default_marker_icon,
1286
-        'geodir_default_marker_w' => $default_marker_width,
1287
-        'geodir_default_marker_h' => $default_marker_height,
1288
-        'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG,
1289
-        'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG,
1290
-        'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'),
1291
-        'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'),
1292
-        'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'),
1293
-        'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'),
1294
-        'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'),
1295
-        'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'),
1296
-        'err_empty_review' => __('Please type a review.', 'geodirectory'),
1297
-        'err_empty_reply' => __('Please type a reply.', 'geodirectory'),
1298
-        /* on/off dragging for phone devices */
1299
-        'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false,
1300
-        'geodir_is_mobile' => wp_is_mobile() ? true : false,
1301
-        'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'),
1302
-        'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'),
1303
-        'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'),
1304
-        'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'),
1305
-        'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'),
1306
-        'geodir_action_remove' => __('Remove', 'geodirectory'),
1256
+	$arr_alert_msg = array(
1257
+		'geodir_plugin_url' => geodir_plugin_url(),
1258
+		'geodir_admin_ajax_url' => $ajax_url,
1259
+		'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'),
1260
+		'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'),
1261
+		'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'),
1262
+		'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'),
1263
+		//start not show alert msg
1264
+		'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'),
1265
+		'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'),
1266
+		'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'),
1267
+		'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'),
1268
+		'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'),
1269
+		// end not show alert msg
1270
+		'my_place_listing_del' => __('Are you sure you wish to delete this listing?', 'geodirectory'),
1271
+		'my_main_listing_del' => __('Deleting the main listing of a franchise will turn all franchises in regular listings. Are you sure wish to delete this main listing?', 'geodirectory'),
1272
+		//start not show alert msg
1273
+		'rating_error_msg' => __('Error : please retry', 'geodirectory'),
1274
+		'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'),
1275
+		'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'),
1276
+		'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'),
1277
+		'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'),
1278
+		'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'),
1279
+		'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'),
1280
+		'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'),
1281
+		'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'),
1282
+		'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'),
1283
+		'geodir_field_id_required' => __('This field is required.', 'geodirectory'),
1284
+		'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'),
1285
+		'geodir_default_marker_icon' => $default_marker_icon,
1286
+		'geodir_default_marker_w' => $default_marker_width,
1287
+		'geodir_default_marker_h' => $default_marker_height,
1288
+		'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG,
1289
+		'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG,
1290
+		'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'),
1291
+		'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'),
1292
+		'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'),
1293
+		'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'),
1294
+		'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'),
1295
+		'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'),
1296
+		'err_empty_review' => __('Please type a review.', 'geodirectory'),
1297
+		'err_empty_reply' => __('Please type a reply.', 'geodirectory'),
1298
+		/* on/off dragging for phone devices */
1299
+		'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false,
1300
+		'geodir_is_mobile' => wp_is_mobile() ? true : false,
1301
+		'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'),
1302
+		'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'),
1303
+		'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'),
1304
+		'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'),
1305
+		'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'),
1306
+		'geodir_action_remove' => __('Remove', 'geodirectory'),
1307 1307
 		'geodir_txt_all_files' => __('Allowed files', 'geodirectory'),
1308 1308
 		'geodir_err_file_type' => __('File type error. Allowed file types: %s', 'geodirectory'),
1309 1309
 		'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '',
@@ -1311,40 +1311,40 @@  discard block
 block discarded – undo
1311 1311
 		'geodir_txt_form_searching' => __('Searching...', 'geodirectory'),
1312 1312
 		'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '',
1313 1313
 		'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '',
1314
-        'multirating' => defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_rating') ? true : false,
1315
-        'geodir_map_name' => geodir_map_name(),
1316
-        'osmStart' => __('Start', 'geodirectory'),
1317
-        'osmVia' => __('Via {viaNumber}', 'geodirectory'),
1318
-        'osmEnd' => __('Enter Your Location', 'geodirectory'),
1319
-        'ga_delete_check' => __('Do you wish to Deauthorize and break Analytics?', 'geodirectory'),
1320
-        'geoMyLocation' => __('My Location', 'geodirectory'),
1321
-        'geoErrUNKNOWN_ERROR' => addslashes(__('Unable to find your location', 'geodirectory')),
1322
-        'geoErrPERMISSION_DENINED' => addslashes(__('Permission denied in finding your location', 'geodirectory')),
1323
-        'geoErrPOSITION_UNAVAILABLE' => addslashes(__('Your location is currently unknown', 'geodirectory')),
1324
-        'geoErrBREAK' => addslashes(__('Attempt to find location took too long', 'geodirectory')),
1325
-        'geoErrDEFAULT' => addslashes(__('Location detection not supported in browser', 'geodirectory')),
1326
-    );
1327
-
1328
-    /**
1329
-     * Filters the translated JS strings from function geodir_localize_all_js_msg().
1330
-     *
1331
-     * With this filter you can add, remove or change translated JS strings.
1332
-     * You should add your own translations to this if you are building an addon rather than adding another script block.
1333
-     *
1334
-     * @since 1.0.0
1335
-     */
1336
-    $arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg);
1337
-
1338
-    foreach ($arr_alert_msg as $key => $value) {
1339
-        if (!is_scalar($value))
1340
-            continue;
1341
-        $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
1342
-    }
1314
+		'multirating' => defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_rating') ? true : false,
1315
+		'geodir_map_name' => geodir_map_name(),
1316
+		'osmStart' => __('Start', 'geodirectory'),
1317
+		'osmVia' => __('Via {viaNumber}', 'geodirectory'),
1318
+		'osmEnd' => __('Enter Your Location', 'geodirectory'),
1319
+		'ga_delete_check' => __('Do you wish to Deauthorize and break Analytics?', 'geodirectory'),
1320
+		'geoMyLocation' => __('My Location', 'geodirectory'),
1321
+		'geoErrUNKNOWN_ERROR' => addslashes(__('Unable to find your location', 'geodirectory')),
1322
+		'geoErrPERMISSION_DENINED' => addslashes(__('Permission denied in finding your location', 'geodirectory')),
1323
+		'geoErrPOSITION_UNAVAILABLE' => addslashes(__('Your location is currently unknown', 'geodirectory')),
1324
+		'geoErrBREAK' => addslashes(__('Attempt to find location took too long', 'geodirectory')),
1325
+		'geoErrDEFAULT' => addslashes(__('Location detection not supported in browser', 'geodirectory')),
1326
+	);
1327
+
1328
+	/**
1329
+	 * Filters the translated JS strings from function geodir_localize_all_js_msg().
1330
+	 *
1331
+	 * With this filter you can add, remove or change translated JS strings.
1332
+	 * You should add your own translations to this if you are building an addon rather than adding another script block.
1333
+	 *
1334
+	 * @since 1.0.0
1335
+	 */
1336
+	$arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg);
1343 1337
 
1344
-    $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';';
1345
-    echo '<script>';
1346
-    echo $script;
1347
-    echo '</script>';
1338
+	foreach ($arr_alert_msg as $key => $value) {
1339
+		if (!is_scalar($value))
1340
+			continue;
1341
+		$arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
1342
+	}
1343
+
1344
+	$script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';';
1345
+	echo '<script>';
1346
+	echo $script;
1347
+	echo '</script>';
1348 1348
 }
1349 1349
 
1350 1350
 add_action('admin_bar_menu', 'geodir_admin_bar_site_menu', 31);
@@ -1360,11 +1360,11 @@  discard block
 block discarded – undo
1360 1360
  */
1361 1361
 function geodir_admin_bar_site_menu($wp_admin_bar)
1362 1362
 {
1363
-    if (get_option("geodir_installed")) {
1364
-        if (current_user_can('manage_options')) {
1365
-            $wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory')));
1366
-        }
1367
-    }
1363
+	if (get_option("geodir_installed")) {
1364
+		if (current_user_can('manage_options')) {
1365
+			$wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory')));
1366
+		}
1367
+	}
1368 1368
 }
1369 1369
 
1370 1370
 add_action('geodir_before_listing', 'geodir_display_sort_options'); /*function in custom_functions.php*/
@@ -1390,25 +1390,25 @@  discard block
 block discarded – undo
1390 1390
  */
1391 1391
 function geodir_store_sidebars()
1392 1392
 {
1393
-    global $geodir_sidebars;
1394
-    global $sidebars_widgets;
1395
-
1396
-    if (!is_array($sidebars_widgets))
1397
-        $sidebars_widgets = wp_get_sidebars_widgets();
1398
-    $geodir_old_sidebars = array();
1399
-
1400
-    if (is_array($geodir_sidebars)) {
1401
-        foreach ($geodir_sidebars as $val) {
1402
-            if (is_array($sidebars_widgets)) {
1403
-                if (array_key_exists($val, $sidebars_widgets))
1404
-                    $geodir_old_sidebars[$val] = $sidebars_widgets[$val];
1405
-                else
1406
-                    $geodir_old_sidebars[$val] = array();
1407
-            }
1408
-        }
1409
-    }
1410
-    update_option('geodir_sidebars', $geodir_old_sidebars);
1411
-    geodir_option_version_backup('geodir_sidebars');
1393
+	global $geodir_sidebars;
1394
+	global $sidebars_widgets;
1395
+
1396
+	if (!is_array($sidebars_widgets))
1397
+		$sidebars_widgets = wp_get_sidebars_widgets();
1398
+	$geodir_old_sidebars = array();
1399
+
1400
+	if (is_array($geodir_sidebars)) {
1401
+		foreach ($geodir_sidebars as $val) {
1402
+			if (is_array($sidebars_widgets)) {
1403
+				if (array_key_exists($val, $sidebars_widgets))
1404
+					$geodir_old_sidebars[$val] = $sidebars_widgets[$val];
1405
+				else
1406
+					$geodir_old_sidebars[$val] = array();
1407
+			}
1408
+		}
1409
+	}
1410
+	update_option('geodir_sidebars', $geodir_old_sidebars);
1411
+	geodir_option_version_backup('geodir_sidebars');
1412 1412
 
1413 1413
 }
1414 1414
 
@@ -1422,28 +1422,28 @@  discard block
 block discarded – undo
1422 1422
  */
1423 1423
 function geodir_restore_sidebars()
1424 1424
 {
1425
-    global $sidebars_widgets;
1426
-
1427
-    if (!is_array($sidebars_widgets))
1428
-        $sidebars_widgets = wp_get_sidebars_widgets();
1429
-
1430
-    if (is_array($sidebars_widgets)) {
1431
-        $geodir_old_sidebars = get_option('geodir_sidebars');
1432
-        if (is_array($geodir_old_sidebars)) {
1433
-            foreach ($geodir_old_sidebars as $key => $val) {
1434
-                if(0 === strpos($key, 'geodir_'))// if gd widget
1435
-                {
1436
-                    $sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1437
-                }
1425
+	global $sidebars_widgets;
1438 1426
 
1427
+	if (!is_array($sidebars_widgets))
1428
+		$sidebars_widgets = wp_get_sidebars_widgets();
1439 1429
 
1440
-            }
1441
-        }
1430
+	if (is_array($sidebars_widgets)) {
1431
+		$geodir_old_sidebars = get_option('geodir_sidebars');
1432
+		if (is_array($geodir_old_sidebars)) {
1433
+			foreach ($geodir_old_sidebars as $key => $val) {
1434
+				if(0 === strpos($key, 'geodir_'))// if gd widget
1435
+				{
1436
+					$sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1437
+				}
1442 1438
 
1443
-    }
1444 1439
 
1445
-    update_option('sidebars_widgets', $sidebars_widgets);
1446
-    update_option('geodir_sidebars', '');
1440
+			}
1441
+		}
1442
+
1443
+	}
1444
+
1445
+	update_option('sidebars_widgets', $sidebars_widgets);
1446
+	update_option('geodir_sidebars', '');
1447 1447
 }
1448 1448
 
1449 1449
 add_action('geodir_after_listing_post_gridview', 'geodir_after_listing_post_gridview');
@@ -1456,9 +1456,9 @@  discard block
 block discarded – undo
1456 1456
  */
1457 1457
 function geodir_after_listing_post_gridview()
1458 1458
 {
1459
-    global $gridview_columns;
1459
+	global $gridview_columns;
1460 1460
 
1461
-    $gridview_columns = '';
1461
+	$gridview_columns = '';
1462 1462
 
1463 1463
 }
1464 1464
 
@@ -1486,11 +1486,11 @@  discard block
 block discarded – undo
1486 1486
  */
1487 1487
 function so_handle_038($url, $original_url, $_context)
1488 1488
 {
1489
-    if (strstr($url, "maps.google.com/maps/api/js") !== false) {
1490
-        $url = str_replace("&#038;", "&amp;", $url); // or $url = $original_url
1491
-    }
1489
+	if (strstr($url, "maps.google.com/maps/api/js") !== false) {
1490
+		$url = str_replace("&#038;", "&amp;", $url); // or $url = $original_url
1491
+	}
1492 1492
 
1493
-    return $url;
1493
+	return $url;
1494 1494
 }
1495 1495
 
1496 1496
 
@@ -1506,34 +1506,34 @@  discard block
 block discarded – undo
1506 1506
 function geodir_after_main_form_fields() {
1507 1507
 	global $gd_session;
1508 1508
 	
1509
-    if (get_option('geodir_accept_term_condition')) {
1510
-        global $post;
1511
-        $term_condition = '';
1512
-        if (isset($_REQUEST['backandedit'])) {
1513
-            $post = (object)$gd_session->get('listing');
1514
-            $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : '';
1515
-        }
1516
-
1517
-        ?>
1509
+	if (get_option('geodir_accept_term_condition')) {
1510
+		global $post;
1511
+		$term_condition = '';
1512
+		if (isset($_REQUEST['backandedit'])) {
1513
+			$post = (object)$gd_session->get('listing');
1514
+			$term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : '';
1515
+		}
1516
+
1517
+		?>
1518 1518
         <div id="geodir_accept_term_condition_row" class="required_field geodir_form_row clearfix">
1519 1519
             <label>&nbsp;</label>
1520 1520
 
1521 1521
             <div class="geodir_taxonomy_field" style="float:left; width:70%;">
1522 1522
 				<span style="display:block"> 
1523 1523
 				<input class="main_list_selecter" type="checkbox" <?php if ($term_condition == '1') {
1524
-                    echo 'checked="checked"';
1525
-                } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition"
1524
+					echo 'checked="checked"';
1525
+				} ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition"
1526 1526
                        class="geodir_textfield" value="1"
1527 1527
                        style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if($terms_page){ echo get_permalink($terms_page);}?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a>
1528 1528
 				</span>
1529 1529
             </div>
1530 1530
             <span class="geodir_message_error"><?php if (isset($required_msg)) {
1531
-                    _e($required_msg, 'geodirectory');
1532
-                } ?></span>
1531
+					_e($required_msg, 'geodirectory');
1532
+				} ?></span>
1533 1533
         </div>
1534 1534
     <?php
1535 1535
 
1536
-    }
1536
+	}
1537 1537
 }
1538 1538
 
1539 1539
 
@@ -1558,42 +1558,42 @@  discard block
 block discarded – undo
1558 1558
  */
1559 1559
 function geodir_detail_page_tab_is_display($is_display, $tab)
1560 1560
 {
1561
-    global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1561
+	global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1562 1562
 
1563
-    if ($tab == 'post_profile') {
1564
-        /** This action is documented in geodirectory_template_actions.php */
1565
-        $desc_limit = apply_filters('geodir_description_field_desc_limit', '');
1563
+	if ($tab == 'post_profile') {
1564
+		/** This action is documented in geodirectory_template_actions.php */
1565
+		$desc_limit = apply_filters('geodir_description_field_desc_limit', '');
1566 1566
         
1567
-        if (!($desc_limit === '' || (int)$desc_limit > 0)) {
1568
-            $is_display = false;
1569
-        }
1570
-    }
1567
+		if (!($desc_limit === '' || (int)$desc_limit > 0)) {
1568
+			$is_display = false;
1569
+		}
1570
+	}
1571 1571
     
1572
-    if ($tab == 'post_info')
1573
-        $is_display = (!empty($geodir_post_detail_fields)) ? true : false;
1572
+	if ($tab == 'post_info')
1573
+		$is_display = (!empty($geodir_post_detail_fields)) ? true : false;
1574 1574
     
1575
-    if ($tab == 'post_images')
1576
-        $is_display = (!empty($post_images)) ? true : false;
1575
+	if ($tab == 'post_images')
1576
+		$is_display = (!empty($post_images)) ? true : false;
1577 1577
 
1578
-    if ($tab == 'post_video')
1579
-        $is_display = (!empty($video)) ? true : false;
1578
+	if ($tab == 'post_video')
1579
+		$is_display = (!empty($video)) ? true : false;
1580 1580
 
1581
-    if ($tab == 'special_offers')
1582
-        $is_display = (!empty($special_offers)) ? true : false;
1581
+	if ($tab == 'special_offers')
1582
+		$is_display = (!empty($special_offers)) ? true : false;
1583 1583
 
1584
-    if ($tab == 'reviews')
1585
-        $is_display = (geodir_is_page('detail')) ? true : false;
1584
+	if ($tab == 'reviews')
1585
+		$is_display = (geodir_is_page('detail')) ? true : false;
1586 1586
 
1587
-    if ($tab == 'related_listing') {
1588
-       $message = __('No listings found which match your selection.', 'geodirectory');
1587
+	if ($tab == 'related_listing') {
1588
+	   $message = __('No listings found which match your selection.', 'geodirectory');
1589 1589
        
1590
-       /** This action is documented in geodirectory-functions/template_functions.php */
1591
-       $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false);
1590
+	   /** This action is documented in geodirectory-functions/template_functions.php */
1591
+	   $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false);
1592 1592
        
1593
-       $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true;
1594
-    }
1593
+	   $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true;
1594
+	}
1595 1595
 
1596
-    return $is_display;
1596
+	return $is_display;
1597 1597
 }
1598 1598
 
1599 1599
 
@@ -1609,69 +1609,69 @@  discard block
 block discarded – undo
1609 1609
  * @global string $plugin_prefix Geodirectory plugin table prefix.
1610 1610
  */
1611 1611
 function geodir_changes_in_custom_fields_table() {
1612
-    global $wpdb, $plugin_prefix;
1612
+	global $wpdb, $plugin_prefix;
1613 1613
 	
1614 1614
 	// Remove unused virtual page
1615 1615
 	$listings_page_id = (int)get_option('geodir_listing_page');
1616 1616
 	if ($listings_page_id) {
1617 1617
 		$wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page')));
1618
-        delete_option('geodir_listing_page');
1618
+		delete_option('geodir_listing_page');
1619 1619
 	}
1620 1620
 
1621
-    if (!get_option('geodir_changes_in_custom_fields_table')) {
1622
-        $wpdb->query(
1623
-            $wpdb->prepare(
1624
-                "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s",
1625
-                array('1', '1', 'admin')
1626
-            )
1627
-        );
1621
+	if (!get_option('geodir_changes_in_custom_fields_table')) {
1622
+		$wpdb->query(
1623
+			$wpdb->prepare(
1624
+				"UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s",
1625
+				array('1', '1', 'admin')
1626
+			)
1627
+		);
1628 1628
 
1629 1629
 
1630
-        /* --- terms meta value set --- */
1630
+		/* --- terms meta value set --- */
1631 1631
 
1632
-        update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png');
1632
+		update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png');
1633 1633
 
1634
-        $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%')));
1634
+		$options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%')));
1635 1635
 
1636
-        if (!empty($options_data)) {
1636
+		if (!empty($options_data)) {
1637 1637
 
1638
-            foreach ($options_data as $optobj) {
1638
+			foreach ($options_data as $optobj) {
1639 1639
 
1640
-                $option_val = str_replace('tax_meta_', '', $optobj->option_name);
1640
+				$option_val = str_replace('tax_meta_', '', $optobj->option_name);
1641 1641
 
1642
-                $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
1642
+				$taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
1643 1643
 
1644
-                if (!empty($taxonomies_data)) {
1644
+				if (!empty($taxonomies_data)) {
1645 1645
 
1646
-                    foreach ($taxonomies_data as $taxobj) {
1646
+					foreach ($taxonomies_data as $taxobj) {
1647 1647
 
1648
-                        $taxObject = get_taxonomy($taxobj->taxonomy);
1649
-                        $post_type = $taxObject->object_type[0];
1648
+						$taxObject = get_taxonomy($taxobj->taxonomy);
1649
+						$post_type = $taxObject->object_type[0];
1650 1650
 
1651
-                        $opt_value = 'tax_meta_' . $post_type . '_' . $option_val;
1651
+						$opt_value = 'tax_meta_' . $post_type . '_' . $option_val;
1652 1652
 
1653
-                        $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val)));
1653
+						$duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val)));
1654 1654
 
1655
-                        if ($duplicate_data) {
1655
+						if ($duplicate_data) {
1656 1656
 
1657
-                            $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET	option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
1657
+							$wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET	option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
1658 1658
 
1659
-                        } else {
1659
+						} else {
1660 1660
 
1661
-                            $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
1661
+							$wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
1662 1662
 
1663
-                        }
1663
+						}
1664 1664
 
1665
-                    }
1665
+					}
1666 1666
 
1667
-                }
1667
+				}
1668 1668
 
1669
-            }
1670
-        }
1669
+			}
1670
+		}
1671 1671
 
1672
-        update_option('geodir_changes_in_custom_fields_table', '1');
1672
+		update_option('geodir_changes_in_custom_fields_table', '1');
1673 1673
 
1674
-    }
1674
+	}
1675 1675
 
1676 1676
 }
1677 1677
 
@@ -1690,24 +1690,24 @@  discard block
 block discarded – undo
1690 1690
 function geodir_location_slug_check($slug)
1691 1691
 {
1692 1692
 
1693
-    global $wpdb, $table_prefix;
1693
+	global $wpdb, $table_prefix;
1694 1694
 
1695
-    $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug)));
1695
+	$slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug)));
1696 1696
 
1697
-    if ($slug_exists) {
1697
+	if ($slug_exists) {
1698 1698
 
1699
-        $suffix = 1;
1700
-        do {
1701
-            $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1702
-            $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name)));
1703
-            $suffix++;
1704
-        } while ($location_slug_check && $suffix < 100);
1699
+		$suffix = 1;
1700
+		do {
1701
+			$alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1702
+			$location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name)));
1703
+			$suffix++;
1704
+		} while ($location_slug_check && $suffix < 100);
1705 1705
 
1706
-        $slug = $alt_location_name;
1706
+		$slug = $alt_location_name;
1707 1707
 
1708
-    }
1708
+	}
1709 1709
 
1710
-    return $slug;
1710
+	return $slug;
1711 1711
 
1712 1712
 }
1713 1713
 
@@ -1732,42 +1732,42 @@  discard block
 block discarded – undo
1732 1732
 function geodir_update_term_slug($term_id, $tt_id, $taxonomy)
1733 1733
 {
1734 1734
 
1735
-    global $wpdb, $plugin_prefix, $table_prefix;
1735
+	global $wpdb, $plugin_prefix, $table_prefix;
1736 1736
 
1737
-    $tern_data = get_term_by('id', $term_id, $taxonomy);
1737
+	$tern_data = get_term_by('id', $term_id, $taxonomy);
1738 1738
 
1739
-    $slug = $tern_data->slug;
1739
+	$slug = $tern_data->slug;
1740 1740
 
1741
-    /**
1742
-     * Filter if a term slug exists.
1743
-     *
1744
-     * @since 1.0.0
1745
-     * @package GeoDirectory
1746
-     * @param bool $bool Default: false.
1747
-     * @param string $slug The term slug.
1748
-     * @param int $term_id The term ID.
1749
-     */
1750
-    $slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id);
1741
+	/**
1742
+	 * Filter if a term slug exists.
1743
+	 *
1744
+	 * @since 1.0.0
1745
+	 * @package GeoDirectory
1746
+	 * @param bool $bool Default: false.
1747
+	 * @param string $slug The term slug.
1748
+	 * @param int $term_id The term ID.
1749
+	 */
1750
+	$slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id);
1751 1751
 
1752
-    if ($slug_exists) {
1752
+	if ($slug_exists) {
1753 1753
 
1754
-        $suffix = 1;
1755
-        do {
1756
-            $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1754
+		$suffix = 1;
1755
+		do {
1756
+			$new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1757 1757
 
1758
-            /** This action is documented in geodirectory_hooks_actions.php */
1759
-            $term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id);
1758
+			/** This action is documented in geodirectory_hooks_actions.php */
1759
+			$term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id);
1760 1760
 
1761
-            $suffix++;
1762
-        } while ($term_slug_check && $suffix < 100);
1761
+			$suffix++;
1762
+		} while ($term_slug_check && $suffix < 100);
1763 1763
 
1764
-        $slug = $new_slug;
1764
+		$slug = $new_slug;
1765 1765
 
1766
-        //wp_update_term( $term_id, $taxonomy, array('slug' => $slug) );
1766
+		//wp_update_term( $term_id, $taxonomy, array('slug' => $slug) );
1767 1767
 
1768
-        $wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
1768
+		$wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
1769 1769
 
1770
-    }
1770
+	}
1771 1771
 	
1772 1772
 	// Update tag in detail table.
1773 1773
 	$taxonomy_obj = get_taxonomy($taxonomy);
@@ -1808,21 +1808,21 @@  discard block
 block discarded – undo
1808 1808
 function geodir_term_slug_is_exists($slug_exists, $slug, $term_id)
1809 1809
 {
1810 1810
 
1811
-    global $wpdb, $table_prefix;
1811
+	global $wpdb, $table_prefix;
1812 1812
 
1813
-    $default_location = geodir_get_default_location();
1813
+	$default_location = geodir_get_default_location();
1814 1814
 
1815
-    $country_slug = $default_location->country_slug;
1816
-    $region_slug = $default_location->region_slug;
1817
-    $city_slug = $default_location->city_slug;
1815
+	$country_slug = $default_location->country_slug;
1816
+	$region_slug = $default_location->region_slug;
1817
+	$city_slug = $default_location->city_slug;
1818 1818
 
1819
-    if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug)
1820
-        return $slug_exists = true;
1819
+	if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug)
1820
+		return $slug_exists = true;
1821 1821
 
1822
-    if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1823
-        return $slug_exists = true;
1822
+	if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1823
+		return $slug_exists = true;
1824 1824
 
1825
-    return $slug_exists;
1825
+	return $slug_exists;
1826 1826
 }
1827 1827
 
1828 1828
 
@@ -1842,75 +1842,75 @@  discard block
 block discarded – undo
1842 1842
  */
1843 1843
 function geodir_custom_page_title($title = '', $sep = '')
1844 1844
 {
1845
-    global $wp;
1846
-    if ((class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) && !geodir_disable_yoast_seo_metas()) {
1847
-        return $title;
1848
-    }
1845
+	global $wp;
1846
+	if ((class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) && !geodir_disable_yoast_seo_metas()) {
1847
+		return $title;
1848
+	}
1849 1849
 
1850
-    if ($sep == '') {
1851
-        /**
1852
-         * Filter the page title separator.
1853
-         *
1854
-         * @since 1.0.0
1855
-         * @package GeoDirectory
1856
-         * @param string $sep The separator, default: `|`.
1857
-         */
1858
-        $sep = apply_filters('geodir_page_title_separator', '|');
1859
-    }
1850
+	if ($sep == '') {
1851
+		/**
1852
+		 * Filter the page title separator.
1853
+		 *
1854
+		 * @since 1.0.0
1855
+		 * @package GeoDirectory
1856
+		 * @param string $sep The separator, default: `|`.
1857
+		 */
1858
+		$sep = apply_filters('geodir_page_title_separator', '|');
1859
+	}
1860 1860
 
1861 1861
 
1862
-    $gd_page = '';
1863
-    if(geodir_is_page('home')){
1864
-        $gd_page = 'home';
1865
-        $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
1866
-    }
1867
-    elseif(geodir_is_page('detail')){
1868
-        $gd_page = 'detail';
1869
-        $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
1870
-    }
1871
-    elseif(geodir_is_page('pt')){
1872
-        $gd_page = 'pt';
1873
-        $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
1874
-    }
1875
-    elseif(geodir_is_page('listing')){
1876
-        $gd_page = 'listing';
1877
-        $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
1878
-    }
1879
-    elseif(geodir_is_page('location')){
1880
-        $gd_page = 'location';
1881
-        $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
1882
-    }
1883
-    elseif(geodir_is_page('search')){
1884
-        $gd_page = 'search';
1885
-        $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
1886
-    }
1887
-    elseif(geodir_is_page('add-listing')){
1888
-        $gd_page = 'add-listing';
1889
-        $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
1890
-    }
1891
-    elseif(geodir_is_page('author')){
1892
-        $gd_page = 'author';
1893
-        $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
1894
-    }
1895
-    elseif(geodir_is_page('login')){
1896
-        $gd_page = 'login';
1897
-        $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
1898
-    }
1899
-    elseif(geodir_is_page('listing-success')){
1900
-        $gd_page = 'listing-success';
1901
-        $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
1902
-    }
1862
+	$gd_page = '';
1863
+	if(geodir_is_page('home')){
1864
+		$gd_page = 'home';
1865
+		$title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
1866
+	}
1867
+	elseif(geodir_is_page('detail')){
1868
+		$gd_page = 'detail';
1869
+		$title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
1870
+	}
1871
+	elseif(geodir_is_page('pt')){
1872
+		$gd_page = 'pt';
1873
+		$title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
1874
+	}
1875
+	elseif(geodir_is_page('listing')){
1876
+		$gd_page = 'listing';
1877
+		$title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
1878
+	}
1879
+	elseif(geodir_is_page('location')){
1880
+		$gd_page = 'location';
1881
+		$title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
1882
+	}
1883
+	elseif(geodir_is_page('search')){
1884
+		$gd_page = 'search';
1885
+		$title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
1886
+	}
1887
+	elseif(geodir_is_page('add-listing')){
1888
+		$gd_page = 'add-listing';
1889
+		$title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
1890
+	}
1891
+	elseif(geodir_is_page('author')){
1892
+		$gd_page = 'author';
1893
+		$title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
1894
+	}
1895
+	elseif(geodir_is_page('login')){
1896
+		$gd_page = 'login';
1897
+		$title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
1898
+	}
1899
+	elseif(geodir_is_page('listing-success')){
1900
+		$gd_page = 'listing-success';
1901
+		$title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
1902
+	}
1903 1903
 
1904 1904
 
1905
-    /**
1906
-     * Filter page meta title to replace variables.
1907
-     *
1908
-     * @since 1.5.4
1909
-     * @param string $title The page title including variables.
1910
-     * @param string $gd_page The GeoDirectory page type if any.
1911
-     * @param string $sep The title separator symbol.
1912
-     */
1913
-    return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep);
1905
+	/**
1906
+	 * Filter page meta title to replace variables.
1907
+	 *
1908
+	 * @since 1.5.4
1909
+	 * @param string $title The page title including variables.
1910
+	 * @param string $gd_page The GeoDirectory page type if any.
1911
+	 * @param string $sep The title separator symbol.
1912
+	 */
1913
+	return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep);
1914 1914
 
1915 1915
 }
1916 1916
 
@@ -1926,36 +1926,36 @@  discard block
 block discarded – undo
1926 1926
 function geodir_set_post_attachment()
1927 1927
 {
1928 1928
 
1929
-    if (!get_option('geodir_set_post_attachments')) {
1929
+	if (!get_option('geodir_set_post_attachments')) {
1930 1930
 
1931
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1932
-        require_once(ABSPATH . 'wp-admin/includes/file.php');
1931
+		require_once(ABSPATH . 'wp-admin/includes/image.php');
1932
+		require_once(ABSPATH . 'wp-admin/includes/file.php');
1933 1933
 
1934
-        $all_postypes = geodir_get_posttypes();
1934
+		$all_postypes = geodir_get_posttypes();
1935 1935
 
1936
-        foreach($all_postypes as $post_type){
1937
-            $args = array(
1938
-                'posts_per_page' => -1,
1939
-                'post_type' => $post_type,
1940
-                'post_status' => 'publish');
1936
+		foreach($all_postypes as $post_type){
1937
+			$args = array(
1938
+				'posts_per_page' => -1,
1939
+				'post_type' => $post_type,
1940
+				'post_status' => 'publish');
1941 1941
 
1942
-            $posts_array = get_posts($args);
1942
+			$posts_array = get_posts($args);
1943 1943
 
1944
-            if (!empty($posts_array)) {
1944
+			if (!empty($posts_array)) {
1945 1945
 
1946
-                foreach ($posts_array as $post) {
1946
+				foreach ($posts_array as $post) {
1947 1947
 
1948
-                    geodir_set_wp_featured_image($post->ID);
1948
+					geodir_set_wp_featured_image($post->ID);
1949 1949
 
1950
-                }
1950
+				}
1951 1951
 
1952
-            }
1953
-        }
1952
+			}
1953
+		}
1954 1954
 
1955 1955
 
1956
-        update_option('geodir_set_post_attachments', '1');
1956
+		update_option('geodir_set_post_attachments', '1');
1957 1957
 
1958
-    }
1958
+	}
1959 1959
 
1960 1960
 }
1961 1961
 
@@ -1972,19 +1972,19 @@  discard block
 block discarded – undo
1972 1972
 function geodir_remove_url_seperator()
1973 1973
 {
1974 1974
 
1975
-    if (!get_option('geodir_remove_url_seperator')) {
1975
+	if (!get_option('geodir_remove_url_seperator')) {
1976 1976
 
1977
-        if (get_option('geodir_listingurl_separator'))
1978
-            delete_option('geodir_listingurl_separator');
1977
+		if (get_option('geodir_listingurl_separator'))
1978
+			delete_option('geodir_listingurl_separator');
1979 1979
 
1980
-        if (get_option('geodir_detailurl_separator'))
1981
-            delete_option('geodir_detailurl_separator');
1980
+		if (get_option('geodir_detailurl_separator'))
1981
+			delete_option('geodir_detailurl_separator');
1982 1982
 
1983
-        flush_rewrite_rules(false);
1983
+		flush_rewrite_rules(false);
1984 1984
 
1985
-        update_option('geodir_remove_url_seperator', '1');
1985
+		update_option('geodir_remove_url_seperator', '1');
1986 1986
 
1987
-    }
1987
+	}
1988 1988
 
1989 1989
 }
1990 1990
 
@@ -2000,19 +2000,19 @@  discard block
 block discarded – undo
2000 2000
  */
2001 2001
 function geodir_remove_url_seperator_form_permalink_settings($permalink_arr)
2002 2002
 {
2003
-    foreach ($permalink_arr as $key => $value) {
2003
+	foreach ($permalink_arr as $key => $value) {
2004 2004
 
2005
-        if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator')
2006
-            unset($permalink_arr[$key]);
2005
+		if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator')
2006
+			unset($permalink_arr[$key]);
2007 2007
 
2008
-    }
2008
+	}
2009 2009
 
2010
-    return $permalink_arr;
2010
+	return $permalink_arr;
2011 2011
 
2012 2012
 }
2013 2013
 
2014 2014
 if (!is_admin()) {
2015
-    add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post');
2015
+	add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post');
2016 2016
 }
2017 2017
 /**
2018 2018
  * Set status from draft to publish.
@@ -2025,16 +2025,16 @@  discard block
 block discarded – undo
2025 2025
  */
2026 2026
 function geodir_set_status_draft_to_publish_for_own_post($post)
2027 2027
 {
2028
-    $user_id = get_current_user_id();
2028
+	$user_id = get_current_user_id();
2029 2029
 
2030
-    if(!$user_id){return $post;}
2030
+	if(!$user_id){return $post;}
2031 2031
 
2032
-    $gd_post_types = geodir_get_posttypes();
2032
+	$gd_post_types = geodir_get_posttypes();
2033 2033
 
2034
-    if (!empty($post) && $post[0]->post_author == $user_id && in_array($post[0]->post_type, $gd_post_types) && !isset($_REQUEST['fl_builder'])) {
2035
-        $post[0]->post_status = 'publish';
2036
-    }
2037
-    return $post;
2034
+	if (!empty($post) && $post[0]->post_author == $user_id && in_array($post[0]->post_type, $gd_post_types) && !isset($_REQUEST['fl_builder'])) {
2035
+		$post[0]->post_status = 'publish';
2036
+	}
2037
+	return $post;
2038 2038
 }
2039 2039
 
2040 2040
 
@@ -2126,33 +2126,33 @@  discard block
 block discarded – undo
2126 2126
  */
2127 2127
 function geodir_detail_page_tab_headings_change($tabs_arr)
2128 2128
 {
2129
-    global $wpdb;
2129
+	global $wpdb;
2130 2130
 
2131
-    $post_type = geodir_get_current_posttype();
2131
+	$post_type = geodir_get_current_posttype();
2132 2132
 
2133
-    $all_postypes = geodir_get_posttypes();
2133
+	$all_postypes = geodir_get_posttypes();
2134 2134
 
2135
-    if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) {
2135
+	if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) {
2136 2136
 
2137
-        if (array_key_exists('post_video', $tabs_arr)) {
2137
+		if (array_key_exists('post_video', $tabs_arr)) {
2138 2138
 
2139
-            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2139
+			$field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2140 2140
 
2141
-            if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '')
2142
-                $tabs_arr['post_video']['heading_text'] = $field_title;
2143
-        }
2141
+			if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '')
2142
+				$tabs_arr['post_video']['heading_text'] = $field_title;
2143
+		}
2144 2144
 
2145
-        if (array_key_exists('special_offers', $tabs_arr)) {
2145
+		if (array_key_exists('special_offers', $tabs_arr)) {
2146 2146
 
2147
-            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2147
+			$field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2148 2148
 
2149
-            if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '')
2150
-                $tabs_arr['special_offers']['heading_text'] = $field_title;
2151
-        }
2149
+			if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '')
2150
+				$tabs_arr['special_offers']['heading_text'] = $field_title;
2151
+		}
2152 2152
 
2153
-    }
2153
+	}
2154 2154
 
2155
-    return $tabs_arr;
2155
+	return $tabs_arr;
2156 2156
 
2157 2157
 }
2158 2158
 
@@ -2165,10 +2165,10 @@  discard block
 block discarded – undo
2165 2165
  */
2166 2166
 function geodir_remove_template_redirect_actions()
2167 2167
 {
2168
-    if (geodir_is_page('login')){
2169
-        remove_all_actions('template_redirect');
2170
-        remove_action('init', 'avia_modify_front', 10);
2171
-    }
2168
+	if (geodir_is_page('login')){
2169
+		remove_all_actions('template_redirect');
2170
+		remove_action('init', 'avia_modify_front', 10);
2171
+	}
2172 2172
 }
2173 2173
 
2174 2174
 
@@ -2190,51 +2190,51 @@  discard block
 block discarded – undo
2190 2190
 function geodirectory_before_featured_image_delete($attachment_id)
2191 2191
 {
2192 2192
 
2193
-    global $wpdb, $plugin_prefix;
2193
+	global $wpdb, $plugin_prefix;
2194 2194
 
2195
-    $post_id = get_post_field('post_parent', $attachment_id);
2195
+	$post_id = get_post_field('post_parent', $attachment_id);
2196 2196
 
2197
-    $attachment_url = wp_get_attachment_url($attachment_id);
2197
+	$attachment_url = wp_get_attachment_url($attachment_id);
2198 2198
 
2199
-    if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) {
2199
+	if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) {
2200 2200
 
2201
-        $post_type = get_post_type($post_id);
2201
+		$post_type = get_post_type($post_id);
2202 2202
 
2203
-        $all_postypes = geodir_get_posttypes();
2203
+		$all_postypes = geodir_get_posttypes();
2204 2204
 
2205
-        if (!in_array($post_type, $all_postypes) || !is_admin())
2206
-            return false;
2205
+		if (!in_array($post_type, $all_postypes) || !is_admin())
2206
+			return false;
2207 2207
 
2208
-        $uploads = wp_upload_dir();
2208
+		$uploads = wp_upload_dir();
2209 2209
 
2210
-        $split_img_path = explode($uploads['baseurl'], $attachment_url);
2210
+		$split_img_path = explode($uploads['baseurl'], $attachment_url);
2211 2211
 
2212
-        $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
2212
+		$split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
2213 2213
 
2214
-        $wpdb->query(
2215
-            $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ",
2216
-                array($post_id, $split_img_file_path)
2217
-            )
2218
-        );
2214
+		$wpdb->query(
2215
+			$wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ",
2216
+				array($post_id, $split_img_file_path)
2217
+			)
2218
+		);
2219 2219
 
2220
-        $attachment_data = $wpdb->get_row(
2221
-            $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d",
2222
-                array($post_id)
2223
-            )
2224
-        );
2220
+		$attachment_data = $wpdb->get_row(
2221
+			$wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d",
2222
+				array($post_id)
2223
+			)
2224
+		);
2225 2225
 
2226
-        if (!empty($attachment_data)) {
2227
-            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2228
-        }
2226
+		if (!empty($attachment_data)) {
2227
+			$wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2228
+		}
2229 2229
 
2230 2230
 
2231
-        $table_name = $plugin_prefix . $post_type . '_detail';
2231
+		$table_name = $plugin_prefix . $post_type . '_detail';
2232 2232
 
2233
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id);
2233
+		$wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id);
2234 2234
 
2235
-        geodir_set_wp_featured_image($post_id);
2235
+		geodir_set_wp_featured_image($post_id);
2236 2236
 
2237
-    }
2237
+	}
2238 2238
 
2239 2239
 }
2240 2240
 
@@ -2252,79 +2252,79 @@  discard block
 block discarded – undo
2252 2252
 function geodir_temp_set_post_attachment()
2253 2253
 {
2254 2254
 
2255
-    global $wpdb, $plugin_prefix;
2255
+	global $wpdb, $plugin_prefix;
2256 2256
 
2257
-    $all_postypes = geodir_get_posttypes();
2257
+	$all_postypes = geodir_get_posttypes();
2258 2258
 
2259
-    foreach ($all_postypes as $posttype) {
2259
+	foreach ($all_postypes as $posttype) {
2260 2260
 
2261
-        $tablename = $plugin_prefix . $posttype . '_detail';
2261
+		$tablename = $plugin_prefix . $posttype . '_detail';
2262 2262
 
2263
-        $get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename);
2263
+		$get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename);
2264 2264
 
2265
-        if (!empty($get_post_data)) {
2265
+		if (!empty($get_post_data)) {
2266 2266
 
2267
-            foreach ($get_post_data as $data) {
2267
+			foreach ($get_post_data as $data) {
2268 2268
 
2269
-                $post_id = $data->post_id;
2269
+				$post_id = $data->post_id;
2270 2270
 
2271
-                $attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''");
2271
+				$attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''");
2272 2272
 
2273
-                if (!empty($attachment_data)) {
2273
+				if (!empty($attachment_data)) {
2274 2274
 
2275
-                    foreach ($attachment_data as $attach) {
2275
+					foreach ($attachment_data as $attach) {
2276 2276
 
2277
-                        $file_info = pathinfo($attach->file);
2277
+						$file_info = pathinfo($attach->file);
2278 2278
 
2279
-                        $sub_dir = '';
2280
-                        if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
2281
-                            $sub_dir = stripslashes_deep($file_info['dirname']);
2279
+						$sub_dir = '';
2280
+						if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
2281
+							$sub_dir = stripslashes_deep($file_info['dirname']);
2282 2282
 
2283
-                        $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
2284
-                        $uploads_path = $uploads['basedir'];
2283
+						$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
2284
+						$uploads_path = $uploads['basedir'];
2285 2285
 
2286
-                        $file_name = $file_info['basename'];
2286
+						$file_name = $file_info['basename'];
2287 2287
 
2288
-                        $img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name;
2288
+						$img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name;
2289 2289
 
2290
-                        if (!file_exists($img_arr['path'])) {
2290
+						if (!file_exists($img_arr['path'])) {
2291 2291
 
2292
-                            $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID);
2292
+							$wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID);
2293 2293
 
2294
-                        }
2294
+						}
2295 2295
 
2296
-                    }
2296
+					}
2297 2297
 
2298
-                    $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id");
2298
+					$attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id");
2299 2299
 
2300
-                    if (!empty($attachment_data)) {
2300
+					if (!empty($attachment_data)) {
2301 2301
 
2302
-                        if ($attachment_data->ID)
2303
-                            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2302
+						if ($attachment_data->ID)
2303
+							$wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2304 2304
 
2305
-                    } else {
2305
+					} else {
2306 2306
 
2307
-                        if (has_post_thumbnail($post_id)) {
2307
+						if (has_post_thumbnail($post_id)) {
2308 2308
 
2309
-                            $post_thumbnail_id = get_post_thumbnail_id($post_id);
2309
+							$post_thumbnail_id = get_post_thumbnail_id($post_id);
2310 2310
 
2311
-                            wp_delete_attachment($post_thumbnail_id);
2311
+							wp_delete_attachment($post_thumbnail_id);
2312 2312
 
2313
-                        }
2313
+						}
2314 2314
 
2315
-                    }
2315
+					}
2316 2316
 
2317
-                    $wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id);
2317
+					$wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id);
2318 2318
 
2319
-                    geodir_set_wp_featured_image($post_id);
2319
+					geodir_set_wp_featured_image($post_id);
2320 2320
 
2321
-                }
2321
+				}
2322 2322
 
2323
-            }
2323
+			}
2324 2324
 
2325
-        }
2325
+		}
2326 2326
 
2327
-    }
2327
+	}
2328 2328
 
2329 2329
 }
2330 2330
 
@@ -2342,9 +2342,9 @@  discard block
 block discarded – undo
2342 2342
 function geodir_default_rating_star_icon()
2343 2343
 {
2344 2344
 
2345
-    if (!get_option('geodir_default_rating_star_icon')) {
2346
-        update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png');
2347
-    }
2345
+	if (!get_option('geodir_default_rating_star_icon')) {
2346
+		update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png');
2347
+	}
2348 2348
 
2349 2349
 }
2350 2350
 
@@ -2362,25 +2362,25 @@  discard block
 block discarded – undo
2362 2362
  */
2363 2363
 function geodir_user_post_listing_count($user_id = 0)
2364 2364
 {
2365
-    global $wpdb, $plugin_prefix, $current_user;
2366
-    if(!$user_id){
2367
-        $user_id = $current_user->ID;
2368
-    }
2365
+	global $wpdb, $plugin_prefix, $current_user;
2366
+	if(!$user_id){
2367
+		$user_id = $current_user->ID;
2368
+	}
2369 2369
 
2370
-    $all_posts = get_option('geodir_listing_link_user_dashboard');
2370
+	$all_posts = get_option('geodir_listing_link_user_dashboard');
2371 2371
 
2372
-    $user_listing = array();
2373
-    if ($user_id && is_array($all_posts) && !empty($all_posts)) {
2374
-        foreach ($all_posts as $ptype) {
2375
-            $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' OR post_status = 'pending' )");
2372
+	$user_listing = array();
2373
+	if ($user_id && is_array($all_posts) && !empty($all_posts)) {
2374
+		foreach ($all_posts as $ptype) {
2375
+			$total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' OR post_status = 'pending' )");
2376 2376
 
2377
-            if ($total_posts > 0) {
2378
-                $user_listing[$ptype] = $total_posts;
2379
-            }
2380
-        }
2381
-    }
2377
+			if ($total_posts > 0) {
2378
+				$user_listing[$ptype] = $total_posts;
2379
+			}
2380
+		}
2381
+	}
2382 2382
 
2383
-    return $user_listing;
2383
+	return $user_listing;
2384 2384
 }
2385 2385
 
2386 2386
 
@@ -2400,189 +2400,189 @@  discard block
 block discarded – undo
2400 2400
  */
2401 2401
 function geodir_detail_page_custom_field_tab($tabs_arr)
2402 2402
 {
2403
-    global $post;
2404
-
2405
-    $post_type = geodir_get_current_posttype();
2406
-    $all_postypes = geodir_get_posttypes();
2407
-
2408
-    if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) {
2409
-        $package_info = array();
2410
-        $package_info = geodir_post_package_info($package_info, $post);
2411
-        $post_package_id = !empty($package_info->pid) ? $package_info->pid : '';
2412
-        $fields_location = 'owntab';
2413
-
2414
-        $custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location);
2415
-        //remove video and special offers if it is already set to show
2416
-        if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){
2417
-            $unset_video = true;
2418
-        }
2419
-
2420
-        if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){
2421
-            $unset_special_offers = true;
2422
-        }
2423
-        if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){
2424
-            foreach($custom_fields as $key => $custom_field){
2425
-                if($custom_field['name']=='geodir_video' && isset($unset_video)){
2426
-                    unset($custom_fields[$key]);
2427
-                }
2428
-                if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){
2429
-                    unset($custom_fields[$key]);
2430
-                }
2431
-            }
2432
-        }
2433
-
2434
-
2435
-        if (!empty($custom_fields)) {
2436
-            $parse_custom_fields = array();
2437
-            foreach ($custom_fields as $field) {
2438
-                $field = stripslashes_deep($field); // strip slashes
2439
-                $type = $field;
2440
-                $field_name = $field['htmlvar_name'];
2441
-                if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2442
-                    $post->{$field_name} = $_REQUEST[$field_name];
2443
-                }
2403
+	global $post;
2444 2404
 
2445
-                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false  && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2446
-                    if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2447
-                        continue;
2448
-                    }
2405
+	$post_type = geodir_get_current_posttype();
2406
+	$all_postypes = geodir_get_posttypes();
2449 2407
 
2450
-                    $parse_custom_fields[] = $field;
2451
-                }
2452
-            }
2453
-            $custom_fields = $parse_custom_fields;
2454
-        }
2455
-        //print_r($custom_fields);
2456
-        if (!empty($custom_fields)) {
2408
+	if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) {
2409
+		$package_info = array();
2410
+		$package_info = geodir_post_package_info($package_info, $post);
2411
+		$post_package_id = !empty($package_info->pid) ? $package_info->pid : '';
2412
+		$fields_location = 'owntab';
2457 2413
 
2458
-            global $field_set_start;
2414
+		$custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location);
2415
+		//remove video and special offers if it is already set to show
2416
+		if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){
2417
+			$unset_video = true;
2418
+		}
2459 2419
 
2460
-            $post = stripslashes_deep($post); // strip slashes
2461
-            
2462
-            $field_set_start = 0;
2463
-            $fieldset_count = 0;
2464
-            $fieldset = '';
2465
-            $total_fields = count($custom_fields);
2466
-            $count_field = 0;
2467
-            $fieldset_arr = array();
2468
-            $i = 0;
2469
-            $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL;
2470
-
2471
-            foreach ($custom_fields as $field) {
2472
-                $count_field++;
2473
-                $field_name = $field['htmlvar_name'];
2474
-                if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2475
-                    $post->{$field_name} = $_REQUEST[$field_name];
2476
-                }
2420
+		if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){
2421
+			$unset_special_offers = true;
2422
+		}
2423
+		if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){
2424
+			foreach($custom_fields as $key => $custom_field){
2425
+				if($custom_field['name']=='geodir_video' && isset($unset_video)){
2426
+					unset($custom_fields[$key]);
2427
+				}
2428
+				if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){
2429
+					unset($custom_fields[$key]);
2430
+				}
2431
+			}
2432
+		}
2477 2433
 
2478
-                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2479
-                    $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title'];
2480
-                    $site_title = trim($field['site_title']);
2481
-                    $type = $field;
2482
-                    $variables_array = array();
2483 2434
 
2484
-                    if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2485
-                        continue;
2486
-                    }
2435
+		if (!empty($custom_fields)) {
2436
+			$parse_custom_fields = array();
2437
+			foreach ($custom_fields as $field) {
2438
+				$field = stripslashes_deep($field); // strip slashes
2439
+				$type = $field;
2440
+				$field_name = $field['htmlvar_name'];
2441
+				if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2442
+					$post->{$field_name} = $_REQUEST[$field_name];
2443
+				}
2487 2444
 
2488
-                    if ($type['type'] != 'fieldset') {
2489
-                        $i++;
2490
-                        $variables_array['post_id'] = $post->ID;
2491
-                        $variables_array['label'] = __($type['site_title'], 'geodirectory');
2492
-                        $variables_array['value'] = isset($post->{$type['htmlvar_name']}) ? $post->{$type['htmlvar_name']} : '';
2493
-
2494
-                    }else{
2495
-                        $i = 0;
2496
-                        $fieldset_count++;
2497
-                        $field_set_start = 1;
2498
-                        $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count;
2499
-                        $fieldset_arr[$fieldset_count]['label'] = $label;
2500
-                    }
2445
+				if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false  && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2446
+					if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2447
+						continue;
2448
+					}
2501 2449
 
2450
+					$parse_custom_fields[] = $field;
2451
+				}
2452
+			}
2453
+			$custom_fields = $parse_custom_fields;
2454
+		}
2455
+		//print_r($custom_fields);
2456
+		if (!empty($custom_fields)) {
2502 2457
 
2503
-                    if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
2504
-                    $type = stripslashes_deep($type); // strip slashes
2505
-                    if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
2506
-                    $html = '';
2507
-                    $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : '';
2508
-                    if($html_var=='post'){$html_var='post_address';}
2509
-                    $field_icon = geodir_field_icon_proccess($type);
2510
-                    $filed_type = $type['type'];
2511
-
2512
-                    /**
2513
-                     * Filter the output for custom fields.
2514
-                     *
2515
-                     * Here we can remove or add new functions depending on the field type.
2516
-                     *
2517
-                     * @param string $html The html to be filtered (blank).
2518
-                     * @param string $fields_location The location the field is to be show.
2519
-                     * @param array $type The array of field values.
2520
-                     */
2521
-                    $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
2522
-
2523
-
2524
-                    /**
2525
-                     * Filter custom field output in tab.
2526
-                     *
2527
-                     * @since 1.5.6
2528
-                     *
2529
-                     * @param string $html_var The HTML variable name for the field.
2530
-                     * @param string $html Custom field unfiltered HTML.
2531
-                     * @param array $variables_array Custom field variables array.
2532
-                     */
2533
-                    $html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array);
2534
-
2535
-                    $fieldset_html = '';
2536
-                    if ($field_set_start == 1) {
2537
-                        $add_html = false;
2538
-                        if ($type['type'] == 'fieldset' && $fieldset_count > 1) {
2539
-                            if ($fieldset != '') {
2540
-                                $add_html = true;
2541
-                                $label = $fieldset_arr[$fieldset_count - 1]['label'];
2542
-                                $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name'];
2543
-                            }
2544
-                            $fieldset_html = $fieldset;
2545
-                            $fieldset = '';
2546
-                        } else {
2547
-                            $fieldset .= $html;
2548
-                            if ($total_fields == $count_field && $fieldset != '') {
2549
-                                $add_html = true;
2550
-                                $label = $fieldset_arr[$fieldset_count]['label'];
2551
-                                $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name'];
2552
-                                $fieldset_html = $fieldset;
2553
-                            }
2554
-                        }
2458
+			global $field_set_start;
2555 2459
 
2556
-                        if ($add_html) {
2557
-                            $tabs_arr[$htmlvar_name] = array(
2558
-                                'heading_text' => __($label, 'geodirectory'),
2559
-                                'is_active_tab' => false,
2560
-                                /**
2561
-                                 * Filter if a custom field should be displayed on the details page tab.
2562
-                                 *
2563
-                                 * @since 1.0.0
2564
-                                 * @param string $htmlvar_name The field HTML var name.
2565
-                                 */
2566
-                                'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name),
2567
-                                'tab_content' => '<div class="geodir-company_info field-group xxx">' . $fieldset_html . '</div>'
2568
-                            );
2569
-                        }
2570
-                    } else {
2571
-                        if ($html != '') {
2572
-                            $tabs_arr[$html_var] = array(
2573
-                                'heading_text' => __($label, 'geodirectory'),
2574
-                                'is_active_tab' => false,
2575
-                                /** This action is documented in geodirectory_hooks_actions.php */
2576
-                                'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']),
2577
-                                'tab_content' => $html
2578
-                            );
2579
-                        }
2580
-                    }
2581
-                }
2582
-            }
2583
-        }
2584
-    }
2585
-    return $tabs_arr;
2460
+			$post = stripslashes_deep($post); // strip slashes
2461
+            
2462
+			$field_set_start = 0;
2463
+			$fieldset_count = 0;
2464
+			$fieldset = '';
2465
+			$total_fields = count($custom_fields);
2466
+			$count_field = 0;
2467
+			$fieldset_arr = array();
2468
+			$i = 0;
2469
+			$geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL;
2470
+
2471
+			foreach ($custom_fields as $field) {
2472
+				$count_field++;
2473
+				$field_name = $field['htmlvar_name'];
2474
+				if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2475
+					$post->{$field_name} = $_REQUEST[$field_name];
2476
+				}
2477
+
2478
+				if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2479
+					$label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title'];
2480
+					$site_title = trim($field['site_title']);
2481
+					$type = $field;
2482
+					$variables_array = array();
2483
+
2484
+					if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2485
+						continue;
2486
+					}
2487
+
2488
+					if ($type['type'] != 'fieldset') {
2489
+						$i++;
2490
+						$variables_array['post_id'] = $post->ID;
2491
+						$variables_array['label'] = __($type['site_title'], 'geodirectory');
2492
+						$variables_array['value'] = isset($post->{$type['htmlvar_name']}) ? $post->{$type['htmlvar_name']} : '';
2493
+
2494
+					}else{
2495
+						$i = 0;
2496
+						$fieldset_count++;
2497
+						$field_set_start = 1;
2498
+						$fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count;
2499
+						$fieldset_arr[$fieldset_count]['label'] = $label;
2500
+					}
2501
+
2502
+
2503
+					if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
2504
+					$type = stripslashes_deep($type); // strip slashes
2505
+					if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
2506
+					$html = '';
2507
+					$html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : '';
2508
+					if($html_var=='post'){$html_var='post_address';}
2509
+					$field_icon = geodir_field_icon_proccess($type);
2510
+					$filed_type = $type['type'];
2511
+
2512
+					/**
2513
+					 * Filter the output for custom fields.
2514
+					 *
2515
+					 * Here we can remove or add new functions depending on the field type.
2516
+					 *
2517
+					 * @param string $html The html to be filtered (blank).
2518
+					 * @param string $fields_location The location the field is to be show.
2519
+					 * @param array $type The array of field values.
2520
+					 */
2521
+					$html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
2522
+
2523
+
2524
+					/**
2525
+					 * Filter custom field output in tab.
2526
+					 *
2527
+					 * @since 1.5.6
2528
+					 *
2529
+					 * @param string $html_var The HTML variable name for the field.
2530
+					 * @param string $html Custom field unfiltered HTML.
2531
+					 * @param array $variables_array Custom field variables array.
2532
+					 */
2533
+					$html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array);
2534
+
2535
+					$fieldset_html = '';
2536
+					if ($field_set_start == 1) {
2537
+						$add_html = false;
2538
+						if ($type['type'] == 'fieldset' && $fieldset_count > 1) {
2539
+							if ($fieldset != '') {
2540
+								$add_html = true;
2541
+								$label = $fieldset_arr[$fieldset_count - 1]['label'];
2542
+								$htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name'];
2543
+							}
2544
+							$fieldset_html = $fieldset;
2545
+							$fieldset = '';
2546
+						} else {
2547
+							$fieldset .= $html;
2548
+							if ($total_fields == $count_field && $fieldset != '') {
2549
+								$add_html = true;
2550
+								$label = $fieldset_arr[$fieldset_count]['label'];
2551
+								$htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name'];
2552
+								$fieldset_html = $fieldset;
2553
+							}
2554
+						}
2555
+
2556
+						if ($add_html) {
2557
+							$tabs_arr[$htmlvar_name] = array(
2558
+								'heading_text' => __($label, 'geodirectory'),
2559
+								'is_active_tab' => false,
2560
+								/**
2561
+								 * Filter if a custom field should be displayed on the details page tab.
2562
+								 *
2563
+								 * @since 1.0.0
2564
+								 * @param string $htmlvar_name The field HTML var name.
2565
+								 */
2566
+								'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name),
2567
+								'tab_content' => '<div class="geodir-company_info field-group xxx">' . $fieldset_html . '</div>'
2568
+							);
2569
+						}
2570
+					} else {
2571
+						if ($html != '') {
2572
+							$tabs_arr[$html_var] = array(
2573
+								'heading_text' => __($label, 'geodirectory'),
2574
+								'is_active_tab' => false,
2575
+								/** This action is documented in geodirectory_hooks_actions.php */
2576
+								'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']),
2577
+								'tab_content' => $html
2578
+							);
2579
+						}
2580
+					}
2581
+				}
2582
+			}
2583
+		}
2584
+	}
2585
+	return $tabs_arr;
2586 2586
 }
2587 2587
 
2588 2588
 /* display add listing page for wpml */
@@ -2606,41 +2606,41 @@  discard block
 block discarded – undo
2606 2606
  */
2607 2607
 function geodir_add_post_status_author_page()
2608 2608
 {
2609
-    global $wpdb, $post;
2610
-
2611
-    $html = '';
2612
-    if (get_current_user_id()) {
2613
-
2614
-        $is_author_page = apply_filters('geodir_post_status_is_author_page', geodir_is_page('author'));
2615
-        if ($is_author_page && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) {
2616
-
2617
-            // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them.
2618
-            $real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID");
2619
-            $status = "<strong>(";
2620
-            $status_icon = '<i class="fa fa-play"></i>';
2621
-            if ($real_status == 'publish') {
2622
-                $status .= __('Published', 'geodirectory');
2623
-            }elseif ($real_status == 'pending') {
2624
-                $status .= __('Awaiting Review', 'geodirectory');
2625
-            } else {
2626
-                $status .= __('Not published', 'geodirectory');
2627
-                $status_icon = '<i class="fa fa-pause"></i>';
2628
-            }
2629
-            $status .= ")</strong>";
2609
+	global $wpdb, $post;
2610
+
2611
+	$html = '';
2612
+	if (get_current_user_id()) {
2613
+
2614
+		$is_author_page = apply_filters('geodir_post_status_is_author_page', geodir_is_page('author'));
2615
+		if ($is_author_page && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) {
2616
+
2617
+			// we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them.
2618
+			$real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID");
2619
+			$status = "<strong>(";
2620
+			$status_icon = '<i class="fa fa-play"></i>';
2621
+			if ($real_status == 'publish') {
2622
+				$status .= __('Published', 'geodirectory');
2623
+			}elseif ($real_status == 'pending') {
2624
+				$status .= __('Awaiting Review', 'geodirectory');
2625
+			} else {
2626
+				$status .= __('Not published', 'geodirectory');
2627
+				$status_icon = '<i class="fa fa-pause"></i>';
2628
+			}
2629
+			$status .= ")</strong>";
2630 2630
 
2631
-            $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>';
2632
-        }
2633
-    }
2631
+			$html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>';
2632
+		}
2633
+	}
2634 2634
 
2635
-    if ($html != '') {
2636
-        /**
2637
-         * Filter the post status text on the author page.
2638
-         *
2639
-         * @since 1.0.0
2640
-         * @param string $html The HTML of the status.
2641
-         */
2642
-        echo apply_filters('geodir_filter_status_text_on_author_page', $html);
2643
-    }
2635
+	if ($html != '') {
2636
+		/**
2637
+		 * Filter the post status text on the author page.
2638
+		 *
2639
+		 * @since 1.0.0
2640
+		 * @param string $html The HTML of the status.
2641
+		 */
2642
+		echo apply_filters('geodir_filter_status_text_on_author_page', $html);
2643
+	}
2644 2644
 
2645 2645
 
2646 2646
 }
@@ -2654,9 +2654,9 @@  discard block
 block discarded – undo
2654 2654
  * @package GeoDirectory
2655 2655
  */
2656 2656
 function geodir_init_no_rating() {
2657
-    if (geodir_rating_disabled_post_types()) {
2658
-        add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2);
2659
-    }
2657
+	if (geodir_rating_disabled_post_types()) {
2658
+		add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2);
2659
+	}
2660 2660
 }
2661 2661
 
2662 2662
 /**
@@ -2670,22 +2670,22 @@  discard block
 block discarded – undo
2670 2670
  * @return array Modified sort options array.
2671 2671
  */
2672 2672
 function geodir_no_rating_get_sort_options($options, $post_type = '') {
2673
-    if (!empty($post_type) && geodir_cpt_has_rating_disabled($post_type)) {
2674
-        $new_options = array();
2673
+	if (!empty($post_type) && geodir_cpt_has_rating_disabled($post_type)) {
2674
+		$new_options = array();
2675 2675
         
2676
-        if (!empty($options)) {
2677
-            foreach ($options as $option) {
2678
-                if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') {
2679
-                    continue;
2680
-                }
2681
-                $new_options[] = $option;
2682
-            }
2676
+		if (!empty($options)) {
2677
+			foreach ($options as $option) {
2678
+				if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') {
2679
+					continue;
2680
+				}
2681
+				$new_options[] = $option;
2682
+			}
2683 2683
 
2684
-            $options = $new_options;
2685
-        }
2686
-    }
2684
+			$options = $new_options;
2685
+		}
2686
+	}
2687 2687
 
2688
-    return $options;
2688
+	return $options;
2689 2689
 }
2690 2690
 
2691 2691
 /**
@@ -2697,9 +2697,9 @@  discard block
 block discarded – undo
2697 2697
  * @return array Modified class array.
2698 2698
  */
2699 2699
 function geodir_body_class_active_map($classes = array()) {
2700
-    $classes[] = 'gd-map-' . geodir_map_name();
2700
+	$classes[] = 'gd-map-' . geodir_map_name();
2701 2701
 
2702
-    return $classes;
2702
+	return $classes;
2703 2703
 }
2704 2704
 add_filter('body_class', 'geodir_body_class_active_map', 100);
2705 2705
 
@@ -2712,9 +2712,9 @@  discard block
 block discarded – undo
2712 2712
  * @return string Modified class string.
2713 2713
  */
2714 2714
 function geodir_admin_body_class_active_map($class = '') {    
2715
-    $class .= ' gd-map-' . geodir_map_name();
2715
+	$class .= ' gd-map-' . geodir_map_name();
2716 2716
 
2717
-    return $class;
2717
+	return $class;
2718 2718
 }
2719 2719
 add_filter('admin_body_class', 'geodir_admin_body_class_active_map', 100);
2720 2720
 
@@ -2732,36 +2732,36 @@  discard block
 block discarded – undo
2732 2732
  * @return array Translation texts.
2733 2733
  */
2734 2734
 function geodir_load_gd_options_text_translation($translation_texts = array()) {
2735
-    $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array();
2736
-
2737
-    $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin');
2738
-
2739
-    /**
2740
-     * Filters the geodirectory option names that requires to add for translation.
2741
-     *
2742
-     * @since 1.5.7
2743
-     * @package GeoDirectory
2744
-     *
2745
-     * @param  array $gd_options Array of option names.
2746
-     */
2747
-    $gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options);
2748
-    $gd_options = array_unique($gd_options);
2749
-
2750
-    if (!empty($gd_options)) {
2751
-        foreach ($gd_options as $gd_option) {
2752
-            if ($gd_option != '' && $option_value = get_option($gd_option)) {
2753
-                $option_value = is_string($option_value) ? stripslashes_deep($option_value) : '';
2735
+	$translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array();
2736
+
2737
+	$gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin');
2738
+
2739
+	/**
2740
+	 * Filters the geodirectory option names that requires to add for translation.
2741
+	 *
2742
+	 * @since 1.5.7
2743
+	 * @package GeoDirectory
2744
+	 *
2745
+	 * @param  array $gd_options Array of option names.
2746
+	 */
2747
+	$gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options);
2748
+	$gd_options = array_unique($gd_options);
2749
+
2750
+	if (!empty($gd_options)) {
2751
+		foreach ($gd_options as $gd_option) {
2752
+			if ($gd_option != '' && $option_value = get_option($gd_option)) {
2753
+				$option_value = is_string($option_value) ? stripslashes_deep($option_value) : '';
2754 2754
                 
2755
-                if ($option_value != '' && !in_array($option_value, $translation_texts)) {
2756
-                    $translation_texts[] = stripslashes_deep($option_value);
2757
-                }
2758
-            }
2759
-        }
2760
-    }
2755
+				if ($option_value != '' && !in_array($option_value, $translation_texts)) {
2756
+					$translation_texts[] = stripslashes_deep($option_value);
2757
+				}
2758
+			}
2759
+		}
2760
+	}
2761 2761
 
2762
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
2762
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
2763 2763
 
2764
-    return $translation_texts;
2764
+	return $translation_texts;
2765 2765
 }
2766 2766
 
2767 2767
 add_filter('geodir_load_db_language', 'geodir_load_gd_options_text_translation');
@@ -2775,15 +2775,15 @@  discard block
 block discarded – undo
2775 2775
 
2776 2776
 add_filter('get_comments_link', 'gd_get_comments_link', 10, 2);
2777 2777
 function gd_get_comments_link($comments_link, $post_id) {
2778
-    $post_type = get_post_type($post_id);
2778
+	$post_type = get_post_type($post_id);
2779 2779
 
2780
-    $all_postypes = geodir_get_posttypes();
2781
-    if (in_array($post_type, $all_postypes)) {
2782
-        $comments_link = str_replace('#comments', '#reviews', $comments_link);
2783
-        $comments_link = str_replace('#respond', '#reviews', $comments_link);
2784
-    }
2780
+	$all_postypes = geodir_get_posttypes();
2781
+	if (in_array($post_type, $all_postypes)) {
2782
+		$comments_link = str_replace('#comments', '#reviews', $comments_link);
2783
+		$comments_link = str_replace('#respond', '#reviews', $comments_link);
2784
+	}
2785 2785
 
2786
-    return $comments_link;
2786
+	return $comments_link;
2787 2787
 }
2788 2788
 
2789 2789
 
@@ -2801,11 +2801,11 @@  discard block
 block discarded – undo
2801 2801
 function geodir_add_nav_menu_class( $args )
2802 2802
 {
2803 2803
 
2804
-        if(isset($args['menu_class'])){
2805
-            $args['menu_class'] = $args['menu_class']." gd-menu-z";
2806
-        }
2804
+		if(isset($args['menu_class'])){
2805
+			$args['menu_class'] = $args['menu_class']." gd-menu-z";
2806
+		}
2807 2807
     
2808
-    return $args;
2808
+	return $args;
2809 2809
 }
2810 2810
 
2811 2811
 add_filter( 'wp_nav_menu_args', 'geodir_add_nav_menu_class' );
@@ -2822,15 +2822,15 @@  discard block
 block discarded – undo
2822 2822
  * @return string Filtered locale ID.
2823 2823
  */
2824 2824
 function geodir_wpml_filter_locale($locale) {
2825
-    global $sitepress;
2825
+	global $sitepress;
2826 2826
     
2827
-    $post_type = !empty($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (!empty($_REQUEST['post']) ? get_post_type($_REQUEST['post']) : '');
2827
+	$post_type = !empty($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (!empty($_REQUEST['post']) ? get_post_type($_REQUEST['post']) : '');
2828 2828
     
2829
-    if (!empty($sitepress) && $sitepress->is_post_edit_screen() && $post_type && in_array($post_type, geodir_get_posttypes()) && $current_lang = $sitepress->get_current_language()) {
2830
-        $locale = $sitepress->get_locale($current_lang);
2831
-    }
2829
+	if (!empty($sitepress) && $sitepress->is_post_edit_screen() && $post_type && in_array($post_type, geodir_get_posttypes()) && $current_lang = $sitepress->get_current_language()) {
2830
+		$locale = $sitepress->get_locale($current_lang);
2831
+	}
2832 2832
     
2833
-    return $locale;
2833
+	return $locale;
2834 2834
 }
2835 2835
 
2836 2836
 /**
@@ -2840,19 +2840,19 @@  discard block
 block discarded – undo
2840 2840
  * @package GeoDirectory
2841 2841
  */
2842 2842
 function geodir_wpml_set_filter() {
2843
-    if (geodir_is_wpml()) {
2844
-        global $sitepress;
2843
+	if (geodir_is_wpml()) {
2844
+		global $sitepress;
2845 2845
         
2846
-        if ($sitepress->get_setting('sync_comments_on_duplicates')) {
2847
-            add_action('comment_post', 'gepdir_wpml_sync_comment', 100, 1);
2848
-        }
2846
+		if ($sitepress->get_setting('sync_comments_on_duplicates')) {
2847
+			add_action('comment_post', 'gepdir_wpml_sync_comment', 100, 1);
2848
+		}
2849 2849
         
2850
-        add_action('geodir_after_save_listing', 'geodir_wpml_duplicate_listing', 100, 2);
2851
-        add_action( 'geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1 );
2852
-        if (is_admin()) {
2853
-            add_filter( 'geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1 );
2854
-        }
2855
-    }
2850
+		add_action('geodir_after_save_listing', 'geodir_wpml_duplicate_listing', 100, 2);
2851
+		add_action( 'geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1 );
2852
+		if (is_admin()) {
2853
+			add_filter( 'geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1 );
2854
+		}
2855
+	}
2856 2856
 }
2857 2857
 add_filter('plugins_loaded', 'geodir_wpml_set_filter');
2858 2858
 
@@ -2865,38 +2865,38 @@  discard block
 block discarded – undo
2865 2865
  * @return array Filtered languages.
2866 2866
  */
2867 2867
 function geodir_wpml_filter_ls_languages($languages) {    
2868
-    if (geodir_is_geodir_page()) {        
2869
-        $keep_vars = array();
2868
+	if (geodir_is_geodir_page()) {        
2869
+		$keep_vars = array();
2870 2870
         
2871
-        if (geodir_is_page('add-listing')) {
2872
-            $keep_vars = array('listing_type', 'package_id');
2873
-        } else if (geodir_is_page('search')) {
2874
-            $keep_vars = array('geodir_search', 'stype', 'snear', 'set_location_type', 'set_location_val', 'sgeo_lat', 'sgeo_lon');
2875
-        } else if (geodir_is_page('author')) {
2876
-            $keep_vars = array('geodir_dashbord', 'stype', 'list');
2877
-        } else if (geodir_is_page('login')) {
2878
-            $keep_vars = array('forgot', 'signup');
2879
-        }        
2871
+		if (geodir_is_page('add-listing')) {
2872
+			$keep_vars = array('listing_type', 'package_id');
2873
+		} else if (geodir_is_page('search')) {
2874
+			$keep_vars = array('geodir_search', 'stype', 'snear', 'set_location_type', 'set_location_val', 'sgeo_lat', 'sgeo_lon');
2875
+		} else if (geodir_is_page('author')) {
2876
+			$keep_vars = array('geodir_dashbord', 'stype', 'list');
2877
+		} else if (geodir_is_page('login')) {
2878
+			$keep_vars = array('forgot', 'signup');
2879
+		}        
2880 2880
         
2881
-        if (!empty($keep_vars)) {
2882
-            foreach ( $languages as $code => $url) {
2883
-                $filter_url = $url['url'];
2881
+		if (!empty($keep_vars)) {
2882
+			foreach ( $languages as $code => $url) {
2883
+				$filter_url = $url['url'];
2884 2884
                 
2885
-                foreach ($keep_vars as $var) {
2886
-                    if (isset($_GET[$var]) && !is_array($_GET[$var])) {
2887
-                        $filter_url = remove_query_arg(array($var), $filter_url);
2888
-                        $filter_url = add_query_arg(array($var => $_GET[$var]), $filter_url);
2889
-                    }
2890
-                }
2885
+				foreach ($keep_vars as $var) {
2886
+					if (isset($_GET[$var]) && !is_array($_GET[$var])) {
2887
+						$filter_url = remove_query_arg(array($var), $filter_url);
2888
+						$filter_url = add_query_arg(array($var => $_GET[$var]), $filter_url);
2889
+					}
2890
+				}
2891 2891
                 
2892
-                if ($filter_url != $url['url']) {
2893
-                    $languages[$code]['url'] = $filter_url;
2894
-                }
2895
-            }
2896
-        }
2897
-    }
2892
+				if ($filter_url != $url['url']) {
2893
+					$languages[$code]['url'] = $filter_url;
2894
+				}
2895
+			}
2896
+		}
2897
+	}
2898 2898
 
2899
-    return $languages;
2899
+	return $languages;
2900 2900
 }
2901 2901
 add_filter( 'icl_ls_languages', 'geodir_wpml_filter_ls_languages', 11, 1 );
2902 2902
 
@@ -2907,18 +2907,18 @@  discard block
 block discarded – undo
2907 2907
  *
2908 2908
  */
2909 2909
 function geodir_remove_yoast_seo_metas(){
2910
-    if ( class_exists( 'WPSEO_Frontend' ) && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas() ) {
2911
-        $wpseo = WPSEO_Frontend::get_instance();
2910
+	if ( class_exists( 'WPSEO_Frontend' ) && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas() ) {
2911
+		$wpseo = WPSEO_Frontend::get_instance();
2912 2912
         
2913
-        remove_action( 'wp_head', array( $wpseo, 'metadesc' ), 6 );
2914
-        remove_action( 'wp_head', array( $wpseo, 'metakeywords' ), 11 );
2915
-        remove_filter( 'pre_get_document_title', array( $wpseo, 'title' ), 15 );
2916
-        remove_filter( 'wp_title', array( $wpseo, 'title' ), 15, 3 );
2917
-        remove_filter( 'thematic_doctitle', array( $wpseo, 'title' ), 15 );
2918
-        remove_filter( 'woo_title', array( $wpseo, 'fix_woo_title' ), 99 );
2913
+		remove_action( 'wp_head', array( $wpseo, 'metadesc' ), 6 );
2914
+		remove_action( 'wp_head', array( $wpseo, 'metakeywords' ), 11 );
2915
+		remove_filter( 'pre_get_document_title', array( $wpseo, 'title' ), 15 );
2916
+		remove_filter( 'wp_title', array( $wpseo, 'title' ), 15, 3 );
2917
+		remove_filter( 'thematic_doctitle', array( $wpseo, 'title' ), 15 );
2918
+		remove_filter( 'woo_title', array( $wpseo, 'fix_woo_title' ), 99 );
2919 2919
         
2920
-        remove_action( 'template_redirect', 'wpseo_frontend_head_init', 999 );
2921
-    }
2920
+		remove_action( 'template_redirect', 'wpseo_frontend_head_init', 999 );
2921
+	}
2922 2922
 }
2923 2923
 
2924 2924
 /**
@@ -2932,20 +2932,20 @@  discard block
 block discarded – undo
2932 2932
  *
2933 2933
  */
2934 2934
  function geodir_wpml_ajax_set_guest_lang() {    
2935
-    if ( geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in() ) {
2936
-        if ( empty( $_GET['lang'] ) && !( !empty( $_SERVER['REQUEST_URI'] ) && preg_match( '@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename( preg_replace( '@\?.*$@', '', $_SERVER['REQUEST_URI'] ) ) ) ) ) {
2937
-            global $sitepress;
2935
+	if ( geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in() ) {
2936
+		if ( empty( $_GET['lang'] ) && !( !empty( $_SERVER['REQUEST_URI'] ) && preg_match( '@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename( preg_replace( '@\?.*$@', '', $_SERVER['REQUEST_URI'] ) ) ) ) ) {
2937
+			global $sitepress;
2938 2938
             
2939
-            $referer = wp_get_referer();
2939
+			$referer = wp_get_referer();
2940 2940
             
2941
-            $current_lang = $sitepress->get_current_language();
2942
-            $referrer_lang = $sitepress->get_language_from_url( $referer );
2941
+			$current_lang = $sitepress->get_current_language();
2942
+			$referrer_lang = $sitepress->get_language_from_url( $referer );
2943 2943
             
2944
-            if ( $referrer_lang && $current_lang != $referrer_lang ) {
2945
-                $_GET['lang'] = $referrer_lang;
2946
-            }
2947
-        }
2948
-    }
2944
+			if ( $referrer_lang && $current_lang != $referrer_lang ) {
2945
+				$_GET['lang'] = $referrer_lang;
2946
+			}
2947
+		}
2948
+	}
2949 2949
 }
2950 2950
 add_action( 'plugins_loaded', 'geodir_wpml_ajax_set_guest_lang', -1 );
2951 2951
 
@@ -2957,36 +2957,36 @@  discard block
 block discarded – undo
2957 2957
  * @param object $wp The WordPress object.
2958 2958
  */
2959 2959
 function geodir_check_redirect($wp) {
2960
-    if (is_404() || (!empty($wp->query_vars['error']) && $wp->query_vars['error'] == '404')) {
2961
-        $current_url = geodir_curPageURL();
2962
-        $search = 'czech-republic';
2963
-        $replace = 'czechia';        
2960
+	if (is_404() || (!empty($wp->query_vars['error']) && $wp->query_vars['error'] == '404')) {
2961
+		$current_url = geodir_curPageURL();
2962
+		$search = 'czech-republic';
2963
+		$replace = 'czechia';        
2964 2964
         
2965
-        $has_slash = substr($current_url, -1);
2966
-        if ($has_slash != "/") {
2967
-            $current_url .= '/';
2968
-        }
2965
+		$has_slash = substr($current_url, -1);
2966
+		if ($has_slash != "/") {
2967
+			$current_url .= '/';
2968
+		}
2969 2969
         
2970
-        $redirect = false;
2971
-        if (strpos($current_url, '/' . $search . '/') !== false) {
2972
-            $redirect = true;
2973
-            $current_url = preg_replace('/\/' . $search . '\//', '/' . $replace . '/', $current_url, 1);
2974
-        }
2970
+		$redirect = false;
2971
+		if (strpos($current_url, '/' . $search . '/') !== false) {
2972
+			$redirect = true;
2973
+			$current_url = preg_replace('/\/' . $search . '\//', '/' . $replace . '/', $current_url, 1);
2974
+		}
2975 2975
         
2976
-        if ($has_slash != "/") {
2977
-            $current_url = trim($current_url, '/');
2978
-        }
2976
+		if ($has_slash != "/") {
2977
+			$current_url = trim($current_url, '/');
2978
+		}
2979 2979
         
2980
-        if (strpos($current_url, 'gd_country=' . $search) !== false) {
2981
-            $redirect = true;
2982
-            $current_url = str_replace('gd_country=' . $search, 'gd_country=' . $replace, $current_url);
2983
-        }
2984
-
2985
-        if ($redirect) {
2986
-            wp_redirect($current_url);
2987
-            exit;
2988
-        }
2989
-    }
2980
+		if (strpos($current_url, 'gd_country=' . $search) !== false) {
2981
+			$redirect = true;
2982
+			$current_url = str_replace('gd_country=' . $search, 'gd_country=' . $replace, $current_url);
2983
+		}
2984
+
2985
+		if ($redirect) {
2986
+			wp_redirect($current_url);
2987
+			exit;
2988
+		}
2989
+	}
2990 2990
 }
2991 2991
 add_action('parse_request', 'geodir_check_redirect', 101, 1);
2992 2992
 
@@ -3006,50 +3006,50 @@  discard block
 block discarded – undo
3006 3006
  * @param string $original_slug The original post slug.
3007 3007
  */
3008 3008
 function geodir_check_post_to_term_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
3009
-    global $wpdb, $sitepress;
3009
+	global $wpdb, $sitepress;
3010 3010
     
3011
-    if ( $post_type && strpos( $post_type, 'gd_' ) === 0 ) {
3012
-        $wpml_post_join = "";
3013
-        $wpml_post_where = "";
3014
-        $wpml_term_join = "";
3015
-        $wpml_term_where = "";
3011
+	if ( $post_type && strpos( $post_type, 'gd_' ) === 0 ) {
3012
+		$wpml_post_join = "";
3013
+		$wpml_post_where = "";
3014
+		$wpml_term_join = "";
3015
+		$wpml_term_where = "";
3016 3016
         
3017
-        if (geodir_wpml_is_post_type_translated($post_type)) {
3018
-            $post_language = $post_ID ? $sitepress->post_translations()->get_element_lang_code($post_ID) : $sitepress->get_current_language();
3019
-            $post_language = $post_language ? $post_language : $sitepress->post_translations()->get_save_post_lang($post_ID, $sitepress);
3020
-            if (!$post_language) {
3021
-                $post_language = $sitepress->get_current_language();
3022
-            }
3017
+		if (geodir_wpml_is_post_type_translated($post_type)) {
3018
+			$post_language = $post_ID ? $sitepress->post_translations()->get_element_lang_code($post_ID) : $sitepress->get_current_language();
3019
+			$post_language = $post_language ? $post_language : $sitepress->post_translations()->get_save_post_lang($post_ID, $sitepress);
3020
+			if (!$post_language) {
3021
+				$post_language = $sitepress->get_current_language();
3022
+			}
3023 3023
             
3024
-            $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)";
3025
-            $wpml_post_where = " AND icl_t.language_code = '" . $post_language ."'";
3024
+			$wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)";
3025
+			$wpml_post_where = " AND icl_t.language_code = '" . $post_language ."'";
3026 3026
             
3027
-            $wpml_term_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON icl_t.element_id = tt.term_taxonomy_id AND icl_t.element_type = CONCAT('tax_', tt.taxonomy)";
3028
-            $wpml_term_where = " AND icl_t.language_code = '" . $post_language ."'";
3029
-        }
3027
+			$wpml_term_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON icl_t.element_id = tt.term_taxonomy_id AND icl_t.element_type = CONCAT('tax_', tt.taxonomy)";
3028
+			$wpml_term_where = " AND icl_t.language_code = '" . $post_language ."'";
3029
+		}
3030 3030
 
3031
-        $term_slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $slug ) );
3031
+		$term_slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $slug ) );
3032 3032
 
3033
-        if ( $term_slug_check ) {
3034
-            $suffix = 1;
3033
+		if ( $term_slug_check ) {
3034
+			$suffix = 1;
3035 3035
             
3036
-            do {
3037
-                $alt_slug = _truncate_post_slug( $original_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3036
+			do {
3037
+				$alt_slug = _truncate_post_slug( $original_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3038 3038
                 
3039
-                $term_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $alt_slug ) );
3039
+				$term_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $alt_slug ) );
3040 3040
                 
3041
-                $post_check = !$term_check && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s AND p.ID != %d {$wpml_term_where} LIMIT 1", $alt_slug, $post_type, $post_ID ) );
3041
+				$post_check = !$term_check && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s AND p.ID != %d {$wpml_term_where} LIMIT 1", $alt_slug, $post_type, $post_ID ) );
3042 3042
                 
3043
-                $term_slug_check = $term_check || $post_check;
3043
+				$term_slug_check = $term_check || $post_check;
3044 3044
                 
3045
-                $suffix++;
3046
-            } while ( $term_slug_check );
3045
+				$suffix++;
3046
+			} while ( $term_slug_check );
3047 3047
             
3048
-            $slug = $alt_slug;
3049
-        }
3050
-    }
3048
+			$slug = $alt_slug;
3049
+		}
3050
+	}
3051 3051
     
3052
-    return $slug;
3052
+	return $slug;
3053 3053
 }
3054 3054
 add_filter( 'wp_unique_post_slug', 'geodir_check_post_to_term_slug', 101, 6 );
3055 3055
 
@@ -3069,47 +3069,47 @@  discard block
 block discarded – undo
3069 3069
  * @return bool true when exists. false when not exists.
3070 3070
  */
3071 3071
 function geodir_check_term_to_post_slug( $slug_exists, $slug, $term_id ) {
3072
-    global $wpdb, $gd_term_post_type, $gd_term_taxonomy, $sitepress;
3072
+	global $wpdb, $gd_term_post_type, $gd_term_taxonomy, $sitepress;
3073 3073
     
3074
-    if ( $slug_exists ) {
3075
-        return $slug_exists;
3076
-    }
3074
+	if ( $slug_exists ) {
3075
+		return $slug_exists;
3076
+	}
3077 3077
     
3078
-    if ( !empty( $gd_term_taxonomy ) && isset($gd_term_taxonomy[$term_id]) ) {
3079
-        $taxonomy = $gd_term_taxonomy[$term_id];
3080
-    } else {
3081
-        $taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id ) );
3082
-        $gd_term_taxonomy[$term_id] = $taxonomy;
3083
-    }
3078
+	if ( !empty( $gd_term_taxonomy ) && isset($gd_term_taxonomy[$term_id]) ) {
3079
+		$taxonomy = $gd_term_taxonomy[$term_id];
3080
+	} else {
3081
+		$taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id ) );
3082
+		$gd_term_taxonomy[$term_id] = $taxonomy;
3083
+	}
3084 3084
     
3085
-    if ( empty($taxonomy) ) {
3086
-        return $slug_exists;
3087
-    }
3085
+	if ( empty($taxonomy) ) {
3086
+		return $slug_exists;
3087
+	}
3088 3088
     
3089
-    if ( !empty( $gd_term_post_type ) && $gd_term_post_type[$term_id] ) {
3090
-        $post_type = $gd_term_post_type[$term_id];
3091
-    } else {
3092
-        $taxonomy_obj = get_taxonomy( $taxonomy );
3093
-        $post_type = !empty( $taxonomy_obj->object_type ) ? $taxonomy_obj->object_type[0] : NULL;
3094
-    }
3089
+	if ( !empty( $gd_term_post_type ) && $gd_term_post_type[$term_id] ) {
3090
+		$post_type = $gd_term_post_type[$term_id];
3091
+	} else {
3092
+		$taxonomy_obj = get_taxonomy( $taxonomy );
3093
+		$post_type = !empty( $taxonomy_obj->object_type ) ? $taxonomy_obj->object_type[0] : NULL;
3094
+	}
3095 3095
     
3096
-    $wpml_post_join = "";
3097
-    $wpml_post_where = "";
3096
+	$wpml_post_join = "";
3097
+	$wpml_post_where = "";
3098 3098
     
3099
-    if (geodir_wpml_is_taxonomy_translated($taxonomy) || geodir_wpml_is_post_type_translated($post_type)) {
3100
-        $term_language = $term_id ? geodir_get_language_for_element($term_id, 'tax_' . $taxonomy) : $sitepress->get_current_language();
3101
-        if (!$term_language) {
3102
-            $term_language = $sitepress->get_current_language();
3103
-        }
3099
+	if (geodir_wpml_is_taxonomy_translated($taxonomy) || geodir_wpml_is_post_type_translated($post_type)) {
3100
+		$term_language = $term_id ? geodir_get_language_for_element($term_id, 'tax_' . $taxonomy) : $sitepress->get_current_language();
3101
+		if (!$term_language) {
3102
+			$term_language = $sitepress->get_current_language();
3103
+		}
3104 3104
         
3105
-        $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)";
3106
-        $wpml_post_where = " AND icl_t.language_code = '" . $term_language ."'";
3107
-    }
3105
+		$wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)";
3106
+		$wpml_post_where = " AND icl_t.language_code = '" . $term_language ."'";
3107
+	}
3108 3108
     
3109
-    if ( $post_type && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s  {$wpml_post_where} LIMIT 1", $slug, $post_type ) ) ) {
3110
-        $slug_exists = true;
3111
-    }
3109
+	if ( $post_type && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s  {$wpml_post_where} LIMIT 1", $slug, $post_type ) ) ) {
3110
+		$slug_exists = true;
3111
+	}
3112 3112
 
3113
-    return $slug_exists;
3113
+	return $slug_exists;
3114 3114
 }
3115 3115
 add_filter( 'geodir_term_slug_is_exists', 'geodir_check_term_to_post_slug', 10, 3 );
3116 3116
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/reviews.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  * return early without loading the comments.
18 18
  */
19 19
 if (post_password_required())
20
-    return;
20
+	return;
21 21
 ?>
22 22
 
23 23
 <div id="comments" class="comments-area">
@@ -25,35 +25,35 @@  discard block
 block discarded – undo
25 25
     <?php // You can start editing here -- including this comment! ?>
26 26
 
27 27
     <?php
28
-    /**
29
-     * Called before displaying reviews.
30
-     *
31
-     * If you would like to wrap reviews inside a div this is the place to print your open div. @see geodir_before_review_form to print your closing div.
32
-     *
33
-     * @since 1.5.7
34
-     */
35
-    do_action('geodir_before_review_list'); ?>
28
+	/**
29
+	 * Called before displaying reviews.
30
+	 *
31
+	 * If you would like to wrap reviews inside a div this is the place to print your open div. @see geodir_before_review_form to print your closing div.
32
+	 *
33
+	 * @since 1.5.7
34
+	 */
35
+	do_action('geodir_before_review_list'); ?>
36 36
 
37 37
     <?php if (have_comments()) : ?>
38 38
         <h2 class="comments-title">
39 39
             <?php
40
-            printf(_n('1 Review <span class="r-title-on">on</span> <span class="r-title">&ldquo;%2$s&rdquo;</span>', '%1$s Reviews <span>on</span> <span class="r-title"> &ldquo;%2$s&rdquo;</span>', get_comments_number(), 'geodirectory'),
41
-                number_format_i18n(get_comments_number()), get_the_title());
42
-            ?>
40
+			printf(_n('1 Review <span class="r-title-on">on</span> <span class="r-title">&ldquo;%2$s&rdquo;</span>', '%1$s Reviews <span>on</span> <span class="r-title"> &ldquo;%2$s&rdquo;</span>', get_comments_number(), 'geodirectory'),
41
+				number_format_i18n(get_comments_number()), get_the_title());
42
+			?>
43 43
         </h2>
44 44
 
45 45
         <?php
46
-        /**
47
-         * Called after displaying review listing title.
48
-         *
49
-         * @since 1.5.7
50
-         */
51
-        do_action('geodir_after_review_list_title'); ?>
46
+		/**
47
+		 * Called after displaying review listing title.
48
+		 *
49
+		 * @since 1.5.7
50
+		 */
51
+		do_action('geodir_after_review_list_title'); ?>
52 52
 
53 53
         <ol class="commentlist">
54 54
             <?php $reverse_top_level = is_plugin_active('geodir_review_rating_manager/geodir_review_rating_manager.php') ? false : null; ?>
55 55
 			<?php wp_list_comments(array('callback' => 'geodir_comment', 'reverse_top_level' => $reverse_top_level, 'style' => 'ol'));
56
-            ?>
56
+			?>
57 57
         </ol><!-- .commentlist -->
58 58
 
59 59
         <?php if (get_comment_pages_count() > 1 && get_option('page_comments')) : // are there comments to navigate through ?>
@@ -68,51 +68,51 @@  discard block
 block discarded – undo
68 68
         <?php endif; // check for comment navigation ?>
69 69
 
70 70
         <?php
71
-        /* If there are no comments and comments are closed, let's leave a note.
71
+		/* If there are no comments and comments are closed, let's leave a note.
72 72
          * But we only want the note on posts and pages that had comments in the first place.
73 73
          */
74
-        if (!comments_open() && get_comments_number()) : ?>
74
+		if (!comments_open() && get_comments_number()) : ?>
75 75
             <p class="nocomments"><?php _e('Reviews are closed.', 'geodirectory'); ?></p>
76 76
         <?php endif; ?>
77 77
 
78 78
     <?php endif; // have_comments() ?>
79 79
 
80 80
     <?php
81
-    /**
82
-     * Called before displaying "Leave a review form".
83
-     *
84
-     * If you would like to wrap "review form" inside a div this is the best place to hook your open div. @see geodir_after_review_form to print your closing div.
85
-     * Also If you would like to wrap "reviews" inside a div this is the best place to print your closing div. @see geodir_before_review_list to print your open div.
86
-     *
87
-     * @since 1.5.7
88
-     */
89
-    do_action('geodir_before_review_form'); ?>
81
+	/**
82
+	 * Called before displaying "Leave a review form".
83
+	 *
84
+	 * If you would like to wrap "review form" inside a div this is the best place to hook your open div. @see geodir_after_review_form to print your closing div.
85
+	 * Also If you would like to wrap "reviews" inside a div this is the best place to print your closing div. @see geodir_before_review_list to print your open div.
86
+	 *
87
+	 * @since 1.5.7
88
+	 */
89
+	do_action('geodir_before_review_form'); ?>
90 90
 
91 91
     <?php
92
-    /**
93
-     * Filters comment form args
94
-     *
95
-     * If you would like to modify your comment form args, use this filter. @see https://codex.wordpress.org/Function_Reference/comment_form for accepted args.
96
-     *
97
-     * @since 1.0.0
98
-     */
99
-    $args = apply_filters('geodir_review_form_args', array(
100
-        'title_reply' => __('Leave a Review', 'geodirectory'),
101
-        'label_submit' => __('Post Review', 'geodirectory'),
102
-        'comment_field' => '<p class="comment-form-comment"><label for="comment">' . __('Review text', 'geodirectory') . ' <span class="required">*</span></label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" required></textarea></p>',
103
-        'must_log_in' => '<p class="must-log-in">' . sprintf(__('You must be <a href="%s">logged in</a> to post a comment.', 'geodirectory'), geodir_login_url()) . '</p>'
104
-    ));
105
-    comment_form($args);
106
-    ?>
92
+	/**
93
+	 * Filters comment form args
94
+	 *
95
+	 * If you would like to modify your comment form args, use this filter. @see https://codex.wordpress.org/Function_Reference/comment_form for accepted args.
96
+	 *
97
+	 * @since 1.0.0
98
+	 */
99
+	$args = apply_filters('geodir_review_form_args', array(
100
+		'title_reply' => __('Leave a Review', 'geodirectory'),
101
+		'label_submit' => __('Post Review', 'geodirectory'),
102
+		'comment_field' => '<p class="comment-form-comment"><label for="comment">' . __('Review text', 'geodirectory') . ' <span class="required">*</span></label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" required></textarea></p>',
103
+		'must_log_in' => '<p class="must-log-in">' . sprintf(__('You must be <a href="%s">logged in</a> to post a comment.', 'geodirectory'), geodir_login_url()) . '</p>'
104
+	));
105
+	comment_form($args);
106
+	?>
107 107
 
108 108
     <?php
109
-    /**
110
-     * Called after displaying "Leave a review form".
111
-     *
112
-     * If you would like to wrap "review form" inside a div this is the best place to print your closing div. @see geodir_before_review_form to print your open div.
113
-     *
114
-     * @since 1.5.7
115
-     */
116
-    do_action('geodir_after_review_form'); ?>
109
+	/**
110
+	 * Called after displaying "Leave a review form".
111
+	 *
112
+	 * If you would like to wrap "review form" inside a div this is the best place to print your closing div. @see geodir_before_review_form to print your open div.
113
+	 *
114
+	 * @since 1.5.7
115
+	 */
116
+	do_action('geodir_after_review_form'); ?>
117 117
 
118 118
 </div><!-- #comments .comments-area -->
119 119
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -99,8 +99,8 @@
 block discarded – undo
99 99
     $args = apply_filters('geodir_review_form_args', array(
100 100
         'title_reply' => __('Leave a Review', 'geodirectory'),
101 101
         'label_submit' => __('Post Review', 'geodirectory'),
102
-        'comment_field' => '<p class="comment-form-comment"><label for="comment">' . __('Review text', 'geodirectory') . ' <span class="required">*</span></label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" required></textarea></p>',
103
-        'must_log_in' => '<p class="must-log-in">' . sprintf(__('You must be <a href="%s">logged in</a> to post a comment.', 'geodirectory'), geodir_login_url()) . '</p>'
102
+        'comment_field' => '<p class="comment-form-comment"><label for="comment">'.__('Review text', 'geodirectory').' <span class="required">*</span></label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" required></textarea></p>',
103
+        'must_log_in' => '<p class="must-log-in">'.sprintf(__('You must be <a href="%s">logged in</a> to post a comment.', 'geodirectory'), geodir_login_url()).'</p>'
104 104
     ));
105 105
     comment_form($args);
106 106
     ?>
Please login to merge, or discard this patch.
geodirectory-functions/general_functions.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 			break;
328 328
 		case 'preview':
329 329
 			if ( ( is_page() && get_query_var( 'page_id' ) == geodir_preview_page_id() ) && isset( $_REQUEST['listing_type'] )
330
-			     && in_array( $_REQUEST['listing_type'], geodir_get_posttypes() )
330
+				 && in_array( $_REQUEST['listing_type'], geodir_get_posttypes() )
331 331
 			) {
332 332
 				return true;
333 333
 			}
@@ -528,9 +528,9 @@  discard block
 block discarded – undo
528 528
 
529 529
 //check if homepage
530 530
 		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] )
531
-		     && ! isset( $wp->query_vars['page_id'] )
532
-		     && ! isset( $wp->query_vars['pagename'] )
533
-		     && is_page_geodir_home()
531
+			 && ! isset( $wp->query_vars['page_id'] )
532
+			 && ! isset( $wp->query_vars['pagename'] )
533
+			 && is_page_geodir_home()
534 534
 		) {
535 535
 			$wp->query_vars['gd_is_geodir_page'] = true;
536 536
 		}
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
 		$deltaLatitude  = deg2rad( (float) $point2['latitude'] - (float) $point1['latitude'] );
716 716
 		$deltaLongitude = deg2rad( (float) $point2['longitude'] - (float) $point1['longitude'] );
717 717
 		$a              = sin( $deltaLatitude / 2 ) * sin( $deltaLatitude / 2 ) +
718
-		                  cos( deg2rad( (float) $point1['latitude'] ) ) * cos( deg2rad( (float) $point2['latitude'] ) ) *
719
-		                  sin( $deltaLongitude / 2 ) * sin( $deltaLongitude / 2 );
718
+						  cos( deg2rad( (float) $point1['latitude'] ) ) * cos( deg2rad( (float) $point2['latitude'] ) ) *
719
+						  sin( $deltaLongitude / 2 ) * sin( $deltaLongitude / 2 );
720 720
 		$c              = 2 * atan2( sqrt( $a ), sqrt( 1 - $a ) );
721 721
 		$distance       = $earthMeanRadius * $c;
722 722
 
@@ -3866,10 +3866,10 @@  discard block
 block discarded – undo
3866 3866
 			$gridview_columns_widget = '';
3867 3867
 		}
3868 3868
 			/**
3869
-		 * Filter the widget listing listview template path.
3870
-		 *
3871
-		 * @since 1.0.0
3872
-		 */
3869
+			 * Filter the widget listing listview template path.
3870
+			 *
3871
+			 * @since 1.0.0
3872
+			 */
3873 3873
 		$template = apply_filters( "geodir_template_part-widget-listing-listview", geodir_locate_template( 'widget-listing-listview' ) );
3874 3874
 		if ( ! isset( $character_count ) ) {
3875 3875
 			/**
@@ -5234,7 +5234,7 @@  discard block
 block discarded – undo
5234 5234
  * @param string $name The name of the string which helps to know what's being translated.
5235 5235
  */
5236 5236
 function geodir_wpml_register_string( $string, $domain = 'geodirectory', $name = '' ) {
5237
-    do_action( 'wpml_register_single_string', $domain, $name, $string );
5237
+	do_action( 'wpml_register_single_string', $domain, $name, $string );
5238 5238
 }
5239 5239
 
5240 5240
 /**
@@ -5250,7 +5250,7 @@  discard block
 block discarded – undo
5250 5250
  * @return string The translated string.
5251 5251
  */
5252 5252
 function geodir_wpml_translate_string( $string, $domain = 'geodirectory', $name = '', $language_code = NULL ) {
5253
-    return apply_filters( 'wpml_translate_single_string', $string, $domain, $name, $language_code );
5253
+	return apply_filters( 'wpml_translate_single_string', $string, $domain, $name, $language_code );
5254 5254
 }
5255 5255
 
5256 5256
 /**
@@ -5266,34 +5266,34 @@  discard block
 block discarded – undo
5266 5266
  * @param array $data Post data.
5267 5267
  */
5268 5268
 function geodir_send_listing_edited_notification( $post_ID, $data ) {
5269
-    global $gd_notified_edited, $gd_set_listing_edited;
5269
+	global $gd_notified_edited, $gd_set_listing_edited;
5270 5270
     
5271
-    if ( !empty( $gd_set_listing_edited[ $post_ID ] ) && empty( $gd_notified_edited[ $post_ID ] ) ) {
5272
-        if ( !empty( $gd_notified_edited ) ) {
5273
-            $gd_notified_edited = array();
5274
-        }
5275
-        $gd_notified_edited[ $post_ID ] = true;
5271
+	if ( !empty( $gd_set_listing_edited[ $post_ID ] ) && empty( $gd_notified_edited[ $post_ID ] ) ) {
5272
+		if ( !empty( $gd_notified_edited ) ) {
5273
+			$gd_notified_edited = array();
5274
+		}
5275
+		$gd_notified_edited[ $post_ID ] = true;
5276 5276
         
5277
-        $from_email   = get_option( 'site_email' );
5278
-        $from_name    = get_site_emailName();
5279
-        $to_email     = get_option( 'admin_email' );
5280
-        $to_name      = get_option( 'name' );
5281
-        $message_type = 'listing_edited';
5282
-
5283
-        $notify_edited = true;
5284
-        /**
5285
-         * Send notification when listing edited by author?
5286
-         *
5287
-         * @since 1.6.0
5288
-         *
5289
-         * @param bool $notify_edited Notify on listing edited by author?
5290
-         * @param object $post        The current post object.
5291
-         */
5292
-        $notify_edited = apply_filters( 'geodir_notify_on_listing_edited', $notify_edited, $post_ID );
5293
-
5294
-        if ( $notify_edited ) {
5295
-            geodir_sendEmail( $from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID );
5296
-        }
5297
-    }
5277
+		$from_email   = get_option( 'site_email' );
5278
+		$from_name    = get_site_emailName();
5279
+		$to_email     = get_option( 'admin_email' );
5280
+		$to_name      = get_option( 'name' );
5281
+		$message_type = 'listing_edited';
5282
+
5283
+		$notify_edited = true;
5284
+		/**
5285
+		 * Send notification when listing edited by author?
5286
+		 *
5287
+		 * @since 1.6.0
5288
+		 *
5289
+		 * @param bool $notify_edited Notify on listing edited by author?
5290
+		 * @param object $post        The current post object.
5291
+		 */
5292
+		$notify_edited = apply_filters( 'geodir_notify_on_listing_edited', $notify_edited, $post_ID );
5293
+
5294
+		if ( $notify_edited ) {
5295
+			geodir_sendEmail( $from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID );
5296
+		}
5297
+	}
5298 5298
 }
5299 5299
 add_action( 'geodir_after_save_listing', 'geodir_send_listing_edited_notification', 1000, 2 );
5300 5300
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1305 added lines, -1305 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 /**
11 11
  * Get All Plugin functions from WordPress
12 12
  */
13
-include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
13
+include_once(ABSPATH.'wp-admin/includes/plugin.php');
14 14
 
15 15
 /*-----------------------------------------------------------------------------------*/
16 16
 /* Helper functions */
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  * @return string example url eg: http://wpgeo.directory/wp-content/plugins/geodirectory
28 28
  */
29 29
 function geodir_plugin_url() {
30
-	return plugins_url( '', dirname( __FILE__ ) );
30
+	return plugins_url('', dirname(__FILE__));
31 31
 	/*
32 32
 	if ( is_ssl() ) :
33 33
 		return str_replace( 'http://', 'https://', WP_PLUGIN_URL ) . "/" . plugin_basename( dirname( dirname( __FILE__ ) ) );
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
  * @return string example url eg: /home/geo/public_html/wp-content/plugins/geodirectory
48 48
  */
49 49
 function geodir_plugin_path() {
50
-	if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
51
-		return dirname( dirname( __FILE__ ) );
50
+	if (defined('GD_TESTING_MODE') && GD_TESTING_MODE) {
51
+		return dirname(dirname(__FILE__));
52 52
 	} else {
53
-		return WP_PLUGIN_DIR . "/" . plugin_basename( dirname( dirname( __FILE__ ) ) );
53
+		return WP_PLUGIN_DIR."/".plugin_basename(dirname(dirname(__FILE__)));
54 54
 	}
55 55
 }
56 56
 
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
  * @return bool true or false.
66 66
  * @todo    check if this is faster than normal WP check and remove if not.
67 67
  */
68
-function geodir_is_plugin_active( $plugin ) {
69
-	$active_plugins = get_option( 'active_plugins' );
70
-	foreach ( $active_plugins as $key => $active_plugin ) {
71
-		if ( strstr( $active_plugin, $plugin ) ) {
68
+function geodir_is_plugin_active($plugin) {
69
+	$active_plugins = get_option('active_plugins');
70
+	foreach ($active_plugins as $key => $active_plugin) {
71
+		if (strstr($active_plugin, $plugin)) {
72 72
 			return true;
73 73
 		}
74 74
 	}
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
  *
91 91
  * @return bool|int|string the formatted date.
92 92
  */
93
-function geodir_get_formated_date( $date ) {
94
-	return mysql2date( get_option( 'date_format' ), $date );
93
+function geodir_get_formated_date($date) {
94
+	return mysql2date(get_option('date_format'), $date);
95 95
 }
96 96
 
97 97
 /**
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
  *
108 108
  * @return bool|int|string the formatted time.
109 109
  */
110
-function geodir_get_formated_time( $time ) {
111
-	return mysql2date( get_option( 'time_format' ), $time, $translate = true );
110
+function geodir_get_formated_time($time) {
111
+	return mysql2date(get_option('time_format'), $time, $translate = true);
112 112
 }
113 113
 
114 114
 
@@ -126,35 +126,35 @@  discard block
 block discarded – undo
126 126
  *
127 127
  * @return string Formatted link.
128 128
  */
129
-function geodir_getlink( $url, $params = array(), $use_existing_arguments = false ) {
130
-	if ( $use_existing_arguments ) {
129
+function geodir_getlink($url, $params = array(), $use_existing_arguments = false) {
130
+	if ($use_existing_arguments) {
131 131
 		$params = $params + $_GET;
132 132
 	}
133
-	if ( ! $params ) {
133
+	if (!$params) {
134 134
 		return $url;
135 135
 	}
136 136
 	$link = $url;
137
-	if ( strpos( $link, '?' ) === false ) {
137
+	if (strpos($link, '?') === false) {
138 138
 		$link .= '?';
139 139
 	} //If there is no '?' add one at the end
140
-	elseif ( strpos( $link, '//maps.google.com/maps/api/js?language=' ) ) {
140
+	elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) {
141 141
 		$link .= '&amp;';
142 142
 	} //If there is no '&' at the END, add one.
143
-	elseif ( ! preg_match( '/(\?|\&(amp;)?)$/', $link ) ) {
143
+	elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) {
144 144
 		$link .= '&';
145 145
 	} //If there is no '&' at the END, add one.
146 146
 
147 147
 	$params_arr = array();
148
-	foreach ( $params as $key => $value ) {
149
-		if ( gettype( $value ) == 'array' ) { //Handle array data properly
150
-			foreach ( $value as $val ) {
151
-				$params_arr[] = $key . '[]=' . urlencode( $val );
148
+	foreach ($params as $key => $value) {
149
+		if (gettype($value) == 'array') { //Handle array data properly
150
+			foreach ($value as $val) {
151
+				$params_arr[] = $key.'[]='.urlencode($val);
152 152
 			}
153 153
 		} else {
154
-			$params_arr[] = $key . '=' . urlencode( $value );
154
+			$params_arr[] = $key.'='.urlencode($value);
155 155
 		}
156 156
 	}
157
-	$link .= implode( '&', $params_arr );
157
+	$link .= implode('&', $params_arr);
158 158
 
159 159
 	return $link;
160 160
 }
@@ -171,18 +171,18 @@  discard block
 block discarded – undo
171 171
  *
172 172
  * @return string Listing page url if valid. Otherwise home url will be returned.
173 173
  */
174
-function geodir_get_addlisting_link( $post_type = '' ) {
174
+function geodir_get_addlisting_link($post_type = '') {
175 175
 	global $wpdb;
176 176
 
177 177
 	//$check_pkg  = $wpdb->get_var("SELECT pid FROM ".GEODIR_PRICE_TABLE." WHERE post_type='".$post_type."' and status != '0'");
178 178
 	$check_pkg = 1;
179
-	if ( post_type_exists( $post_type ) && $check_pkg ) {
179
+	if (post_type_exists($post_type) && $check_pkg) {
180 180
 
181
-		$add_listing_link = get_page_link( geodir_add_listing_page_id() );
181
+		$add_listing_link = get_page_link(geodir_add_listing_page_id());
182 182
 
183
-		return esc_url( add_query_arg( array( 'listing_type' => $post_type ), $add_listing_link ) );
183
+		return esc_url(add_query_arg(array('listing_type' => $post_type), $add_listing_link));
184 184
 	} else {
185
-		return get_bloginfo( 'url' );
185
+		return get_bloginfo('url');
186 186
 	}
187 187
 }
188 188
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	if (!empty($_SERVER['PHP_SELF']) && !empty($_SERVER['REQUEST_URI'])) {
211 211
 		// To build the entire URI we need to prepend the protocol, and the http host
212 212
 		// to the URI string.
213
-		$pageURL .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
213
+		$pageURL .= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
214 214
 	} else {
215 215
 		/*
216 216
 		 * Since we do not have REQUEST_URI to work with, we will assume we are
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
 		 *
220 220
 		 * IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS
221 221
 		 */
222
-		$pageURL .= $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
222
+		$pageURL .= $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
223 223
 		
224 224
 		// If the query string exists append it to the URI string
225 225
 		if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
226
-			$pageURL .= '?' . $_SERVER['QUERY_STRING'];
226
+			$pageURL .= '?'.$_SERVER['QUERY_STRING'];
227 227
 		}
228 228
 	}
229 229
 	
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 *
235 235
 	 * @param string $pageURL The URL of the current page.
236 236
 	 */
237
-	return apply_filters( 'geodir_curPageURL', $pageURL );
237
+	return apply_filters('geodir_curPageURL', $pageURL);
238 238
 }
239 239
 
240 240
 /**
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
  *
250 250
  * @return string Cleaned variable.
251 251
  */
252
-function geodir_clean( $string ) {
252
+function geodir_clean($string) {
253 253
 
254
-	$string = trim( strip_tags( stripslashes( $string ) ) );
255
-	$string = str_replace( " ", "-", $string ); // Replaces all spaces with hyphens.
256
-	$string = preg_replace( '/[^A-Za-z0-9\-\_]/', '', $string ); // Removes special chars.
257
-	$string = preg_replace( '/-+/', '-', $string ); // Replaces multiple hyphens with single one.
254
+	$string = trim(strip_tags(stripslashes($string)));
255
+	$string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
256
+	$string = preg_replace('/[^A-Za-z0-9\-\_]/', '', $string); // Removes special chars.
257
+	$string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
258 258
 
259 259
 	return $string;
260 260
 }
@@ -268,13 +268,13 @@  discard block
 block discarded – undo
268 268
  */
269 269
 function geodir_get_weekday() {
270 270
 	return array(
271
-		__( 'Sunday', 'geodirectory' ),
272
-		__( 'Monday', 'geodirectory' ),
273
-		__( 'Tuesday', 'geodirectory' ),
274
-		__( 'Wednesday', 'geodirectory' ),
275
-		__( 'Thursday', 'geodirectory' ),
276
-		__( 'Friday', 'geodirectory' ),
277
-		__( 'Saturday', 'geodirectory' )
271
+		__('Sunday', 'geodirectory'),
272
+		__('Monday', 'geodirectory'),
273
+		__('Tuesday', 'geodirectory'),
274
+		__('Wednesday', 'geodirectory'),
275
+		__('Thursday', 'geodirectory'),
276
+		__('Friday', 'geodirectory'),
277
+		__('Saturday', 'geodirectory')
278 278
 	);
279 279
 }
280 280
 
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
  */
288 288
 function geodir_get_weeks() {
289 289
 	return array(
290
-		__( 'First', 'geodirectory' ),
291
-		__( 'Second', 'geodirectory' ),
292
-		__( 'Third', 'geodirectory' ),
293
-		__( 'Fourth', 'geodirectory' ),
294
-		__( 'Last', 'geodirectory' )
290
+		__('First', 'geodirectory'),
291
+		__('Second', 'geodirectory'),
292
+		__('Third', 'geodirectory'),
293
+		__('Fourth', 'geodirectory'),
294
+		__('Last', 'geodirectory')
295 295
 	);
296 296
 }
297 297
 
@@ -310,112 +310,112 @@  discard block
 block discarded – undo
310 310
  *
311 311
  * @return bool If valid returns true. Otherwise false.
312 312
  */
313
-function geodir_is_page( $gdpage = '' ) {
313
+function geodir_is_page($gdpage = '') {
314 314
 
315 315
 	global $wp_query, $post, $wp;
316 316
 	//if(!is_admin()):
317 317
 
318
-	switch ( $gdpage ):
318
+	switch ($gdpage):
319 319
 		case 'add-listing':
320 320
 
321
-			if ( is_page() && get_query_var( 'page_id' ) == geodir_add_listing_page_id() ) {
321
+			if (is_page() && get_query_var('page_id') == geodir_add_listing_page_id()) {
322 322
 				return true;
323
-			} elseif ( is_page() && isset( $post->post_content ) && has_shortcode( $post->post_content, 'gd_add_listing' ) ) {
323
+			} elseif (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
324 324
 				return true;
325 325
 			}
326 326
 
327 327
 			break;
328 328
 		case 'preview':
329
-			if ( ( is_page() && get_query_var( 'page_id' ) == geodir_preview_page_id() ) && isset( $_REQUEST['listing_type'] )
330
-			     && in_array( $_REQUEST['listing_type'], geodir_get_posttypes() )
329
+			if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
330
+			     && in_array($_REQUEST['listing_type'], geodir_get_posttypes())
331 331
 			) {
332 332
 				return true;
333 333
 			}
334 334
 			break;
335 335
 		case 'listing-success':
336
-			if ( is_page() && get_query_var( 'page_id' ) == geodir_success_page_id() ) {
336
+			if (is_page() && get_query_var('page_id') == geodir_success_page_id()) {
337 337
 				return true;
338 338
 			}
339 339
 			break;
340 340
 		case 'detail':
341
-			$post_type = get_query_var( 'post_type' );
342
-			if ( is_array( $post_type ) ) {
343
-				$post_type = reset( $post_type );
341
+			$post_type = get_query_var('post_type');
342
+			if (is_array($post_type)) {
343
+				$post_type = reset($post_type);
344 344
 			}
345
-			if ( is_single() && in_array( $post_type, geodir_get_posttypes() ) ) {
345
+			if (is_single() && in_array($post_type, geodir_get_posttypes())) {
346 346
 				return true;
347 347
 			}
348 348
 			break;
349 349
 		case 'pt':
350
-			$post_type = get_query_var( 'post_type' );
351
-			if ( is_array( $post_type ) ) {
352
-				$post_type = reset( $post_type );
350
+			$post_type = get_query_var('post_type');
351
+			if (is_array($post_type)) {
352
+				$post_type = reset($post_type);
353 353
 			}
354
-			if ( is_post_type_archive() && in_array( $post_type, geodir_get_posttypes() ) && ! is_tax() ) {
354
+			if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()) && !is_tax()) {
355 355
 				return true;
356 356
 			}
357 357
 
358 358
 			break;
359 359
 		case 'listing':
360
-			if ( is_tax() && geodir_get_taxonomy_posttype() ) {
360
+			if (is_tax() && geodir_get_taxonomy_posttype()) {
361 361
 				global $current_term, $taxonomy, $term;
362 362
 
363 363
 				return true;
364 364
 			}
365
-			$post_type = get_query_var( 'post_type' );
366
-			if ( is_array( $post_type ) ) {
367
-				$post_type = reset( $post_type );
365
+			$post_type = get_query_var('post_type');
366
+			if (is_array($post_type)) {
367
+				$post_type = reset($post_type);
368 368
 			}
369
-			if ( is_post_type_archive() && in_array( $post_type, geodir_get_posttypes() ) ) {
369
+			if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes())) {
370 370
 				return true;
371 371
 			}
372 372
 
373 373
 			break;
374 374
 		case 'home':
375 375
 
376
-			if ( ( is_page() && get_query_var( 'page_id' ) == geodir_home_page_id() ) || is_page_geodir_home() ) {
376
+			if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home()) {
377 377
 				return true;
378 378
 			}
379 379
 
380 380
 			break;
381 381
 		case 'location':
382
-			if ( is_page() && get_query_var( 'page_id' ) == geodir_location_page_id() ) {
382
+			if (is_page() && get_query_var('page_id') == geodir_location_page_id()) {
383 383
 				return true;
384 384
 			}
385 385
 			break;
386 386
 		case 'author':
387
-			if ( is_author() && isset( $_REQUEST['geodir_dashbord'] ) ) {
387
+			if (is_author() && isset($_REQUEST['geodir_dashbord'])) {
388 388
 				return true;
389 389
 			}
390 390
 
391
-			if ( function_exists( 'bp_loggedin_user_id' ) && function_exists( 'bp_displayed_user_id' ) && $my_id = (int) bp_loggedin_user_id() ) {
392
-				if ( ( (bool) bp_is_current_component( 'listings' ) || (bool) bp_is_current_component( 'favorites' ) ) && $my_id > 0 && $my_id == (int) bp_displayed_user_id() ) {
391
+			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int) bp_loggedin_user_id()) {
392
+				if (((bool) bp_is_current_component('listings') || (bool) bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int) bp_displayed_user_id()) {
393 393
 					return true;
394 394
 				}
395 395
 			}
396 396
 			break;
397 397
 		case 'search':
398
-			if ( is_search() && isset( $_REQUEST['geodir_search'] ) ) {
398
+			if (is_search() && isset($_REQUEST['geodir_search'])) {
399 399
 				return true;
400 400
 			}
401 401
 			break;
402 402
 		case 'info':
403
-			if ( is_page() && get_query_var( 'page_id' ) == geodir_info_page_id() ) {
403
+			if (is_page() && get_query_var('page_id') == geodir_info_page_id()) {
404 404
 				return true;
405 405
 			}
406 406
 			break;
407 407
 		case 'login':
408
-			if ( is_page() && get_query_var( 'page_id' ) == geodir_login_page_id() ) {
408
+			if (is_page() && get_query_var('page_id') == geodir_login_page_id()) {
409 409
 				return true;
410 410
 			}
411 411
 			break;
412 412
 		case 'checkout':
413
-			if ( is_page() && function_exists( 'geodir_payment_checkout_page_id' ) && get_query_var( 'page_id' ) == geodir_payment_checkout_page_id() ) {
413
+			if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id()) {
414 414
 				return true;
415 415
 			}
416 416
 			break;
417 417
 		case 'invoices':
418
-			if ( is_page() && function_exists( 'geodir_payment_invoices_page_id' ) && get_query_var( 'page_id' ) == geodir_payment_invoices_page_id() ) {
418
+			if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id()) {
419 419
 				return true;
420 420
 			}
421 421
 			break;
@@ -440,25 +440,25 @@  discard block
 block discarded – undo
440 440
  *
441 441
  * @param object $wp WordPress object.
442 442
  */
443
-function geodir_set_is_geodir_page( $wp ) {
444
-	if ( ! is_admin() ) {
443
+function geodir_set_is_geodir_page($wp) {
444
+	if (!is_admin()) {
445 445
 		//$wp->query_vars['gd_is_geodir_page'] = false;
446 446
 		//print_r()
447
-		if ( empty( $wp->query_vars ) || ! array_diff( array_keys( $wp->query_vars ), array(
447
+		if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array(
448 448
 				'preview',
449 449
 				'page',
450 450
 				'paged',
451 451
 				'cpage'
452
-			) )
452
+			))
453 453
 		) {
454
-			if ( geodir_is_page( 'home' ) ) {
454
+			if (geodir_is_page('home')) {
455 455
 				$wp->query_vars['gd_is_geodir_page'] = true;
456 456
 			}
457 457
 
458 458
 
459 459
 		}
460 460
 
461
-		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['page_id'] ) ) {
461
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) {
462 462
 			if (
463 463
 				$wp->query_vars['page_id'] == geodir_add_listing_page_id()
464 464
 				|| $wp->query_vars['page_id'] == geodir_preview_page_id()
@@ -467,26 +467,26 @@  discard block
 block discarded – undo
467 467
 				|| $wp->query_vars['page_id'] == geodir_home_page_id()
468 468
 				|| $wp->query_vars['page_id'] == geodir_info_page_id()
469 469
 				|| $wp->query_vars['page_id'] == geodir_login_page_id()
470
-				|| ( function_exists( 'geodir_payment_checkout_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id() )
471
-				|| ( function_exists( 'geodir_payment_invoices_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id() )
470
+				|| (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
471
+				|| (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
472 472
 			) {
473 473
 				$wp->query_vars['gd_is_geodir_page'] = true;
474 474
 			}
475 475
 		}
476 476
 
477
-		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['pagename'] ) ) {
478
-			$page = get_page_by_path( $wp->query_vars['pagename'] );
477
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
478
+			$page = get_page_by_path($wp->query_vars['pagename']);
479 479
 
480
-			if ( ! empty( $page ) && (
480
+			if (!empty($page) && (
481 481
 					$page->ID == geodir_add_listing_page_id()
482 482
 					|| $page->ID == geodir_preview_page_id()
483 483
 					|| $page->ID == geodir_success_page_id()
484 484
 					|| $page->ID == geodir_location_page_id()
485
-					|| ( isset( $wp->query_vars['page_id'] ) && $wp->query_vars['page_id'] == geodir_home_page_id() )
486
-					|| ( isset( $wp->query_vars['page_id'] ) && $wp->query_vars['page_id'] == geodir_info_page_id() )
487
-					|| ( isset( $wp->query_vars['page_id'] ) && $wp->query_vars['page_id'] == geodir_login_page_id() )
488
-					|| ( isset( $wp->query_vars['page_id'] ) && function_exists( 'geodir_payment_checkout_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id() )
489
-					|| ( isset( $wp->query_vars['page_id'] ) && function_exists( 'geodir_payment_invoices_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id() )
485
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_home_page_id())
486
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_info_page_id())
487
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_login_page_id())
488
+					|| (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
489
+					|| (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
490 490
 				)
491 491
 			) {
492 492
 				$wp->query_vars['gd_is_geodir_page'] = true;
@@ -494,20 +494,20 @@  discard block
 block discarded – undo
494 494
 		}
495 495
 
496 496
 
497
-		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['post_type'] ) && $wp->query_vars['post_type'] != '' ) {
497
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
498 498
 			$requested_post_type = $wp->query_vars['post_type'];
499 499
 			// check if this post type is geodirectory post types
500 500
 			$post_type_array = geodir_get_posttypes();
501
-			if ( in_array( $requested_post_type, $post_type_array ) ) {
501
+			if (in_array($requested_post_type, $post_type_array)) {
502 502
 				$wp->query_vars['gd_is_geodir_page'] = true;
503 503
 			}
504 504
 		}
505 505
 
506
-		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) ) {
507
-			$geodir_taxonomis = geodir_get_taxonomies( '', true );
508
-			if ( ! empty( $geodir_taxonomis ) ) {
509
-				foreach ( $geodir_taxonomis as $taxonomy ) {
510
-					if ( array_key_exists( $taxonomy, $wp->query_vars ) ) {
506
+		if (!isset($wp->query_vars['gd_is_geodir_page'])) {
507
+			$geodir_taxonomis = geodir_get_taxonomies('', true);
508
+			if (!empty($geodir_taxonomis)) {
509
+				foreach ($geodir_taxonomis as $taxonomy) {
510
+					if (array_key_exists($taxonomy, $wp->query_vars)) {
511 511
 						$wp->query_vars['gd_is_geodir_page'] = true;
512 512
 						break;
513 513
 					}
@@ -516,20 +516,20 @@  discard block
 block discarded – undo
516 516
 
517 517
 		}
518 518
 
519
-		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['author_name'] ) && isset( $_REQUEST['geodir_dashbord'] ) ) {
519
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) {
520 520
 			$wp->query_vars['gd_is_geodir_page'] = true;
521 521
 		}
522 522
 
523 523
 
524
-		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $_REQUEST['geodir_search'] ) ) {
524
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) {
525 525
 			$wp->query_vars['gd_is_geodir_page'] = true;
526 526
 		}
527 527
 
528 528
 
529 529
 //check if homepage
530
-		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] )
531
-		     && ! isset( $wp->query_vars['page_id'] )
532
-		     && ! isset( $wp->query_vars['pagename'] )
530
+		if (!isset($wp->query_vars['gd_is_geodir_page'])
531
+		     && !isset($wp->query_vars['page_id'])
532
+		     && !isset($wp->query_vars['pagename'])
533 533
 		     && is_page_geodir_home()
534 534
 		) {
535 535
 			$wp->query_vars['gd_is_geodir_page'] = true;
@@ -553,14 +553,14 @@  discard block
 block discarded – undo
553 553
  */
554 554
 function geodir_is_geodir_page() {
555 555
 	global $wp;
556
-	if ( isset( $wp->query_vars['gd_is_geodir_page'] ) && $wp->query_vars['gd_is_geodir_page'] ) {
556
+	if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page']) {
557 557
 		return true;
558 558
 	} else {
559 559
 		return false;
560 560
 	}
561 561
 }
562 562
 
563
-if ( ! function_exists( 'geodir_get_imagesize' ) ) {
563
+if (!function_exists('geodir_get_imagesize')) {
564 564
 	/**
565 565
 	 * Get image size using the size key .
566 566
 	 *
@@ -571,13 +571,13 @@  discard block
 block discarded – undo
571 571
 	 *
572 572
 	 * @return array|mixed|void|WP_Error If valid returns image size. Else returns error.
573 573
 	 */
574
-	function geodir_get_imagesize( $size = '' ) {
574
+	function geodir_get_imagesize($size = '') {
575 575
 
576 576
 		$imagesizes = array(
577
-			'list-thumb'   => array( 'w' => 283, 'h' => 188 ),
578
-			'thumbnail'    => array( 'w' => 125, 'h' => 125 ),
579
-			'widget-thumb' => array( 'w' => 50, 'h' => 50 ),
580
-			'slider-thumb' => array( 'w' => 100, 'h' => 100 )
577
+			'list-thumb'   => array('w' => 283, 'h' => 188),
578
+			'thumbnail'    => array('w' => 125, 'h' => 125),
579
+			'widget-thumb' => array('w' => 50, 'h' => 50),
580
+			'slider-thumb' => array('w' => 100, 'h' => 100)
581 581
 		);
582 582
 
583 583
 		/**
@@ -587,9 +587,9 @@  discard block
 block discarded – undo
587 587
 		 *
588 588
 		 * @param array $imagesizes Image size array.
589 589
 		 */
590
-		$imagesizes = apply_filters( 'geodir_imagesizes', $imagesizes );
590
+		$imagesizes = apply_filters('geodir_imagesizes', $imagesizes);
591 591
 
592
-		if ( ! empty( $size ) && array_key_exists( $size, $imagesizes ) ) {
592
+		if (!empty($size) && array_key_exists($size, $imagesizes)) {
593 593
 			/**
594 594
 			 * Filters image size of the passed key.
595 595
 			 *
@@ -597,11 +597,11 @@  discard block
 block discarded – undo
597 597
 			 *
598 598
 			 * @param array $imagesizes [$size] Image size array of the passed key.
599 599
 			 */
600
-			return apply_filters( 'geodir_get_imagesize_' . $size, $imagesizes[ $size ] );
600
+			return apply_filters('geodir_get_imagesize_'.$size, $imagesizes[$size]);
601 601
 
602
-		} elseif ( ! empty( $size ) ) {
602
+		} elseif (!empty($size)) {
603 603
 
604
-			return new WP_Error( 'geodir_no_imagesize', __( "Given image size is not valid", 'geodirectory' ) );
604
+			return new WP_Error('geodir_no_imagesize', __("Given image size is not valid", 'geodirectory'));
605 605
 
606 606
 		}
607 607
 
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 */
626 626
 
627 627
 
628
-if ( ! function_exists( 'createRandomString' ) ) {
628
+if (!function_exists('createRandomString')) {
629 629
 	/**
630 630
 	 * Creates random string.
631 631
 	 *
@@ -635,21 +635,21 @@  discard block
 block discarded – undo
635 635
 	 */
636 636
 	function createRandomString() {
637 637
 		$chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
638
-		srand( (double) microtime() * 1000000 );
638
+		srand((double) microtime() * 1000000);
639 639
 		$i       = 0;
640 640
 		$rstring = '';
641
-		while ( $i <= 25 ) {
641
+		while ($i <= 25) {
642 642
 			$num     = rand() % 33;
643
-			$tmp     = substr( $chars, $num, 1 );
644
-			$rstring = $rstring . $tmp;
645
-			$i ++;
643
+			$tmp     = substr($chars, $num, 1);
644
+			$rstring = $rstring.$tmp;
645
+			$i++;
646 646
 		}
647 647
 
648 648
 		return $rstring;
649 649
 	}
650 650
 }
651 651
 
652
-if ( ! function_exists( 'geodir_getDistanceRadius' ) ) {
652
+if (!function_exists('geodir_getDistanceRadius')) {
653 653
 	/**
654 654
 	 * Calculates the distance radius.
655 655
 	 *
@@ -660,9 +660,9 @@  discard block
 block discarded – undo
660 660
 	 *
661 661
 	 * @return float The mean radius.
662 662
 	 */
663
-	function geodir_getDistanceRadius( $uom = 'km' ) {
663
+	function geodir_getDistanceRadius($uom = 'km') {
664 664
 //	Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude
665
-		switch ( geodir_strtolower( $uom ) ):
665
+		switch (geodir_strtolower($uom)):
666 666
 			case 'km'    :
667 667
 				$earthMeanRadius = 6371.009; // km
668 668
 				break;
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 }
695 695
 
696 696
 
697
-if ( ! function_exists( 'geodir_calculateDistanceFromLatLong' ) ) {
697
+if (!function_exists('geodir_calculateDistanceFromLatLong')) {
698 698
 	/**
699 699
 	 * Calculate the great circle distance between two points identified by longitude and latitude.
700 700
 	 *
@@ -707,17 +707,17 @@  discard block
 block discarded – undo
707 707
 	 *
708 708
 	 * @return float The distance.
709 709
 	 */
710
-	function geodir_calculateDistanceFromLatLong( $point1, $point2, $uom = 'km' ) {
710
+	function geodir_calculateDistanceFromLatLong($point1, $point2, $uom = 'km') {
711 711
 //	Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude
712 712
 
713
-		$earthMeanRadius = geodir_getDistanceRadius( $uom );
713
+		$earthMeanRadius = geodir_getDistanceRadius($uom);
714 714
 
715
-		$deltaLatitude  = deg2rad( (float) $point2['latitude'] - (float) $point1['latitude'] );
716
-		$deltaLongitude = deg2rad( (float) $point2['longitude'] - (float) $point1['longitude'] );
717
-		$a              = sin( $deltaLatitude / 2 ) * sin( $deltaLatitude / 2 ) +
718
-		                  cos( deg2rad( (float) $point1['latitude'] ) ) * cos( deg2rad( (float) $point2['latitude'] ) ) *
719
-		                  sin( $deltaLongitude / 2 ) * sin( $deltaLongitude / 2 );
720
-		$c              = 2 * atan2( sqrt( $a ), sqrt( 1 - $a ) );
715
+		$deltaLatitude  = deg2rad((float) $point2['latitude'] - (float) $point1['latitude']);
716
+		$deltaLongitude = deg2rad((float) $point2['longitude'] - (float) $point1['longitude']);
717
+		$a              = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) +
718
+		                  cos(deg2rad((float) $point1['latitude'])) * cos(deg2rad((float) $point2['latitude'])) *
719
+		                  sin($deltaLongitude / 2) * sin($deltaLongitude / 2);
720
+		$c              = 2 * atan2(sqrt($a), sqrt(1 - $a));
721 721
 		$distance       = $earthMeanRadius * $c;
722 722
 
723 723
 		return $distance;
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 }
727 727
 
728 728
 
729
-if ( ! function_exists( 'geodir_sendEmail' ) ) {
729
+if (!function_exists('geodir_sendEmail')) {
730 730
 	/**
731 731
 	 * The main function that send transactional emails using the args provided.
732 732
 	 *
@@ -745,95 +745,95 @@  discard block
 block discarded – undo
745 745
 	 * @param string $post_id       The post ID.
746 746
 	 * @param string $user_id       The user ID.
747 747
 	 */
748
-	function geodir_sendEmail( $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '' ) {
748
+	function geodir_sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') {
749 749
 		$login_details = '';
750 750
 
751 751
 		// strip slashes from subject & message text
752
-		$to_subject = stripslashes_deep( $to_subject );
753
-		$to_message = stripslashes_deep( $to_message );
752
+		$to_subject = stripslashes_deep($to_subject);
753
+		$to_message = stripslashes_deep($to_message);
754 754
 
755
-		if ( $message_type == 'send_friend' ) {
756
-			$subject = get_option( 'geodir_email_friend_subject' );
757
-			$message = get_option( 'geodir_email_friend_content' );
758
-		} elseif ( $message_type == 'send_enquiry' ) {
759
-			$subject = get_option( 'geodir_email_enquiry_subject' );
760
-			$message = get_option( 'geodir_email_enquiry_content' );
755
+		if ($message_type == 'send_friend') {
756
+			$subject = get_option('geodir_email_friend_subject');
757
+			$message = get_option('geodir_email_friend_content');
758
+		} elseif ($message_type == 'send_enquiry') {
759
+			$subject = get_option('geodir_email_enquiry_subject');
760
+			$message = get_option('geodir_email_enquiry_content');
761 761
 
762 762
 			// change to name in some cases
763
-			$post_author = get_post_field( 'post_author', $post_id );
764
-			if(is_super_admin( $post_author  )){// if admin probably not the post author so change name
765
-				$toEmailName = __('Business Owner','geodirectory');
766
-			}elseif(defined('GEODIRCLAIM_VERSION') && geodir_get_post_meta($post_id,'claimed')!='1'){// if claim manager installed but listing not claimed
767
-				$toEmailName = __('Business Owner','geodirectory');
763
+			$post_author = get_post_field('post_author', $post_id);
764
+			if (is_super_admin($post_author)) {// if admin probably not the post author so change name
765
+				$toEmailName = __('Business Owner', 'geodirectory');
766
+			}elseif (defined('GEODIRCLAIM_VERSION') && geodir_get_post_meta($post_id, 'claimed') != '1') {// if claim manager installed but listing not claimed
767
+				$toEmailName = __('Business Owner', 'geodirectory');
768 768
 			}
769 769
 
770 770
 
771
-		} elseif ( $message_type == 'forgot_password' ) {
772
-			$subject       = get_option( 'geodir_forgot_password_subject' );
773
-			$message       = get_option( 'geodir_forgot_password_content' );
771
+		} elseif ($message_type == 'forgot_password') {
772
+			$subject       = get_option('geodir_forgot_password_subject');
773
+			$message       = get_option('geodir_forgot_password_content');
774 774
 			$login_details = $to_message;
775
-		} elseif ( $message_type == 'registration' ) {
776
-			$subject       = get_option( 'geodir_registration_success_email_subject' );
777
-			$message       = get_option( 'geodir_registration_success_email_content' );
775
+		} elseif ($message_type == 'registration') {
776
+			$subject       = get_option('geodir_registration_success_email_subject');
777
+			$message       = get_option('geodir_registration_success_email_content');
778 778
 			$login_details = $to_message;
779
-		} elseif ( $message_type == 'post_submit' ) {
780
-			$subject = get_option( 'geodir_post_submited_success_email_subject' );
781
-			$message = get_option( 'geodir_post_submited_success_email_content' );
782
-		} elseif ( $message_type == 'listing_published' ) {
783
-			$subject = get_option( 'geodir_post_published_email_subject' );
784
-			$message = get_option( 'geodir_post_published_email_content' );
785
-		} elseif ( $message_type == 'listing_edited' ) {
786
-			$subject = get_option( 'geodir_post_edited_email_subject_admin' );
787
-			$message = get_option( 'geodir_post_edited_email_content_admin' );
779
+		} elseif ($message_type == 'post_submit') {
780
+			$subject = get_option('geodir_post_submited_success_email_subject');
781
+			$message = get_option('geodir_post_submited_success_email_content');
782
+		} elseif ($message_type == 'listing_published') {
783
+			$subject = get_option('geodir_post_published_email_subject');
784
+			$message = get_option('geodir_post_published_email_content');
785
+		} elseif ($message_type == 'listing_edited') {
786
+			$subject = get_option('geodir_post_edited_email_subject_admin');
787
+			$message = get_option('geodir_post_edited_email_content_admin');
788 788
 		}
789 789
 
790
-		if ( ! empty( $subject ) ) {
791
-			$subject = __( stripslashes_deep( $subject ), 'geodirectory' );
790
+		if (!empty($subject)) {
791
+			$subject = __(stripslashes_deep($subject), 'geodirectory');
792 792
 		}
793 793
 
794
-		if ( ! empty( $message ) ) {
795
-			$message = __( stripslashes_deep( $message ), 'geodirectory' );
794
+		if (!empty($message)) {
795
+			$message = __(stripslashes_deep($message), 'geodirectory');
796 796
 		}
797 797
 
798
-		$to_message        = nl2br( $to_message );
799
-		$sitefromEmail     = get_option( 'site_email' );
798
+		$to_message        = nl2br($to_message);
799
+		$sitefromEmail     = get_option('site_email');
800 800
 		$sitefromEmailName = get_site_emailName();
801
-		$productlink       = get_permalink( $post_id );
801
+		$productlink       = get_permalink($post_id);
802 802
 
803 803
 		$user_login = '';
804
-		if ( $user_id > 0 && $user_info = get_userdata( $user_id ) ) {
804
+		if ($user_id > 0 && $user_info = get_userdata($user_id)) {
805 805
 			$user_login = $user_info->user_login;
806 806
 		}
807 807
 
808 808
 		$posted_date = '';
809 809
 		$listingLink = '';
810 810
 
811
-		$post_info = get_post( $post_id );
811
+		$post_info = get_post($post_id);
812 812
 
813
-		if ( $post_info ) {
813
+		if ($post_info) {
814 814
 			$posted_date = $post_info->post_date;
815
-			$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
815
+			$listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
816 816
 		}
817 817
 		$siteurl       = home_url();
818
-		$siteurl_link  = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
818
+		$siteurl_link  = '<a href="'.$siteurl.'">'.$siteurl.'</a>';
819 819
 		$loginurl      = geodir_login_url();
820
-		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
820
+		$loginurl_link = '<a href="'.$loginurl.'">login</a>';
821 821
         
822
-		$post_author_id   = ! empty( $post_info ) ? $post_info->post_author : 0;
823
-		$post_author_data = $post_author_id ? get_userdata( $post_author_id ) : NULL;
824
-		$post_author_name = geodir_get_client_name( $post_author_id );
825
-		$post_author_email = !empty( $post_author_data->user_email ) ? $post_author_data->user_email : '';
826
-		$current_date     = date_i18n( 'Y-m-d H:i:s', current_time( 'timestamp' ) );
827
-
828
-		if ( $fromEmail == '' ) {
829
-			$fromEmail = get_option( 'site_email' );
822
+		$post_author_id   = !empty($post_info) ? $post_info->post_author : 0;
823
+		$post_author_data = $post_author_id ? get_userdata($post_author_id) : NULL;
824
+		$post_author_name = geodir_get_client_name($post_author_id);
825
+		$post_author_email = !empty($post_author_data->user_email) ? $post_author_data->user_email : '';
826
+		$current_date     = date_i18n('Y-m-d H:i:s', current_time('timestamp'));
827
+
828
+		if ($fromEmail == '') {
829
+			$fromEmail = get_option('site_email');
830 830
 		}
831 831
 
832
-		if ( $fromEmailName == '' ) {
833
-			$fromEmailName = get_option( 'site_email_name' );
832
+		if ($fromEmailName == '') {
833
+			$fromEmailName = get_option('site_email_name');
834 834
 		}
835 835
 
836
-		$search_array  = array(
836
+		$search_array = array(
837 837
 			'[#listing_link#]',
838 838
 			'[#site_name_url#]',
839 839
 			'[#post_id#]',
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 			$post_author_email,
876 876
 			$current_date,
877 877
 		);
878
-		$message       = str_replace( $search_array, $replace_array, $message );
878
+		$message       = str_replace($search_array, $replace_array, $message);
879 879
 
880 880
 		$search_array  = array(
881 881
 			'[#listing_link#]',
@@ -913,12 +913,12 @@  discard block
 block discarded – undo
913 913
 			$post_author_email,
914 914
 			$current_date
915 915
 		);
916
-		$subject       = str_replace( $search_array, $replace_array, $subject );
916
+		$subject = str_replace($search_array, $replace_array, $subject);
917 917
 
918
-		$headers =  array();
918
+		$headers = array();
919 919
 		$headers[] = 'Content-type: text/html; charset=UTF-8';
920
-		$headers[] = "Reply-To: " . $fromEmail;
921
-		$headers[] = 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>';
920
+		$headers[] = "Reply-To: ".$fromEmail;
921
+		$headers[] = 'From: '.$sitefromEmailName.' <'.$sitefromEmail.'>';
922 922
 
923 923
 		$to = $toEmail;
924 924
 
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 		 * @param string $post_id       The post ID.
941 941
 		 * @param string $user_id       The user ID.
942 942
 		 */
943
-		$to = apply_filters( 'geodir_sendEmail_to', $to, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
943
+		$to = apply_filters('geodir_sendEmail_to', $to, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
944 944
 		/**
945 945
 		 * Filter the client email subject.
946 946
 		 *
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 		 * @param string $post_id       The post ID.
960 960
 		 * @param string $user_id       The user ID.
961 961
 		 */
962
-		$subject = apply_filters( 'geodir_sendEmail_subject', $subject, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
962
+		$subject = apply_filters('geodir_sendEmail_subject', $subject, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
963 963
 		/**
964 964
 		 * Filter the client email message.
965 965
 		 *
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
 		 * @param string $post_id       The post ID.
979 979
 		 * @param string $user_id       The user ID.
980 980
 		 */
981
-		$message = apply_filters( 'geodir_sendEmail_message', $message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
981
+		$message = apply_filters('geodir_sendEmail_message', $message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
982 982
 		/**
983 983
 		 * Filter the client email headers.
984 984
 		 *
@@ -997,39 +997,39 @@  discard block
 block discarded – undo
997 997
 		 * @param string $post_id       The post ID.
998 998
 		 * @param string $user_id       The user ID.
999 999
 		 */
1000
-		$headers = apply_filters( 'geodir_sendEmail_headers', $headers, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
1000
+		$headers = apply_filters('geodir_sendEmail_headers', $headers, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
1001 1001
 
1002
-		$sent = wp_mail( $to, $subject, $message, $headers );
1002
+		$sent = wp_mail($to, $subject, $message, $headers);
1003 1003
 
1004
-		if ( ! $sent ) {
1005
-			if ( is_array( $to ) ) {
1006
-				$to = implode( ',', $to );
1004
+		if (!$sent) {
1005
+			if (is_array($to)) {
1006
+				$to = implode(',', $to);
1007 1007
 			}
1008 1008
 			$log_message = sprintf(
1009
-				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1009
+				__("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1010 1010
 				$message_type,
1011
-				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1011
+				date_i18n('F j Y H:i:s', current_time('timestamp')),
1012 1012
 				$to,
1013 1013
 				$subject
1014 1014
 			);
1015
-			geodir_error_log( $log_message );
1015
+			geodir_error_log($log_message);
1016 1016
 		}
1017 1017
 
1018 1018
 		///////// ADMIN BCC EMIALS
1019
-		$adminEmail = get_bloginfo( 'admin_email' );
1019
+		$adminEmail = get_bloginfo('admin_email');
1020 1020
 		$to         = $adminEmail;
1021 1021
 
1022 1022
 		$admin_bcc = false;
1023
-		if ( $message_type == 'registration' ) {
1024
-			$message_raw  = explode( __( "Password:", 'geodirectory' ), $message );
1025
-			$message_raw2 = explode( "</p>", $message_raw[1], 2 );
1026
-			$message      = $message_raw[0] . __( 'Password:', 'geodirectory' ) . ' **********</p>' . $message_raw2[1];
1023
+		if ($message_type == 'registration') {
1024
+			$message_raw  = explode(__("Password:", 'geodirectory'), $message);
1025
+			$message_raw2 = explode("</p>", $message_raw[1], 2);
1026
+			$message      = $message_raw[0].__('Password:', 'geodirectory').' **********</p>'.$message_raw2[1];
1027 1027
 		}
1028
-		if ( $message_type == 'post_submit' && ( get_option( 'geodir_notify_post_submit' ) || get_option( 'geodir_notify_post_submit', '-1' ) == '-1' ) ) {
1029
-			$subject = __( stripslashes_deep( get_option( 'geodir_post_submited_success_email_subject_admin' ) ), 'geodirectory' );
1030
-			$message = __( stripslashes_deep( get_option( 'geodir_post_submited_success_email_content_admin' ) ), 'geodirectory' );
1028
+		if ($message_type == 'post_submit' && (get_option('geodir_notify_post_submit') || get_option('geodir_notify_post_submit', '-1') == '-1')) {
1029
+			$subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
1030
+			$message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
1031 1031
 
1032
-			$search_array  = array(
1032
+			$search_array = array(
1033 1033
 				'[#listing_link#]',
1034 1034
 				'[#site_name_url#]',
1035 1035
 				'[#post_id#]',
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 				$user_login,
1066 1066
 				$post_author_email,
1067 1067
 			);
1068
-			$message       = str_replace( $search_array, $replace_array, $message );
1068
+			$message       = str_replace($search_array, $replace_array, $message);
1069 1069
 
1070 1070
 			$search_array  = array(
1071 1071
 				'[#listing_link#]',
@@ -1097,26 +1097,26 @@  discard block
 block discarded – undo
1097 1097
 				$user_login,
1098 1098
 				$post_author_email,
1099 1099
 			);
1100
-			$subject       = str_replace( $search_array, $replace_array, $subject );
1100
+			$subject = str_replace($search_array, $replace_array, $subject);
1101 1101
 
1102 1102
 			$subject .= ' - ADMIN BCC COPY';
1103 1103
 			$admin_bcc = true;
1104 1104
 
1105
-		} elseif ( $message_type == 'registration' && get_option( 'geodir_bcc_new_user' ) ) {
1105
+		} elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
1106 1106
 			$subject .= ' - ADMIN BCC COPY';
1107 1107
 			$admin_bcc = true;
1108
-		} elseif ( $message_type == 'send_friend' && get_option( 'geodir_bcc_friend' ) ) {
1108
+		} elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
1109 1109
 			$subject .= ' - ADMIN BCC COPY';
1110 1110
 			$admin_bcc = true;
1111
-		} elseif ( $message_type == 'send_enquiry' && get_option( 'geodir_bcc_enquiry' ) ) {
1111
+		} elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
1112 1112
 			$subject .= ' - ADMIN BCC COPY';
1113 1113
 			$admin_bcc = true;
1114
-		} elseif ( $message_type == 'listing_published' && get_option( 'geodir_bcc_listing_published' ) ) {
1114
+		} elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
1115 1115
 			$subject .= ' - ADMIN BCC COPY';
1116 1116
 			$admin_bcc = true;
1117 1117
 		}
1118 1118
 
1119
-		if ( $admin_bcc === true ) {
1119
+		if ($admin_bcc === true) {
1120 1120
 
1121 1121
 			/**
1122 1122
 			 * Filter the client email subject.
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 			 * @param string $post_id       The post ID.
1137 1137
 			 * @param string $user_id       The user ID.
1138 1138
 			 */
1139
-			$subject = apply_filters( 'geodir_sendEmail_subject_admin_bcc', $subject, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
1139
+			$subject = apply_filters('geodir_sendEmail_subject_admin_bcc', $subject, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
1140 1140
 			/**
1141 1141
 			 * Filter the client email message.
1142 1142
 			 *
@@ -1155,23 +1155,23 @@  discard block
 block discarded – undo
1155 1155
 			 * @param string $post_id       The post ID.
1156 1156
 			 * @param string $user_id       The user ID.
1157 1157
 			 */
1158
-			$message = apply_filters( 'geodir_sendEmail_message_admin_bcc', $message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
1158
+			$message = apply_filters('geodir_sendEmail_message_admin_bcc', $message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
1159 1159
 
1160 1160
 
1161
-			$sent = wp_mail( $to, $subject, $message, $headers );
1161
+			$sent = wp_mail($to, $subject, $message, $headers);
1162 1162
 
1163
-			if ( ! $sent ) {
1164
-				if ( is_array( $to ) ) {
1165
-					$to = implode( ',', $to );
1163
+			if (!$sent) {
1164
+				if (is_array($to)) {
1165
+					$to = implode(',', $to);
1166 1166
 				}
1167 1167
 				$log_message = sprintf(
1168
-					__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1168
+					__("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1169 1169
 					$message_type,
1170
-					date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1170
+					date_i18n('F j Y H:i:s', current_time('timestamp')),
1171 1171
 					$to,
1172 1172
 					$subject
1173 1173
 				);
1174
-				geodir_error_log( $log_message );
1174
+				geodir_error_log($log_message);
1175 1175
 			}
1176 1176
 		}
1177 1177
 
@@ -1187,51 +1187,51 @@  discard block
 block discarded – undo
1187 1187
  */
1188 1188
 function geodir_taxonomy_breadcrumb() {
1189 1189
 
1190
-	$term   = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
1190
+	$term   = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
1191 1191
 	$parent = $term->parent;
1192 1192
 
1193
-	while ( $parent ):
1193
+	while ($parent):
1194 1194
 		$parents[]  = $parent;
1195
-		$new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) );
1195
+		$new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
1196 1196
 		$parent     = $new_parent->parent;
1197 1197
 	endwhile;
1198 1198
 
1199
-	if ( ! empty( $parents ) ):
1200
-		$parents = array_reverse( $parents );
1199
+	if (!empty($parents)):
1200
+		$parents = array_reverse($parents);
1201 1201
 
1202
-		foreach ( $parents as $parent ):
1203
-			$item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) );
1204
-			$url  = get_term_link( $item, get_query_var( 'taxonomy' ) );
1205
-			echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>';
1202
+		foreach ($parents as $parent):
1203
+			$item = get_term_by('id', $parent, get_query_var('taxonomy'));
1204
+			$url  = get_term_link($item, get_query_var('taxonomy'));
1205
+			echo '<li> > <a href="'.$url.'">'.$item->name.'</a></li>';
1206 1206
 		endforeach;
1207 1207
 
1208 1208
 	endif;
1209 1209
 
1210
-	echo '<li> > ' . $term->name . '</li>';
1210
+	echo '<li> > '.$term->name.'</li>';
1211 1211
 }
1212 1212
 
1213
-function geodir_wpml_post_type_archive_link($link, $post_type){
1213
+function geodir_wpml_post_type_archive_link($link, $post_type) {
1214 1214
 	if (geodir_is_wpml()) {
1215
-		$post_types   = get_option( 'geodir_post_types' );
1215
+		$post_types = get_option('geodir_post_types');
1216 1216
 		
1217
-		if ( isset( $post_types[ $post_type ] ) ) {
1218
-			$slug = $post_types[ $post_type ]['rewrite']['slug'];
1217
+		if (isset($post_types[$post_type])) {
1218
+			$slug = $post_types[$post_type]['rewrite']['slug'];
1219 1219
 
1220 1220
 			// Alter the CPT slug if WPML is set to do so
1221
-			if ( geodir_wpml_is_post_type_translated( $post_type ) ) {
1222
-				if ( gd_wpml_slug_translation_turned_on( $post_type ) && $language_code = gd_wpml_get_lang_from_url( $link) ) {
1221
+			if (geodir_wpml_is_post_type_translated($post_type)) {
1222
+				if (gd_wpml_slug_translation_turned_on($post_type) && $language_code = gd_wpml_get_lang_from_url($link)) {
1223 1223
 
1224 1224
 					$org_slug = $slug;
1225
-					$slug     = apply_filters( 'wpml_translate_single_string',
1225
+					$slug     = apply_filters('wpml_translate_single_string',
1226 1226
 						$slug,
1227 1227
 						'WordPress',
1228
-						'URL slug: ' . $slug,
1229
-						$language_code );
1228
+						'URL slug: '.$slug,
1229
+						$language_code);
1230 1230
                     
1231
-					if ( ! $slug ) {
1231
+					if (!$slug) {
1232 1232
 						$slug = $org_slug;
1233 1233
 					} else {
1234
-						$link = str_replace( $org_slug, $slug, $link );
1234
+						$link = str_replace($org_slug, $slug, $link);
1235 1235
 					}
1236 1236
 				}
1237 1237
 			}
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
 
1241 1241
 	return $link;
1242 1242
 }
1243
-add_filter( 'post_type_archive_link','geodir_wpml_post_type_archive_link', 1000, 2);
1243
+add_filter('post_type_archive_link', 'geodir_wpml_post_type_archive_link', 1000, 2);
1244 1244
 
1245 1245
 /**
1246 1246
  * Main function that generates breadcrumb for all pages.
@@ -1261,9 +1261,9 @@  discard block
 block discarded – undo
1261 1261
 	 *
1262 1262
 	 * @since 1.0.0
1263 1263
 	 */
1264
-	$separator = apply_filters( 'geodir_breadcrumb_separator', ' > ' );
1264
+	$separator = apply_filters('geodir_breadcrumb_separator', ' > ');
1265 1265
 
1266
-	if ( ! geodir_is_page( 'home' ) ) {
1266
+	if (!geodir_is_page('home')) {
1267 1267
 		$breadcrumb    = '';
1268 1268
 		$url_categoris = '';
1269 1269
 		$breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">';
@@ -1272,167 +1272,167 @@  discard block
 block discarded – undo
1272 1272
 		 *
1273 1273
 		 * @since 1.0.0
1274 1274
 		 */
1275
-		$breadcrumb .= '<li>' . apply_filters( 'geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __( 'Home', 'geodirectory' ) . '</a>' ) . '</li>';
1275
+		$breadcrumb .= '<li>'.apply_filters('geodir_breadcrumb_first_link', '<a href="'.home_url().'">'.__('Home', 'geodirectory').'</a>').'</li>';
1276 1276
 
1277 1277
 		$gd_post_type   = geodir_get_current_posttype();
1278
-		$post_type_info = get_post_type_object( $gd_post_type );
1278
+		$post_type_info = get_post_type_object($gd_post_type);
1279 1279
 
1280
-		remove_filter( 'post_type_archive_link', 'geodir_get_posttype_link' );
1280
+		remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
1281 1281
 
1282
-		$listing_link = get_post_type_archive_link( $gd_post_type );
1282
+		$listing_link = get_post_type_archive_link($gd_post_type);
1283 1283
 
1284
-		add_filter( 'post_type_archive_link', 'geodir_get_posttype_link', 10, 2 );
1285
-		$listing_link = rtrim( $listing_link, '/' );
1284
+		add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
1285
+		$listing_link = rtrim($listing_link, '/');
1286 1286
 		$listing_link .= '/';
1287 1287
 
1288 1288
 		$post_type_for_location_link = $listing_link;
1289
-		$location_terms              = geodir_get_current_location_terms( 'query_vars', $gd_post_type );
1289
+		$location_terms              = geodir_get_current_location_terms('query_vars', $gd_post_type);
1290 1290
 
1291 1291
 		global $wp, $gd_session;
1292 1292
 		$location_link = $post_type_for_location_link;
1293 1293
 
1294
-		if ( geodir_is_page( 'detail' ) || geodir_is_page( 'listing' ) ) {
1294
+		if (geodir_is_page('detail') || geodir_is_page('listing')) {
1295 1295
 			global $post;
1296
-			$location_manager     = defined( 'POST_LOCATION_TABLE' ) ? true : false;
1297
-			$neighbourhood_active = $location_manager && get_option( 'location_neighbourhoods' ) ? true : false;
1296
+			$location_manager     = defined('POST_LOCATION_TABLE') ? true : false;
1297
+			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
1298 1298
 
1299
-			if ( geodir_is_page( 'detail' ) && isset( $post->country_slug ) ) {
1299
+			if (geodir_is_page('detail') && isset($post->country_slug)) {
1300 1300
 				$location_terms = array(
1301 1301
 					'gd_country' => $post->country_slug,
1302 1302
 					'gd_region'  => $post->region_slug,
1303 1303
 					'gd_city'    => $post->city_slug
1304 1304
 				);
1305 1305
 
1306
-				if ( $neighbourhood_active && ! empty( $location_terms['gd_city'] ) && $gd_ses_neighbourhood = $gd_session->get( 'gd_neighbourhood' ) ) {
1306
+				if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
1307 1307
 					$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
1308 1308
 				}
1309 1309
 			}
1310 1310
 
1311
-			$geodir_show_location_url = get_option( 'geodir_show_location_url' );
1311
+			$geodir_show_location_url = get_option('geodir_show_location_url');
1312 1312
 
1313 1313
 			$hide_url_part = array();
1314
-			if ( $location_manager ) {
1315
-				$hide_country_part = get_option( 'geodir_location_hide_country_part' );
1316
-				$hide_region_part  = get_option( 'geodir_location_hide_region_part' );
1317
-
1318
-				if ( $hide_region_part && $hide_country_part ) {
1319
-					$hide_url_part = array( 'gd_country', 'gd_region' );
1320
-				} else if ( $hide_region_part && ! $hide_country_part ) {
1321
-					$hide_url_part = array( 'gd_region' );
1322
-				} else if ( ! $hide_region_part && $hide_country_part ) {
1323
-					$hide_url_part = array( 'gd_country' );
1314
+			if ($location_manager) {
1315
+				$hide_country_part = get_option('geodir_location_hide_country_part');
1316
+				$hide_region_part  = get_option('geodir_location_hide_region_part');
1317
+
1318
+				if ($hide_region_part && $hide_country_part) {
1319
+					$hide_url_part = array('gd_country', 'gd_region');
1320
+				} else if ($hide_region_part && !$hide_country_part) {
1321
+					$hide_url_part = array('gd_region');
1322
+				} else if (!$hide_region_part && $hide_country_part) {
1323
+					$hide_url_part = array('gd_country');
1324 1324
 				}
1325 1325
 			}
1326 1326
 
1327 1327
 			$hide_text_part = array();
1328
-			if ( $geodir_show_location_url == 'country_city' ) {
1329
-				$hide_text_part = array( 'gd_region' );
1328
+			if ($geodir_show_location_url == 'country_city') {
1329
+				$hide_text_part = array('gd_region');
1330 1330
 
1331
-				if ( isset( $location_terms['gd_region'] ) && ! $location_manager ) {
1332
-					unset( $location_terms['gd_region'] );
1331
+				if (isset($location_terms['gd_region']) && !$location_manager) {
1332
+					unset($location_terms['gd_region']);
1333 1333
 				}
1334
-			} else if ( $geodir_show_location_url == 'region_city' ) {
1335
-				$hide_text_part = array( 'gd_country' );
1334
+			} else if ($geodir_show_location_url == 'region_city') {
1335
+				$hide_text_part = array('gd_country');
1336 1336
 
1337
-				if ( isset( $location_terms['gd_country'] ) && ! $location_manager ) {
1338
-					unset( $location_terms['gd_country'] );
1337
+				if (isset($location_terms['gd_country']) && !$location_manager) {
1338
+					unset($location_terms['gd_country']);
1339 1339
 				}
1340
-			} else if ( $geodir_show_location_url == 'city' ) {
1341
-				$hide_text_part = array( 'gd_country', 'gd_region' );
1340
+			} else if ($geodir_show_location_url == 'city') {
1341
+				$hide_text_part = array('gd_country', 'gd_region');
1342 1342
 
1343
-				if ( isset( $location_terms['gd_country'] ) && ! $location_manager ) {
1344
-					unset( $location_terms['gd_country'] );
1343
+				if (isset($location_terms['gd_country']) && !$location_manager) {
1344
+					unset($location_terms['gd_country']);
1345 1345
 				}
1346
-				if ( isset( $location_terms['gd_region'] ) && ! $location_manager ) {
1347
-					unset( $location_terms['gd_region'] );
1346
+				if (isset($location_terms['gd_region']) && !$location_manager) {
1347
+					unset($location_terms['gd_region']);
1348 1348
 				}
1349 1349
 			}
1350 1350
 
1351 1351
 			$is_location_last = '';
1352 1352
 			$is_taxonomy_last = '';
1353 1353
 			$breadcrumb .= '<li>';
1354
-			if ( get_query_var( $gd_post_type . 'category' ) ) {
1355
-				$gd_taxonomy = $gd_post_type . 'category';
1356
-			} elseif ( get_query_var( $gd_post_type . '_tags' ) ) {
1357
-				$gd_taxonomy = $gd_post_type . '_tags';
1354
+			if (get_query_var($gd_post_type.'category')) {
1355
+				$gd_taxonomy = $gd_post_type.'category';
1356
+			} elseif (get_query_var($gd_post_type.'_tags')) {
1357
+				$gd_taxonomy = $gd_post_type.'_tags';
1358 1358
 			}
1359 1359
 
1360
-			$breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __( geodir_utf8_ucfirst( $post_type_info->label ), 'geodirectory' ) . '</a>';
1361
-			if ( ! empty( $gd_taxonomy ) || geodir_is_page( 'detail' ) ) {
1360
+			$breadcrumb .= $separator.'<a href="'.$listing_link.'">'.__(geodir_utf8_ucfirst($post_type_info->label), 'geodirectory').'</a>';
1361
+			if (!empty($gd_taxonomy) || geodir_is_page('detail')) {
1362 1362
 				$is_location_last = false;
1363 1363
 			} else {
1364 1364
 				$is_location_last = true;
1365 1365
 			}
1366 1366
 
1367
-			if ( ! empty( $gd_taxonomy ) && geodir_is_page( 'listing' ) ) {
1367
+			if (!empty($gd_taxonomy) && geodir_is_page('listing')) {
1368 1368
 				$is_taxonomy_last = true;
1369 1369
 			} else {
1370 1370
 				$is_taxonomy_last = false;
1371 1371
 			}
1372 1372
 
1373
-			if ( ! empty( $location_terms ) ) {
1374
-				$geodir_get_locations = function_exists( 'get_actual_location_name' ) ? true : false;
1373
+			if (!empty($location_terms)) {
1374
+				$geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
1375 1375
 
1376
-				foreach ( $location_terms as $key => $location_term ) {
1377
-					if ( $location_term != '' ) {
1378
-						if ( ! empty( $hide_url_part ) && in_array( $key, $hide_url_part ) ) { // Hide location part from url & breadcrumb.
1376
+				foreach ($location_terms as $key => $location_term) {
1377
+					if ($location_term != '') {
1378
+						if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
1379 1379
 							continue;
1380 1380
 						}
1381 1381
 
1382
-						$gd_location_link_text = preg_replace( '/-(\d+)$/', '', $location_term );
1383
-						$gd_location_link_text = preg_replace( '/[_-]/', ' ', $gd_location_link_text );
1384
-						$gd_location_link_text = geodir_utf8_ucfirst( $gd_location_link_text );
1382
+						$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
1383
+						$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
1384
+						$gd_location_link_text = geodir_utf8_ucfirst($gd_location_link_text);
1385 1385
 
1386 1386
 						$location_term_actual_country = '';
1387 1387
 						$location_term_actual_region  = '';
1388 1388
 						$location_term_actual_city    = '';
1389 1389
 						$location_term_actual_neighbourhood = '';
1390
-						if ( $geodir_get_locations ) {
1391
-							if ( $key == 'gd_country' ) {
1392
-								$location_term_actual_country = get_actual_location_name( 'country', $location_term, true );
1393
-							} else if ( $key == 'gd_region' ) {
1394
-								$location_term_actual_region = get_actual_location_name( 'region', $location_term, true );
1395
-							} else if ( $key == 'gd_city' ) {
1396
-								$location_term_actual_city = get_actual_location_name( 'city', $location_term, true );
1397
-							} else if ( $key == 'gd_neighbourhood' ) {
1398
-								$location_term_actual_neighbourhood = get_actual_location_name( 'neighbourhood', $location_term, true );
1390
+						if ($geodir_get_locations) {
1391
+							if ($key == 'gd_country') {
1392
+								$location_term_actual_country = get_actual_location_name('country', $location_term, true);
1393
+							} else if ($key == 'gd_region') {
1394
+								$location_term_actual_region = get_actual_location_name('region', $location_term, true);
1395
+							} else if ($key == 'gd_city') {
1396
+								$location_term_actual_city = get_actual_location_name('city', $location_term, true);
1397
+							} else if ($key == 'gd_neighbourhood') {
1398
+								$location_term_actual_neighbourhood = get_actual_location_name('neighbourhood', $location_term, true);
1399 1399
 							}
1400 1400
 						} else {
1401 1401
 							$location_info = geodir_get_location();
1402 1402
 
1403
-							if ( ! empty( $location_info ) && isset( $location_info->location_id ) ) {
1404
-								if ( $key == 'gd_country' ) {
1405
-									$location_term_actual_country = __( $location_info->country, 'geodirectory' );
1406
-								} else if ( $key == 'gd_region' ) {
1407
-									$location_term_actual_region = __( $location_info->region, 'geodirectory' );
1408
-								} else if ( $key == 'gd_city' ) {
1409
-									$location_term_actual_city = __( $location_info->city, 'geodirectory' );
1403
+							if (!empty($location_info) && isset($location_info->location_id)) {
1404
+								if ($key == 'gd_country') {
1405
+									$location_term_actual_country = __($location_info->country, 'geodirectory');
1406
+								} else if ($key == 'gd_region') {
1407
+									$location_term_actual_region = __($location_info->region, 'geodirectory');
1408
+								} else if ($key == 'gd_city') {
1409
+									$location_term_actual_city = __($location_info->city, 'geodirectory');
1410 1410
 								}
1411 1411
 							}
1412 1412
 						}
1413 1413
 
1414
-						if ( $is_location_last && $key == 'gd_country' && ! ( isset( $location_terms['gd_region'] ) && $location_terms['gd_region'] != '' ) && ! ( isset( $location_terms['gd_city'] ) && $location_terms['gd_city'] != '' ) ) {
1415
-							$breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text;
1416
-						} else if ( $is_location_last && $key == 'gd_region' && ! ( isset( $location_terms['gd_city'] ) && $location_terms['gd_city'] != '' ) ) {
1417
-							$breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text;
1418
-						} else if ( $is_location_last && $key == 'gd_city' && empty( $location_terms['gd_neighbourhood'] ) ) {
1419
-							$breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text;
1420
-						} else if ( $is_location_last && $key == 'gd_neighbourhood' ) {
1421
-							$breadcrumb .= $location_term_actual_neighbourhood != '' ? $separator . $location_term_actual_neighbourhood : $separator . $gd_location_link_text;
1414
+						if ($is_location_last && $key == 'gd_country' && !(isset($location_terms['gd_region']) && $location_terms['gd_region'] != '') && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
1415
+							$breadcrumb .= $location_term_actual_country != '' ? $separator.$location_term_actual_country : $separator.$gd_location_link_text;
1416
+						} else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
1417
+							$breadcrumb .= $location_term_actual_region != '' ? $separator.$location_term_actual_region : $separator.$gd_location_link_text;
1418
+						} else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
1419
+							$breadcrumb .= $location_term_actual_city != '' ? $separator.$location_term_actual_city : $separator.$gd_location_link_text;
1420
+						} else if ($is_location_last && $key == 'gd_neighbourhood') {
1421
+							$breadcrumb .= $location_term_actual_neighbourhood != '' ? $separator.$location_term_actual_neighbourhood : $separator.$gd_location_link_text;
1422 1422
 						} else {
1423
-							if ( get_option( 'permalink_structure' ) != '' ) {
1424
-								$location_link .= $location_term . '/';
1423
+							if (get_option('permalink_structure') != '') {
1424
+								$location_link .= $location_term.'/';
1425 1425
 							} else {
1426
-								$location_link .= "&$key=" . $location_term;
1426
+								$location_link .= "&$key=".$location_term;
1427 1427
 							}
1428 1428
 
1429
-							if ( $key == 'gd_country' && $location_term_actual_country != '' ) {
1429
+							if ($key == 'gd_country' && $location_term_actual_country != '') {
1430 1430
 								$gd_location_link_text = $location_term_actual_country;
1431
-							} else if ( $key == 'gd_region' && $location_term_actual_region != '' ) {
1431
+							} else if ($key == 'gd_region' && $location_term_actual_region != '') {
1432 1432
 								$gd_location_link_text = $location_term_actual_region;
1433
-							} else if ( $key == 'gd_city' && $location_term_actual_city != '' ) {
1433
+							} else if ($key == 'gd_city' && $location_term_actual_city != '') {
1434 1434
 								$gd_location_link_text = $location_term_actual_city;
1435
-							} else if ( $key == 'gd_neighbourhood' && $location_term_actual_neighbourhood != '' ) {
1435
+							} else if ($key == 'gd_neighbourhood' && $location_term_actual_neighbourhood != '') {
1436 1436
 								$gd_location_link_text = $location_term_actual_neighbourhood;
1437 1437
 							}
1438 1438
 
@@ -1442,77 +1442,77 @@  discard block
 block discarded – undo
1442 1442
                             }
1443 1443
                             */
1444 1444
 
1445
-							$breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>';
1445
+							$breadcrumb .= $separator.'<a href="'.$location_link.'">'.$gd_location_link_text.'</a>';
1446 1446
 						}
1447 1447
 					}
1448 1448
 				}
1449 1449
 			}
1450 1450
 
1451
-			if ( ! empty( $gd_taxonomy ) ) {
1451
+			if (!empty($gd_taxonomy)) {
1452 1452
 				$term_index = 1;
1453 1453
 
1454 1454
 				//if(get_option('geodir_add_categories_url'))
1455 1455
 				{
1456
-					if ( get_query_var( $gd_post_type . '_tags' ) ) {
1457
-						$cat_link = $listing_link . 'tags/';
1456
+					if (get_query_var($gd_post_type.'_tags')) {
1457
+						$cat_link = $listing_link.'tags/';
1458 1458
 					} else {
1459 1459
 						$cat_link = $listing_link;
1460 1460
 					}
1461 1461
 
1462
-					foreach ( $location_terms as $key => $location_term ) {
1463
-						if ( $location_manager && in_array( $key, $hide_url_part ) ) {
1462
+					foreach ($location_terms as $key => $location_term) {
1463
+						if ($location_manager && in_array($key, $hide_url_part)) {
1464 1464
 							continue;
1465 1465
 						}
1466 1466
 
1467
-						if ( $location_term != '' ) {
1468
-							if ( get_option( 'permalink_structure' ) != '' ) {
1469
-								$cat_link .= $location_term . '/';
1467
+						if ($location_term != '') {
1468
+							if (get_option('permalink_structure') != '') {
1469
+								$cat_link .= $location_term.'/';
1470 1470
 							}
1471 1471
 						}
1472 1472
 					}
1473 1473
 
1474
-					$term_array = explode( "/", trim( $wp_query->query[ $gd_taxonomy ], "/" ) );
1475
-					foreach ( $term_array as $term ) {
1476
-						$term_link_text = preg_replace( '/-(\d+)$/', '', $term );
1477
-						$term_link_text = preg_replace( '/[_-]/', ' ', $term_link_text );
1474
+					$term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
1475
+					foreach ($term_array as $term) {
1476
+						$term_link_text = preg_replace('/-(\d+)$/', '', $term);
1477
+						$term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
1478 1478
 
1479 1479
 						// get term actual name
1480
-						$term_info = get_term_by( 'slug', $term, $gd_taxonomy, 'ARRAY_A' );
1481
-						if ( ! empty( $term_info ) && isset( $term_info['name'] ) && $term_info['name'] != '' ) {
1482
-							$term_link_text = urldecode( $term_info['name'] );
1480
+						$term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
1481
+						if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
1482
+							$term_link_text = urldecode($term_info['name']);
1483 1483
 						} else {
1484 1484
 							continue;
1485 1485
 							//$term_link_text = wp_strip_all_tags(geodir_ucwords(urldecode($term_link_text)));
1486 1486
 						}
1487 1487
 
1488
-						if ( $term_index == count( $term_array ) && $is_taxonomy_last ) {
1489
-							$breadcrumb .= $separator . $term_link_text;
1488
+						if ($term_index == count($term_array) && $is_taxonomy_last) {
1489
+							$breadcrumb .= $separator.$term_link_text;
1490 1490
 						} else {
1491
-							$cat_link .= $term . '/';
1492
-							$breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1491
+							$cat_link .= $term.'/';
1492
+							$breadcrumb .= $separator.'<a href="'.$cat_link.'">'.$term_link_text.'</a>';
1493 1493
 						}
1494
-						$term_index ++;
1494
+						$term_index++;
1495 1495
 					}
1496 1496
 				}
1497 1497
 
1498 1498
 
1499 1499
 			}
1500 1500
 
1501
-			if ( geodir_is_page( 'detail' ) ) {
1502
-				$breadcrumb .= $separator . get_the_title();
1501
+			if (geodir_is_page('detail')) {
1502
+				$breadcrumb .= $separator.get_the_title();
1503 1503
 			}
1504 1504
 
1505 1505
 			$breadcrumb .= '</li>';
1506 1506
 
1507 1507
 
1508
-		} elseif ( geodir_is_page( 'author' ) ) {
1508
+		} elseif (geodir_is_page('author')) {
1509 1509
 			$dashboard_post_type = isset($_REQUEST['stype']) ? sanitize_text_field($_REQUEST['stype']) : $gd_post_type;
1510 1510
 			$user_id             = get_current_user_id();
1511
-			$author_link         = get_author_posts_url( $user_id );
1512
-			$default_author_link = geodir_getlink( $author_link, array(
1511
+			$author_link         = get_author_posts_url($user_id);
1512
+			$default_author_link = geodir_getlink($author_link, array(
1513 1513
 				'geodir_dashbord' => 'true',
1514 1514
 				'stype'           => $dashboard_post_type
1515
-			), false );
1515
+			), false);
1516 1516
 
1517 1517
 			/**
1518 1518
 			 * Filter author page link.
@@ -1522,16 +1522,16 @@  discard block
 block discarded – undo
1522 1522
 			 * @param string $default_author_link Default author link.
1523 1523
 			 * @param int $user_id                Author ID.
1524 1524
 			 */
1525
-			$default_author_link = apply_filters( 'geodir_dashboard_author_link', $default_author_link, $user_id );
1525
+			$default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
1526 1526
 
1527 1527
 			$breadcrumb .= '<li>';
1528
-			$breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __( 'My Dashboard', 'geodirectory' ) . '</a>';
1528
+			$breadcrumb .= $separator.'<a href="'.$default_author_link.'">'.__('My Dashboard', 'geodirectory').'</a>';
1529 1529
 
1530
-			if ( isset( $_REQUEST['list'] ) ) {
1531
-				$author_link = geodir_getlink( $author_link, array(
1530
+			if (isset($_REQUEST['list'])) {
1531
+				$author_link = geodir_getlink($author_link, array(
1532 1532
 					'geodir_dashbord' => 'true',
1533 1533
 					'stype'           => $_REQUEST['stype']
1534
-				), false );
1534
+				), false);
1535 1535
 
1536 1536
 				/**
1537 1537
 				 * Filter author page link.
@@ -1542,61 +1542,61 @@  discard block
 block discarded – undo
1542 1542
 				 * @param int $user_id        Author ID.
1543 1543
 				 * @param string $_REQUEST    ['stype'] Post type.
1544 1544
 				 */
1545
-				$author_link = apply_filters( 'geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype'] );
1545
+				$author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
1546 1546
 
1547
-				$breadcrumb .= $separator . '<a href="' . $author_link . '">' . __( geodir_utf8_ucfirst( $post_type_info->label ), 'geodirectory' ) . '</a>';
1548
-				$breadcrumb .= $separator . geodir_utf8_ucfirst( __( 'My', 'geodirectory' ) . ' ' . $_REQUEST['list'] );
1547
+				$breadcrumb .= $separator.'<a href="'.$author_link.'">'.__(geodir_utf8_ucfirst($post_type_info->label), 'geodirectory').'</a>';
1548
+				$breadcrumb .= $separator.geodir_utf8_ucfirst(__('My', 'geodirectory').' '.$_REQUEST['list']);
1549 1549
 			} else {
1550
-				$breadcrumb .= $separator . __( geodir_utf8_ucfirst( $post_type_info->label ), 'geodirectory' );
1550
+				$breadcrumb .= $separator.__(geodir_utf8_ucfirst($post_type_info->label), 'geodirectory');
1551 1551
 			}
1552 1552
 
1553 1553
 			$breadcrumb .= '</li>';
1554
-		} elseif ( is_category() || is_single() ) {
1554
+		} elseif (is_category() || is_single()) {
1555 1555
 			$category = get_the_category();
1556
-			if ( is_category() ) {
1557
-				$breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>';
1556
+			if (is_category()) {
1557
+				$breadcrumb .= '<li>'.$separator.$category[0]->cat_name.'</li>';
1558 1558
 			}
1559
-			if ( is_single() ) {
1560
-				$breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link( $category[0]->term_id ) . '">' . $category[0]->cat_name . '</a></li>';
1561
-				$breadcrumb .= '<li>' . $separator . get_the_title() . '</li>';
1559
+			if (is_single()) {
1560
+				$breadcrumb .= '<li>'.$separator.'<a href="'.get_category_link($category[0]->term_id).'">'.$category[0]->cat_name.'</a></li>';
1561
+				$breadcrumb .= '<li>'.$separator.get_the_title().'</li>';
1562 1562
 			}
1563 1563
 			/* End of my version ##################################################### */
1564
-		} else if ( is_page() ) {
1564
+		} else if (is_page()) {
1565 1565
 			$page_title = get_the_title();
1566 1566
 
1567
-			if ( geodir_is_page( 'location' ) ) {
1567
+			if (geodir_is_page('location')) {
1568 1568
 				$location_page_id = geodir_location_page_id();
1569
-				$loc_post         = get_post( $location_page_id );
1569
+				$loc_post         = get_post($location_page_id);
1570 1570
 				$post_name        = $loc_post->post_name;
1571
-				$slug             = ucwords( str_replace( '-', ' ', $post_name ) );
1572
-				$page_title       = ! empty( $slug ) ? $slug : __( 'Location', 'geodirectory' );
1571
+				$slug             = ucwords(str_replace('-', ' ', $post_name));
1572
+				$page_title       = !empty($slug) ? $slug : __('Location', 'geodirectory');
1573 1573
 			}
1574 1574
 
1575
-			$breadcrumb .= '<li>' . $separator;
1576
-			$breadcrumb .= stripslashes_deep( $page_title );
1575
+			$breadcrumb .= '<li>'.$separator;
1576
+			$breadcrumb .= stripslashes_deep($page_title);
1577 1577
 			$breadcrumb .= '</li>';
1578
-		} else if ( is_tag() ) {
1579
-			$breadcrumb .= "<li> " . $separator . single_tag_title( '', false ) . '</li>';
1580
-		} else if ( is_day() ) {
1581
-			$breadcrumb .= "<li> " . $separator . __( " Archive for", 'geodirectory' ) . " ";
1582
-			the_time( 'F jS, Y' );
1578
+		} else if (is_tag()) {
1579
+			$breadcrumb .= "<li> ".$separator.single_tag_title('', false).'</li>';
1580
+		} else if (is_day()) {
1581
+			$breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
1582
+			the_time('F jS, Y');
1583 1583
 			$breadcrumb .= '</li>';
1584
-		} else if ( is_month() ) {
1585
-			$breadcrumb .= "<li> " . $separator . __( " Archive for", 'geodirectory' ) . " ";
1586
-			the_time( 'F, Y' );
1584
+		} else if (is_month()) {
1585
+			$breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
1586
+			the_time('F, Y');
1587 1587
 			$breadcrumb .= '</li>';
1588
-		} else if ( is_year() ) {
1589
-			$breadcrumb .= "<li> " . $separator . __( " Archive for", 'geodirectory' ) . " ";
1590
-			the_time( 'Y' );
1588
+		} else if (is_year()) {
1589
+			$breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
1590
+			the_time('Y');
1591 1591
 			$breadcrumb .= '</li>';
1592
-		} else if ( is_author() ) {
1593
-			$breadcrumb .= "<li> " . $separator . __( " Author Archive", 'geodirectory' );
1592
+		} else if (is_author()) {
1593
+			$breadcrumb .= "<li> ".$separator.__(" Author Archive", 'geodirectory');
1594 1594
 			$breadcrumb .= '</li>';
1595
-		} else if ( isset( $_GET['paged'] ) && ! empty( $_GET['paged'] ) ) {
1596
-			$breadcrumb .= "<li>" . $separator . __( "Blog Archives", 'geodirectory' );
1595
+		} else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1596
+			$breadcrumb .= "<li>".$separator.__("Blog Archives", 'geodirectory');
1597 1597
 			$breadcrumb .= '</li>';
1598
-		} else if ( is_search() ) {
1599
-			$breadcrumb .= "<li> " . $separator . __( " Search Results", 'geodirectory' );
1598
+		} else if (is_search()) {
1599
+			$breadcrumb .= "<li> ".$separator.__(" Search Results", 'geodirectory');
1600 1600
 			$breadcrumb .= '</li>';
1601 1601
 		}
1602 1602
 		$breadcrumb .= '</ul></div>';
@@ -1609,13 +1609,13 @@  discard block
 block discarded – undo
1609 1609
 		 * @param string $breadcrumb Breadcrumb HTML.
1610 1610
 		 * @param string $separator  Breadcrumb separator.
1611 1611
 		 */
1612
-		echo $breadcrumb = apply_filters( 'geodir_breadcrumb', $breadcrumb, $separator );
1612
+		echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
1613 1613
 	}
1614 1614
 }
1615 1615
 
1616 1616
 
1617
-add_action( "admin_init", "geodir_allow_wpadmin" ); // check user is admin
1618
-if ( ! function_exists( 'geodir_allow_wpadmin' ) ) {
1617
+add_action("admin_init", "geodir_allow_wpadmin"); // check user is admin
1618
+if (!function_exists('geodir_allow_wpadmin')) {
1619 1619
 	/**
1620 1620
 	 * Allow only admins to access wp-admin.
1621 1621
 	 *
@@ -1627,12 +1627,12 @@  discard block
 block discarded – undo
1627 1627
 	 */
1628 1628
 	function geodir_allow_wpadmin() {
1629 1629
 		global $wpdb;
1630
-		if ( get_option( 'geodir_allow_wpadmin' ) == '0' && is_user_logged_in() && ( ! defined( 'DOING_AJAX' ) ) ) // checking action in request to allow ajax request go through
1630
+		if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!defined('DOING_AJAX'))) // checking action in request to allow ajax request go through
1631 1631
 		{
1632
-			if ( current_user_can( 'administrator' ) ) {
1632
+			if (current_user_can('administrator')) {
1633 1633
 			} else {
1634 1634
 
1635
-				wp_redirect( home_url() );
1635
+				wp_redirect(home_url());
1636 1636
 				exit;
1637 1637
 			}
1638 1638
 
@@ -1651,23 +1651,23 @@  discard block
 block discarded – undo
1651 1651
  *
1652 1652
  * @return array|WP_Error The uploaded data as array. When failure returns error.
1653 1653
  */
1654
-function fetch_remote_file( $url ) {
1654
+function fetch_remote_file($url) {
1655 1655
 	// extract the file name and extension from the url
1656
-	require_once( ABSPATH . 'wp-includes/pluggable.php' );
1657
-	$file_name = basename( $url );
1658
-	if ( strpos( $file_name, '?' ) !== false ) {
1659
-		list( $file_name ) = explode( '?', $file_name );
1656
+	require_once(ABSPATH.'wp-includes/pluggable.php');
1657
+	$file_name = basename($url);
1658
+	if (strpos($file_name, '?') !== false) {
1659
+		list($file_name) = explode('?', $file_name);
1660 1660
 	}
1661 1661
 	$dummy        = false;
1662 1662
 	$add_to_cache = false;
1663 1663
 	$key          = null;
1664
-	if ( strpos( $url, '/dummy/' ) !== false ) {
1664
+	if (strpos($url, '/dummy/') !== false) {
1665 1665
 		$dummy = true;
1666
-		$key   = "dummy_" . str_replace( '.', '_', $file_name );
1667
-		$value = get_transient( 'cached_dummy_images' );
1668
-		if ( $value ) {
1669
-			if ( isset( $value[ $key ] ) ) {
1670
-				return $value[ $key ];
1666
+		$key   = "dummy_".str_replace('.', '_', $file_name);
1667
+		$value = get_transient('cached_dummy_images');
1668
+		if ($value) {
1669
+			if (isset($value[$key])) {
1670
+				return $value[$key];
1671 1671
 			} else {
1672 1672
 				$add_to_cache = true;
1673 1673
 			}
@@ -1678,62 +1678,62 @@  discard block
 block discarded – undo
1678 1678
 
1679 1679
 	// get placeholder file in the upload dir with a unique, sanitized filename
1680 1680
 
1681
-	$post_upload_date = isset( $post['upload_date'] ) ? $post['upload_date'] : '';
1681
+	$post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1682 1682
 
1683
-	$upload = wp_upload_bits( $file_name, 0, '', $post_upload_date );
1684
-	if ( $upload['error'] ) {
1685
-		return new WP_Error( 'upload_dir_error', $upload['error'] );
1683
+	$upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1684
+	if ($upload['error']) {
1685
+		return new WP_Error('upload_dir_error', $upload['error']);
1686 1686
 	}
1687 1687
 
1688 1688
 
1689
-	sleep( 0.3 );// if multiple remote file this can cause the remote server to timeout so we add a slight delay
1689
+	sleep(0.3); // if multiple remote file this can cause the remote server to timeout so we add a slight delay
1690 1690
 
1691 1691
 	// fetch the remote url and write it to the placeholder file
1692
-	$headers = wp_remote_get( $url, array( 'stream' => true, 'filename' => $upload['file'] ) );
1692
+	$headers = wp_remote_get($url, array('stream' => true, 'filename' => $upload['file']));
1693 1693
 
1694 1694
 	$log_message = '';
1695
-	if ( is_wp_error( $headers ) ) {
1696
-		echo 'file: ' . $url;
1695
+	if (is_wp_error($headers)) {
1696
+		echo 'file: '.$url;
1697 1697
 
1698
-		return new WP_Error( 'import_file_error', $headers->get_error_message() );
1698
+		return new WP_Error('import_file_error', $headers->get_error_message());
1699 1699
 	}
1700 1700
 
1701 1701
 	// clear cache to make compat with EWWW Image Optimizer
1702
-	if(defined( 'EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE')){
1702
+	if (defined('EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE')) {
1703 1703
 		clearstatcache();
1704 1704
 	}
1705
-	$filesize = filesize( $upload['file'] );
1705
+	$filesize = filesize($upload['file']);
1706 1706
 	// request failed
1707
-	if ( ! $headers ) {
1708
-		$log_message = __( 'Remote server did not respond', 'geodirectory' );
1707
+	if (!$headers) {
1708
+		$log_message = __('Remote server did not respond', 'geodirectory');
1709 1709
 	} // make sure the fetch was successful
1710
-	elseif ( $headers['response']['code'] != '200' ) {
1711
-		$log_message = sprintf( __( 'Remote server returned error response %1$d %2$s', 'geodirectory' ), esc_html( $headers['response'] ), get_status_header_desc( $headers['response'] ) );
1712
-	} elseif ( isset( $headers['headers']['content-length'] ) && $filesize != $headers['headers']['content-length'] ) {
1713
-		$log_message = __( 'Remote file is incorrect size', 'geodirectory' );
1714
-	} elseif ( 0 == $filesize ) {
1715
-		$log_message = __( 'Zero size file downloaded', 'geodirectory' );
1716
-	}
1717
-
1718
-	if ( $log_message ) {
1719
-		$del = unlink( $upload['file'] );
1720
-		if ( ! $del ) {
1721
-			geodir_error_log( __( 'GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory' ) );
1710
+	elseif ($headers['response']['code'] != '200') {
1711
+		$log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1712
+	} elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1713
+		$log_message = __('Remote file is incorrect size', 'geodirectory');
1714
+	} elseif (0 == $filesize) {
1715
+		$log_message = __('Zero size file downloaded', 'geodirectory');
1716
+	}
1717
+
1718
+	if ($log_message) {
1719
+		$del = unlink($upload['file']);
1720
+		if (!$del) {
1721
+			geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));
1722 1722
 		}
1723 1723
 
1724
-		return new WP_Error( 'import_file_error', $log_message );
1724
+		return new WP_Error('import_file_error', $log_message);
1725 1725
 	}
1726 1726
 
1727
-	if ( $dummy && $add_to_cache && is_array( $upload ) ) {
1728
-		$images = get_transient( 'cached_dummy_images' );
1729
-		if ( is_array( $images ) ) {
1730
-			$images[ $key ] = $upload;
1727
+	if ($dummy && $add_to_cache && is_array($upload)) {
1728
+		$images = get_transient('cached_dummy_images');
1729
+		if (is_array($images)) {
1730
+			$images[$key] = $upload;
1731 1731
 		} else {
1732
-			$images = array( $key => $upload );
1732
+			$images = array($key => $upload);
1733 1733
 		}
1734 1734
 
1735 1735
 		//setting the cache using the WP Transient API
1736
-		set_transient( 'cached_dummy_images', $images, 60 * 10 ); //10 minutes cache
1736
+		set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
1737 1737
 	}
1738 1738
 
1739 1739
 	return $upload;
@@ -1747,12 +1747,12 @@  discard block
 block discarded – undo
1747 1747
  * @return string|void Max upload size.
1748 1748
  */
1749 1749
 function geodir_max_upload_size() {
1750
-	$max_filesize = (float) get_option( 'geodir_upload_max_filesize', 2 );
1750
+	$max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
1751 1751
 
1752
-	if ( $max_filesize > 0 && $max_filesize < 1 ) {
1753
-		$max_filesize = (int) ( $max_filesize * 1024 ) . 'kb';
1752
+	if ($max_filesize > 0 && $max_filesize < 1) {
1753
+		$max_filesize = (int) ($max_filesize * 1024).'kb';
1754 1754
 	} else {
1755
-		$max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1755
+		$max_filesize = $max_filesize > 0 ? $max_filesize.'mb' : '2mb';
1756 1756
 	}
1757 1757
 
1758 1758
 	/**
@@ -1762,7 +1762,7 @@  discard block
 block discarded – undo
1762 1762
 	 *
1763 1763
 	 * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1764 1764
 	 */
1765
-	return apply_filters( 'geodir_default_image_upload_size_limit', $max_filesize );
1765
+	return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1766 1766
 }
1767 1767
 
1768 1768
 /**
@@ -1775,8 +1775,8 @@  discard block
 block discarded – undo
1775 1775
  * @return bool If dummy folder exists returns true, else false.
1776 1776
  */
1777 1777
 function geodir_dummy_folder_exists() {
1778
-	$path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1779
-	if ( ! is_dir( $path ) ) {
1778
+	$path = geodir_plugin_path().'/geodirectory-admin/dummy/';
1779
+	if (!is_dir($path)) {
1780 1780
 		return false;
1781 1781
 	} else {
1782 1782
 		return true;
@@ -1795,17 +1795,17 @@  discard block
 block discarded – undo
1795 1795
  *
1796 1796
  * @return object Author info.
1797 1797
  */
1798
-function geodir_get_author_info( $aid ) {
1798
+function geodir_get_author_info($aid) {
1799 1799
 	global $wpdb;
1800 1800
 	/*$infosql = "select * from $wpdb->users where ID=$aid";*/
1801
-	$infosql = $wpdb->prepare( "select * from $wpdb->users where ID=%d", array( $aid ) );
1802
-	$info    = $wpdb->get_results( $infosql );
1803
-	if ( $info ) {
1801
+	$infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1802
+	$info    = $wpdb->get_results($infosql);
1803
+	if ($info) {
1804 1804
 		return $info[0];
1805 1805
 	}
1806 1806
 }
1807 1807
 
1808
-if ( ! function_exists( 'adminEmail' ) ) {
1808
+if (!function_exists('adminEmail')) {
1809 1809
 	/**
1810 1810
 	 * Send emails to client on post submission, renew etc.
1811 1811
 	 *
@@ -1818,67 +1818,67 @@  discard block
 block discarded – undo
1818 1818
 	 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1819 1819
 	 * @param string $custom_1     Custom data to be sent.
1820 1820
 	 */
1821
-	function adminEmail( $page_id, $user_id, $message_type, $custom_1 = '' ) {
1821
+	function adminEmail($page_id, $user_id, $message_type, $custom_1 = '') {
1822 1822
 		global $wpdb;
1823
-		if ( $message_type == 'expiration' ) {
1824
-			$subject        = stripslashes( __( get_option( 'renew_email_subject' ), 'geodirectory' ) );
1825
-			$client_message = stripslashes( __( get_option( 'renew_email_content' ), 'geodirectory' ) );
1826
-		} elseif ( $message_type == 'post_submited' ) {
1827
-			$subject        = __( get_option( 'post_submited_success_email_subject_admin' ), 'geodirectory' );
1828
-			$client_message = __( get_option( 'post_submited_success_email_content_admin' ), 'geodirectory' );
1829
-		} elseif ( $message_type == 'renew' ) {
1830
-			$subject        = __( get_option( 'post_renew_success_email_subject_admin' ), 'geodirectory' );
1831
-			$client_message = __( get_option( 'post_renew_success_email_content_admin' ), 'geodirectory' );
1832
-		} elseif ( $message_type == 'upgrade' ) {
1833
-			$subject        = __( get_option( 'post_upgrade_success_email_subject_admin' ), 'geodirectory' );
1834
-			$client_message = __( get_option( 'post_upgrade_success_email_content_admin' ), 'geodirectory' );
1835
-		} elseif ( $message_type == 'claim_approved' ) {
1836
-			$subject        = __( get_option( 'claim_approved_email_subject' ), 'geodirectory' );
1837
-			$client_message = __( get_option( 'claim_approved_email_content' ), 'geodirectory' );
1838
-		} elseif ( $message_type == 'claim_rejected' ) {
1839
-			$subject        = __( get_option( 'claim_rejected_email_subject' ), 'geodirectory' );
1840
-			$client_message = __( get_option( 'claim_rejected_email_content' ), 'geodirectory' );
1841
-		} elseif ( $message_type == 'claim_requested' ) {
1842
-			$subject        = __( get_option( 'claim_email_subject_admin' ), 'geodirectory' );
1843
-			$client_message = __( get_option( 'claim_email_content_admin' ), 'geodirectory' );
1844
-		} elseif ( $message_type == 'auto_claim' ) {
1845
-			$subject        = __( get_option( 'auto_claim_email_subject' ), 'geodirectory' );
1846
-			$client_message = __( get_option( 'auto_claim_email_content' ), 'geodirectory' );
1847
-		} elseif ( $message_type == 'payment_success' ) {
1848
-			$subject        = __( get_option( 'post_payment_success_admin_email_subject' ), 'geodirectory' );
1849
-			$client_message = __( get_option( 'post_payment_success_admin_email_content' ), 'geodirectory' );
1850
-		} elseif ( $message_type == 'payment_fail' ) {
1851
-			$subject        = __( get_option( 'post_payment_fail_admin_email_subject' ), 'geodirectory' );
1852
-			$client_message = __( get_option( 'post_payment_fail_admin_email_content' ), 'geodirectory' );
1823
+		if ($message_type == 'expiration') {
1824
+			$subject        = stripslashes(__(get_option('renew_email_subject'), 'geodirectory'));
1825
+			$client_message = stripslashes(__(get_option('renew_email_content'), 'geodirectory'));
1826
+		} elseif ($message_type == 'post_submited') {
1827
+			$subject        = __(get_option('post_submited_success_email_subject_admin'), 'geodirectory');
1828
+			$client_message = __(get_option('post_submited_success_email_content_admin'), 'geodirectory');
1829
+		} elseif ($message_type == 'renew') {
1830
+			$subject        = __(get_option('post_renew_success_email_subject_admin'), 'geodirectory');
1831
+			$client_message = __(get_option('post_renew_success_email_content_admin'), 'geodirectory');
1832
+		} elseif ($message_type == 'upgrade') {
1833
+			$subject        = __(get_option('post_upgrade_success_email_subject_admin'), 'geodirectory');
1834
+			$client_message = __(get_option('post_upgrade_success_email_content_admin'), 'geodirectory');
1835
+		} elseif ($message_type == 'claim_approved') {
1836
+			$subject        = __(get_option('claim_approved_email_subject'), 'geodirectory');
1837
+			$client_message = __(get_option('claim_approved_email_content'), 'geodirectory');
1838
+		} elseif ($message_type == 'claim_rejected') {
1839
+			$subject        = __(get_option('claim_rejected_email_subject'), 'geodirectory');
1840
+			$client_message = __(get_option('claim_rejected_email_content'), 'geodirectory');
1841
+		} elseif ($message_type == 'claim_requested') {
1842
+			$subject        = __(get_option('claim_email_subject_admin'), 'geodirectory');
1843
+			$client_message = __(get_option('claim_email_content_admin'), 'geodirectory');
1844
+		} elseif ($message_type == 'auto_claim') {
1845
+			$subject        = __(get_option('auto_claim_email_subject'), 'geodirectory');
1846
+			$client_message = __(get_option('auto_claim_email_content'), 'geodirectory');
1847
+		} elseif ($message_type == 'payment_success') {
1848
+			$subject        = __(get_option('post_payment_success_admin_email_subject'), 'geodirectory');
1849
+			$client_message = __(get_option('post_payment_success_admin_email_content'), 'geodirectory');
1850
+		} elseif ($message_type == 'payment_fail') {
1851
+			$subject        = __(get_option('post_payment_fail_admin_email_subject'), 'geodirectory');
1852
+			$client_message = __(get_option('post_payment_fail_admin_email_content'), 'geodirectory');
1853 1853
 		}
1854 1854
 		$transaction_details = $custom_1;
1855
-		$fromEmail           = get_option( 'site_email' );
1855
+		$fromEmail           = get_option('site_email');
1856 1856
 		$fromEmailName       = get_site_emailName();
1857 1857
 //$alivedays = get_post_meta($page_id,'alive_days',true);
1858
-		$pkg_limit            = get_property_price_info_listing( $page_id );
1858
+		$pkg_limit            = get_property_price_info_listing($page_id);
1859 1859
 		$alivedays            = $pkg_limit['days'];
1860
-		$productlink          = get_permalink( $page_id );
1861
-		$post_info            = get_post( $page_id );
1862
-		$post_date            = date( 'dS F,Y', strtotime( $post_info->post_date ) );
1863
-		$listingLink          = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1860
+		$productlink          = get_permalink($page_id);
1861
+		$post_info            = get_post($page_id);
1862
+		$post_date            = date('dS F,Y', strtotime($post_info->post_date));
1863
+		$listingLink          = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
1864 1864
 		$loginurl             = geodir_login_url();
1865
-		$loginurl_link        = '<a href="' . $loginurl . '">login</a>';
1865
+		$loginurl_link        = '<a href="'.$loginurl.'">login</a>';
1866 1866
 		$siteurl              = home_url();
1867
-		$siteurl_link         = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1868
-		$user_info            = get_userdata( $user_id );
1867
+		$siteurl_link         = '<a href="'.$siteurl.'">'.$fromEmailName.'</a>';
1868
+		$user_info            = get_userdata($user_id);
1869 1869
 		$user_email           = $user_info->user_email;
1870
-		$display_name         = geodir_get_client_name( $user_id );
1870
+		$display_name         = geodir_get_client_name($user_id);
1871 1871
 		$user_login           = $user_info->user_login;
1872
-		$number_of_grace_days = get_option( 'ptthemes_listing_preexpiry_notice_days' );
1873
-		if ( $number_of_grace_days == '' ) {
1872
+		$number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1873
+		if ($number_of_grace_days == '') {
1874 1874
 			$number_of_grace_days = 1;
1875 1875
 		}
1876
-		if ( $post_info->post_type == 'event' ) {
1876
+		if ($post_info->post_type == 'event') {
1877 1877
 			$post_type = 'event';
1878 1878
 		} else {
1879 1879
 			$post_type = 'listing';
1880 1880
 		}
1881
-		$renew_link     = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1881
+		$renew_link     = '<a href="'.$siteurl.'?ptype=post_'.$post_type.'&renew=1&pid='.$page_id.'">'.RENEW_LINK.'</a>';
1882 1882
 		$search_array   = array(
1883 1883
 			'[#client_name#]',
1884 1884
 			'[#listing_link#]',
@@ -1894,7 +1894,7 @@  discard block
 block discarded – undo
1894 1894
 			'[#site_name#]',
1895 1895
 			'[#transaction_details#]'
1896 1896
 		);
1897
-		$replace_array  = array(
1897
+		$replace_array = array(
1898 1898
 			$display_name,
1899 1899
 			$listingLink,
1900 1900
 			$post_date,
@@ -1909,13 +1909,13 @@  discard block
 block discarded – undo
1909 1909
 			$fromEmailName,
1910 1910
 			$transaction_details
1911 1911
 		);
1912
-		$client_message = str_replace( $search_array, $replace_array, $client_message );
1913
-		$subject        = str_replace( $search_array, $replace_array, $subject );
1912
+		$client_message = str_replace($search_array, $replace_array, $client_message);
1913
+		$subject        = str_replace($search_array, $replace_array, $subject);
1914 1914
 		
1915 1915
 		
1916
-		$headers  = array();
1916
+		$headers = array();
1917 1917
 		$headers[] = 'Content-type: text/html; charset=UTF-8';
1918
-		$headers[] = 'From: ' . $fromEmailName . ' <' . $fromEmail . '>';
1918
+		$headers[] = 'From: '.$fromEmailName.' <'.$fromEmail.'>';
1919 1919
 
1920 1920
 		$to      = $fromEmail;
1921 1921
 		$message = $client_message;
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
 		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1934 1934
 		 * @param string $custom_1     Custom data to be sent.
1935 1935
 		 */
1936
-		$to = apply_filters( 'geodir_adminEmail_to', $to, $page_id, $user_id, $message_type, $custom_1 );
1936
+		$to = apply_filters('geodir_adminEmail_to', $to, $page_id, $user_id, $message_type, $custom_1);
1937 1937
 		/**
1938 1938
 		 * Filter the admin email subject.
1939 1939
 		 *
@@ -1946,7 +1946,7 @@  discard block
 block discarded – undo
1946 1946
 		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1947 1947
 		 * @param string $custom_1     Custom data to be sent.
1948 1948
 		 */
1949
-		$subject = apply_filters( 'geodir_adminEmail_subject', $subject, $page_id, $user_id, $message_type, $custom_1 );
1949
+		$subject = apply_filters('geodir_adminEmail_subject', $subject, $page_id, $user_id, $message_type, $custom_1);
1950 1950
 		/**
1951 1951
 		 * Filter the admin email message.
1952 1952
 		 *
@@ -1959,7 +1959,7 @@  discard block
 block discarded – undo
1959 1959
 		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1960 1960
 		 * @param string $custom_1     Custom data to be sent.
1961 1961
 		 */
1962
-		$message = apply_filters( 'geodir_adminEmail_message', $message, $page_id, $user_id, $message_type, $custom_1 );
1962
+		$message = apply_filters('geodir_adminEmail_message', $message, $page_id, $user_id, $message_type, $custom_1);
1963 1963
 		/**
1964 1964
 		 * Filter the admin email headers.
1965 1965
 		 *
@@ -1972,22 +1972,22 @@  discard block
 block discarded – undo
1972 1972
 		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1973 1973
 		 * @param string $custom_1     Custom data to be sent.
1974 1974
 		 */
1975
-		$headers = apply_filters( 'geodir_adminEmail_headers', $headers, $page_id, $user_id, $message_type, $custom_1 );
1975
+		$headers = apply_filters('geodir_adminEmail_headers', $headers, $page_id, $user_id, $message_type, $custom_1);
1976 1976
 
1977 1977
 
1978
-		$sent = wp_mail( $to, $subject, $message, $headers );
1979
-		if ( ! $sent ) {
1980
-			if ( is_array( $to ) ) {
1981
-				$to = implode( ',', $to );
1978
+		$sent = wp_mail($to, $subject, $message, $headers);
1979
+		if (!$sent) {
1980
+			if (is_array($to)) {
1981
+				$to = implode(',', $to);
1982 1982
 			}
1983 1983
 			$log_message = sprintf(
1984
-				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1984
+				__("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1985 1985
 				$message_type,
1986
-				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1986
+				date_i18n('F j Y H:i:s', current_time('timestamp')),
1987 1987
 				$to,
1988 1988
 				$subject
1989 1989
 			);
1990
-			geodir_error_log( $log_message );
1990
+			geodir_error_log($log_message);
1991 1991
 		}
1992 1992
 	}
1993 1993
 }
@@ -2007,12 +2007,12 @@  discard block
 block discarded – undo
2007 2007
  *
2008 2008
  * @return array Category IDs.
2009 2009
  */
2010
-function gd_lang_object_ids( $ids_array, $type ) {
2011
-	if ( geodir_is_wpml() ) {
2010
+function gd_lang_object_ids($ids_array, $type) {
2011
+	if (geodir_is_wpml()) {
2012 2012
 		$res = array();
2013
-		foreach ( $ids_array as $id ) {
2014
-			$xlat = geodir_wpml_object_id( $id, $type, false );
2015
-			if ( ! is_null( $xlat ) ) {
2013
+		foreach ($ids_array as $id) {
2014
+			$xlat = geodir_wpml_object_id($id, $type, false);
2015
+			if (!is_null($xlat)) {
2016 2016
 				$res[] = $xlat;
2017 2017
 			}
2018 2018
 		}
@@ -2036,20 +2036,20 @@  discard block
 block discarded – undo
2036 2036
  *
2037 2037
  * @return array Modified Body CSS classes.
2038 2038
  */
2039
-function geodir_custom_posts_body_class( $classes ) {
2039
+function geodir_custom_posts_body_class($classes) {
2040 2040
 	global $wpdb, $wp;
2041
-	$post_types = geodir_get_posttypes( 'object' );
2042
-	if ( ! empty( $post_types ) && count( (array) $post_types ) > 1 ) {
2041
+	$post_types = geodir_get_posttypes('object');
2042
+	if (!empty($post_types) && count((array) $post_types) > 1) {
2043 2043
 		$classes[] = 'geodir_custom_posts';
2044 2044
 	}
2045 2045
 
2046 2046
 	// fix body class for signup page
2047
-	if ( geodir_is_page( 'login' ) ) {
2047
+	if (geodir_is_page('login')) {
2048 2048
 		$new_classes   = array();
2049 2049
 		$new_classes[] = 'signup page-geodir-signup';
2050
-		if ( ! empty( $classes ) ) {
2051
-			foreach ( $classes as $class ) {
2052
-				if ( $class && $class != 'home' && $class != 'blog' ) {
2050
+		if (!empty($classes)) {
2051
+			foreach ($classes as $class) {
2052
+				if ($class && $class != 'home' && $class != 'blog') {
2053 2053
 					$new_classes[] = $class;
2054 2054
 				}
2055 2055
 			}
@@ -2057,14 +2057,14 @@  discard block
 block discarded – undo
2057 2057
 		$classes = $new_classes;
2058 2058
 	}
2059 2059
 
2060
-	if ( geodir_is_geodir_page() ) {
2060
+	if (geodir_is_geodir_page()) {
2061 2061
 		$classes[] = 'geodir-page';
2062 2062
 	}
2063 2063
 
2064 2064
 	return $classes;
2065 2065
 }
2066 2066
 
2067
-add_filter( 'body_class', 'geodir_custom_posts_body_class' ); // let's add a class to the body so we can style the new addition to the search
2067
+add_filter('body_class', 'geodir_custom_posts_body_class'); // let's add a class to the body so we can style the new addition to the search
2068 2068
 
2069 2069
 
2070 2070
 /**
@@ -2080,7 +2080,7 @@  discard block
 block discarded – undo
2080 2080
 	 *
2081 2081
 	 * @since 1.0.0
2082 2082
 	 */
2083
-	return apply_filters( 'geodir_map_zoom_level', array(
2083
+	return apply_filters('geodir_map_zoom_level', array(
2084 2084
 		1,
2085 2085
 		2,
2086 2086
 		3,
@@ -2100,7 +2100,7 @@  discard block
 block discarded – undo
2100 2100
 		17,
2101 2101
 		18,
2102 2102
 		19
2103
-	) );
2103
+	));
2104 2104
 
2105 2105
 }
2106 2106
 
@@ -2113,12 +2113,12 @@  discard block
 block discarded – undo
2113 2113
  *
2114 2114
  * @param string $geodir_option_name Option key.
2115 2115
  */
2116
-function geodir_option_version_backup( $geodir_option_name ) {
2116
+function geodir_option_version_backup($geodir_option_name) {
2117 2117
 	$version_date  = time();
2118
-	$geodir_option = get_option( $geodir_option_name );
2118
+	$geodir_option = get_option($geodir_option_name);
2119 2119
 
2120
-	if ( ! empty( $geodir_option ) ) {
2121
-		add_option( $geodir_option_name . '_' . $version_date, $geodir_option );
2120
+	if (!empty($geodir_option)) {
2121
+		add_option($geodir_option_name.'_'.$version_date, $geodir_option);
2122 2122
 	}
2123 2123
 }
2124 2124
 
@@ -2132,10 +2132,10 @@  discard block
 block discarded – undo
2132 2132
  *
2133 2133
  * @return int Page ID.
2134 2134
  */
2135
-function get_page_id_geodir_add_listing_page( $page_id ) {
2136
-	if ( geodir_wpml_multilingual_status() ) {
2135
+function get_page_id_geodir_add_listing_page($page_id) {
2136
+	if (geodir_wpml_multilingual_status()) {
2137 2137
 		$post_type = 'post_page';
2138
-		$page_id   = geodir_get_wpml_element_id( $page_id, $post_type );
2138
+		$page_id   = geodir_get_wpml_element_id($page_id, $post_type);
2139 2139
 	}
2140 2140
 
2141 2141
 	return $page_id;
@@ -2149,7 +2149,7 @@  discard block
 block discarded – undo
2149 2149
  * @return bool Returns true when sitepress multilingual CMS active. else returns false.
2150 2150
  */
2151 2151
 function geodir_wpml_multilingual_status() {
2152
-	if ( geodir_is_wpml() ) {
2152
+	if (geodir_is_wpml()) {
2153 2153
 		return true;
2154 2154
 	}
2155 2155
 
@@ -2167,19 +2167,19 @@  discard block
 block discarded – undo
2167 2167
  *
2168 2168
  * @return int Element ID when exists. Else the page id.
2169 2169
  */
2170
-function geodir_get_wpml_element_id( $page_id, $post_type ) {
2170
+function geodir_get_wpml_element_id($page_id, $post_type) {
2171 2171
 	global $sitepress;
2172
-	if ( geodir_wpml_multilingual_status() && ! empty( $sitepress ) && isset( $sitepress->queries ) ) {
2173
-		$trid = $sitepress->get_element_trid( $page_id, $post_type );
2172
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
2173
+		$trid = $sitepress->get_element_trid($page_id, $post_type);
2174 2174
 
2175
-		if ( $trid > 0 ) {
2176
-			$translations = $sitepress->get_element_translations( $trid, $post_type );
2175
+		if ($trid > 0) {
2176
+			$translations = $sitepress->get_element_translations($trid, $post_type);
2177 2177
 
2178 2178
 			$lang = $sitepress->get_current_language();
2179 2179
 			$lang = $lang ? $lang : $sitepress->get_default_language();
2180 2180
 
2181
-			if ( ! empty( $translations ) && ! empty( $lang ) && isset( $translations[ $lang ] ) && isset( $translations[ $lang ]->element_id ) && ! empty( $translations[ $lang ]->element_id ) ) {
2182
-				$page_id = $translations[ $lang ]->element_id;
2181
+			if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
2182
+				$page_id = $translations[$lang]->element_id;
2183 2183
 			}
2184 2184
 		}
2185 2185
 	}
@@ -2196,15 +2196,15 @@  discard block
 block discarded – undo
2196 2196
  */
2197 2197
 function geodir_wpml_check_element_id() {
2198 2198
 	global $sitepress;
2199
-	if ( geodir_wpml_multilingual_status() && ! empty( $sitepress ) && isset( $sitepress->queries ) ) {
2199
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
2200 2200
 		$el_type      = 'post_page';
2201
-		$el_id        = get_option( 'geodir_add_listing_page' );
2201
+		$el_id        = get_option('geodir_add_listing_page');
2202 2202
 		$default_lang = $sitepress->get_default_language();
2203
-		$el_details   = $sitepress->get_element_language_details( $el_id, $el_type );
2203
+		$el_details   = $sitepress->get_element_language_details($el_id, $el_type);
2204 2204
 
2205
-		if ( ! ( $el_id > 0 && $default_lang && ! empty( $el_details ) && isset( $el_details->language_code ) && $el_details->language_code == $default_lang ) ) {
2206
-			if ( ! $el_details->source_language_code ) {
2207
-				$sitepress->set_element_language_details( $el_id, $el_type, '', $default_lang );
2205
+		if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
2206
+			if (!$el_details->source_language_code) {
2207
+				$sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
2208 2208
 				$sitepress->icl_translations_cache->clear();
2209 2209
 			}
2210 2210
 		}
@@ -2224,44 +2224,44 @@  discard block
 block discarded – undo
2224 2224
  *
2225 2225
  * @return string Orderby SQL.
2226 2226
  */
2227
-function geodir_widget_listings_get_order( $query_args ) {
2227
+function geodir_widget_listings_get_order($query_args) {
2228 2228
 	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2229 2229
 
2230 2230
 	$query_args = $gd_query_args_widgets;
2231
-	if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
2232
-		return $wpdb->posts . ".post_date DESC, ";
2231
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2232
+		return $wpdb->posts.".post_date DESC, ";
2233 2233
 	}
2234 2234
 
2235
-	$post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type'];
2236
-	$table     = $plugin_prefix . $post_type . '_detail';
2235
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2236
+	$table     = $plugin_prefix.$post_type.'_detail';
2237 2237
 
2238
-	$sort_by = ! empty( $query_args['order_by'] ) ? $query_args['order_by'] : '';
2238
+	$sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
2239 2239
 
2240
-	switch ( $sort_by ) {
2240
+	switch ($sort_by) {
2241 2241
 		case 'latest':
2242 2242
 		case 'newest':
2243
-			$orderby = $wpdb->posts . ".post_date DESC, ";
2243
+			$orderby = $wpdb->posts.".post_date DESC, ";
2244 2244
 			break;
2245 2245
 		case 'featured':
2246
-			$orderby = $table . ".is_featured ASC, ". $wpdb->posts . ".post_date DESC, ";
2246
+			$orderby = $table.".is_featured ASC, ".$wpdb->posts.".post_date DESC, ";
2247 2247
 			break;
2248 2248
 		case 'az':
2249
-			$orderby = $wpdb->posts . ".post_title ASC, ";
2249
+			$orderby = $wpdb->posts.".post_title ASC, ";
2250 2250
 			break;
2251 2251
 		case 'high_review':
2252
-			$orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
2252
+			$orderby = $table.".rating_count DESC, ".$table.".overall_rating DESC, ";
2253 2253
 			break;
2254 2254
 		case 'high_rating':
2255
-			$orderby = "( " . $table . ".overall_rating  ) DESC, ";
2255
+			$orderby = "( ".$table.".overall_rating  ) DESC, ";
2256 2256
 			break;
2257 2257
 		case 'random':
2258 2258
 			$orderby = "RAND(), ";
2259 2259
 			break;
2260 2260
 		default:
2261
-			if ( $custom_orderby = geodir_prepare_custom_sorting( $sort_by, $table ) ) {
2262
-				$orderby = $custom_orderby . ", ";
2261
+			if ($custom_orderby = geodir_prepare_custom_sorting($sort_by, $table)) {
2262
+				$orderby = $custom_orderby.", ";
2263 2263
 			} else {
2264
-				$orderby = $wpdb->posts . ".post_title ASC, ";
2264
+				$orderby = $wpdb->posts.".post_title ASC, ";
2265 2265
 			}
2266 2266
 			break;
2267 2267
 	}
@@ -2286,16 +2286,16 @@  discard block
 block discarded – undo
2286 2286
  *
2287 2287
  * @return mixed Result object.
2288 2288
  */
2289
-function geodir_get_widget_listings( $query_args = array(), $count_only = false ) {
2289
+function geodir_get_widget_listings($query_args = array(), $count_only = false) {
2290 2290
 	global $wpdb, $plugin_prefix, $table_prefix;
2291 2291
 	$GLOBALS['gd_query_args_widgets'] = $query_args;
2292 2292
 	$gd_query_args_widgets            = $query_args;
2293 2293
 
2294
-	$post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type'];
2295
-	$table     = $plugin_prefix . $post_type . '_detail';
2296
-	$supports_wpml = geodir_wpml_is_post_type_translated( $post_type );
2294
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2295
+	$table     = $plugin_prefix.$post_type.'_detail';
2296
+	$supports_wpml = geodir_wpml_is_post_type_translated($post_type);
2297 2297
 
2298
-	$fields = $wpdb->posts . ".*, " . $table . ".*";
2298
+	$fields = $wpdb->posts.".*, ".$table.".*";
2299 2299
 	/**
2300 2300
 	 * Filter widget listing fields string part that is being used for query.
2301 2301
 	 *
@@ -2305,17 +2305,17 @@  discard block
 block discarded – undo
2305 2305
 	 * @param string $table     Table name.
2306 2306
 	 * @param string $post_type Post type.
2307 2307
 	 */
2308
-	$fields = apply_filters( 'geodir_filter_widget_listings_fields', $fields, $table, $post_type );
2308
+	$fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
2309 2309
 
2310
-	$join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
2310
+	$join = "INNER JOIN ".$table." ON (".$table.".post_id = ".$wpdb->posts.".ID)";
2311 2311
 
2312 2312
 	########### WPML ###########
2313 2313
 
2314
-	if ( $supports_wpml ) {
2314
+	if ($supports_wpml) {
2315 2315
 		global $sitepress;
2316 2316
 		$lang_code = ICL_LANGUAGE_CODE;
2317
-		if ( $lang_code ) {
2318
-			$join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
2317
+		if ($lang_code) {
2318
+			$join .= " JOIN ".$table_prefix."icl_translations icl_t ON icl_t.element_id = ".$table_prefix."posts.ID";
2319 2319
 		}
2320 2320
 	}
2321 2321
 
@@ -2329,15 +2329,15 @@  discard block
 block discarded – undo
2329 2329
 	 * @param string $join      Join clause string.
2330 2330
 	 * @param string $post_type Post type.
2331 2331
 	 */
2332
-	$join = apply_filters( 'geodir_filter_widget_listings_join', $join, $post_type );
2332
+	$join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
2333 2333
 
2334
-	$post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
2334
+	$post_status = is_super_admin() ? " OR ".$wpdb->posts.".post_status = 'private'" : '';
2335 2335
 
2336
-	$where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
2336
+	$where = " AND ( ".$wpdb->posts.".post_status = 'publish' ".$post_status." ) AND ".$wpdb->posts.".post_type = '".$post_type."'";
2337 2337
 
2338 2338
 	########### WPML ###########
2339
-	if ( $supports_wpml ) {
2340
-		if ( $lang_code ) {
2339
+	if ($supports_wpml) {
2340
+		if ($lang_code) {
2341 2341
 			$where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
2342 2342
 		}
2343 2343
 	}
@@ -2350,8 +2350,8 @@  discard block
 block discarded – undo
2350 2350
 	 * @param string $where     Where clause string.
2351 2351
 	 * @param string $post_type Post type.
2352 2352
 	 */
2353
-	$where = apply_filters( 'geodir_filter_widget_listings_where', $where, $post_type );
2354
-	$where = $where != '' ? " WHERE 1=1 " . $where : '';
2353
+	$where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2354
+	$where = $where != '' ? " WHERE 1=1 ".$where : '';
2355 2355
 
2356 2356
 	$groupby = " GROUP BY $wpdb->posts.ID "; //@todo is this needed? faster without
2357 2357
 	/**
@@ -2362,15 +2362,15 @@  discard block
 block discarded – undo
2362 2362
 	 * @param string $groupby   Group by clause string.
2363 2363
 	 * @param string $post_type Post type.
2364 2364
 	 */
2365
-	$groupby = apply_filters( 'geodir_filter_widget_listings_groupby', $groupby, $post_type );
2365
+	$groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
2366 2366
 
2367
-	if ( $count_only ) {
2368
-		$sql  = "SELECT COUNT(DISTINCT " . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
2369
-			" . $join . "
2367
+	if ($count_only) {
2368
+		$sql  = "SELECT COUNT(DISTINCT ".$wpdb->posts.".ID) AS total FROM ".$wpdb->posts."
2369
+			" . $join."
2370 2370
 			" . $where;
2371
-		$rows = (int) $wpdb->get_var( $sql );
2371
+		$rows = (int) $wpdb->get_var($sql);
2372 2372
 	} else {
2373
-		$orderby = geodir_widget_listings_get_order( $query_args );
2373
+		$orderby = geodir_widget_listings_get_order($query_args);
2374 2374
 		/**
2375 2375
 		 * Filter widget listing orderby clause string part that is being used for query.
2376 2376
 		 *
@@ -2380,33 +2380,33 @@  discard block
 block discarded – undo
2380 2380
 		 * @param string $table     Table name.
2381 2381
 		 * @param string $post_type Post type.
2382 2382
 		 */
2383
-		$orderby = apply_filters( 'geodir_filter_widget_listings_orderby', $orderby, $table, $post_type );
2383
+		$orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2384 2384
 		
2385 2385
 		$second_orderby = array();
2386
-		if ( strpos( $orderby, strtolower( $table . ".is_featured" )  ) === false ) {
2387
-			$second_orderby[] = $table . ".is_featured ASC";
2386
+		if (strpos($orderby, strtolower($table.".is_featured")) === false) {
2387
+			$second_orderby[] = $table.".is_featured ASC";
2388 2388
 		}
2389 2389
 		
2390
-		if ( strpos( $orderby, strtolower( $wpdb->posts . ".post_date" )  ) === false ) {
2391
-			$second_orderby[] = $wpdb->posts . ".post_date DESC";
2390
+		if (strpos($orderby, strtolower($wpdb->posts.".post_date")) === false) {
2391
+			$second_orderby[] = $wpdb->posts.".post_date DESC";
2392 2392
 		}
2393 2393
 		
2394
-		if ( strpos( $orderby, strtolower( $wpdb->posts . ".post_title" )  ) === false ) {
2395
-			$second_orderby[] = $wpdb->posts . ".post_title ASC";
2394
+		if (strpos($orderby, strtolower($wpdb->posts.".post_title")) === false) {
2395
+			$second_orderby[] = $wpdb->posts.".post_title ASC";
2396 2396
 		}
2397 2397
 		
2398
-		if ( !empty( $second_orderby ) ) {
2399
-			$orderby .= implode( ', ', $second_orderby );
2398
+		if (!empty($second_orderby)) {
2399
+			$orderby .= implode(', ', $second_orderby);
2400 2400
 		}
2401 2401
 		
2402
-		if ( !empty( $orderby ) ) {
2403
-			$orderby = trim( $orderby );
2404
-			$orderby = rtrim( $orderby, "," );
2402
+		if (!empty($orderby)) {
2403
+			$orderby = trim($orderby);
2404
+			$orderby = rtrim($orderby, ",");
2405 2405
 		}
2406 2406
 		
2407
-		$orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2407
+		$orderby = $orderby != '' ? " ORDER BY ".$orderby : '';
2408 2408
 
2409
-		$limit = ! empty( $query_args['posts_per_page'] ) ? $query_args['posts_per_page'] : 5;
2409
+		$limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2410 2410
 		/**
2411 2411
 		 * Filter widget listing limit that is being used for query.
2412 2412
 		 *
@@ -2415,27 +2415,27 @@  discard block
 block discarded – undo
2415 2415
 		 * @param int $limit        Query results limit.
2416 2416
 		 * @param string $post_type Post type.
2417 2417
 		 */
2418
-		$limit = apply_filters( 'geodir_filter_widget_listings_limit', $limit, $post_type );
2418
+		$limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2419 2419
 
2420
-		$page = ! empty( $query_args['pageno'] ) ? absint( $query_args['pageno'] ) : 1;
2421
-		if ( ! $page ) {
2420
+		$page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2421
+		if (!$page) {
2422 2422
 			$page = 1;
2423 2423
 		}
2424 2424
 
2425
-		$limit = (int) $limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int) $limit ) . ", " . (int) $limit : "";
2425
+		$limit = (int) $limit > 0 ? " LIMIT ".absint(($page - 1) * (int) $limit).", ".(int) $limit : "";
2426 2426
 
2427 2427
 		//@todo removed SQL_CALC_FOUND_ROWS from below as don't think it is needed and query is faster without
2428
-		$sql  = "SELECT " . $fields . " FROM " . $wpdb->posts . "
2429
-			" . $join . "
2430
-			" . $where . "
2431
-			" . $groupby . "
2432
-			" . $orderby . "
2428
+		$sql = "SELECT ".$fields." FROM ".$wpdb->posts."
2429
+			" . $join."
2430
+			" . $where."
2431
+			" . $groupby."
2432
+			" . $orderby."
2433 2433
 			" . $limit;
2434
-		$rows = $wpdb->get_results( $sql );
2434
+		$rows = $wpdb->get_results($sql);
2435 2435
 	}
2436 2436
 
2437
-	unset( $GLOBALS['gd_query_args_widgets'] );
2438
-	unset( $gd_query_args_widgets );
2437
+	unset($GLOBALS['gd_query_args_widgets']);
2438
+	unset($gd_query_args_widgets);
2439 2439
 
2440 2440
 	return $rows;
2441 2441
 }
@@ -2452,11 +2452,11 @@  discard block
 block discarded – undo
2452 2452
  *
2453 2453
  * @return string Modified fields SQL.
2454 2454
  */
2455
-function geodir_function_widget_listings_fields( $fields ) {
2455
+function geodir_function_widget_listings_fields($fields) {
2456 2456
 	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2457 2457
 
2458 2458
 	$query_args = $gd_query_args_widgets;
2459
-	if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
2459
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2460 2460
 		return $fields;
2461 2461
 	}
2462 2462
 
@@ -2475,24 +2475,24 @@  discard block
 block discarded – undo
2475 2475
  *
2476 2476
  * @return string Modified join clause SQL.
2477 2477
  */
2478
-function geodir_function_widget_listings_join( $join ) {
2478
+function geodir_function_widget_listings_join($join) {
2479 2479
 	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2480 2480
 
2481 2481
 	$query_args = $gd_query_args_widgets;
2482
-	if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
2482
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2483 2483
 		return $join;
2484 2484
 	}
2485 2485
 
2486
-	$post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type'];
2487
-	$table     = $plugin_prefix . $post_type . '_detail';
2486
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2487
+	$table     = $plugin_prefix.$post_type.'_detail';
2488 2488
 
2489
-	if ( ! empty( $query_args['with_pics_only'] ) ) {
2490
-		$join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2489
+	if (!empty($query_args['with_pics_only'])) {
2490
+		$join .= " LEFT JOIN ".GEODIR_ATTACHMENT_TABLE." ON ( ".GEODIR_ATTACHMENT_TABLE.".post_id=".$table.".post_id AND ".GEODIR_ATTACHMENT_TABLE.".mime_type LIKE '%image%' )";
2491 2491
 	}
2492 2492
 
2493
-	if ( ! empty( $query_args['tax_query'] ) ) {
2494
-		$tax_queries = get_tax_sql( $query_args['tax_query'], $wpdb->posts, 'ID' );
2495
-		if ( ! empty( $tax_queries['join'] ) && ! empty( $tax_queries['where'] ) ) {
2493
+	if (!empty($query_args['tax_query'])) {
2494
+		$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2495
+		if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2496 2496
 			$join .= $tax_queries['join'];
2497 2497
 		}
2498 2498
 	}
@@ -2513,60 +2513,60 @@  discard block
 block discarded – undo
2513 2513
  *
2514 2514
  * @return string Modified where clause SQL.
2515 2515
  */
2516
-function geodir_function_widget_listings_where( $where ) {
2516
+function geodir_function_widget_listings_where($where) {
2517 2517
 	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2518 2518
 
2519 2519
 	$query_args = $gd_query_args_widgets;
2520
-	if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
2520
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2521 2521
 		return $where;
2522 2522
 	}
2523
-	$post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type'];
2524
-	$table     = $plugin_prefix . $post_type . '_detail';
2523
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2524
+	$table     = $plugin_prefix.$post_type.'_detail';
2525 2525
 
2526
-	if ( ! empty( $query_args ) ) {
2527
-		if ( ! empty( $query_args['gd_location'] ) && function_exists( 'geodir_default_location_where' ) ) {
2528
-			$where = geodir_default_location_where( $where, $table );
2526
+	if (!empty($query_args)) {
2527
+		if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2528
+			$where = geodir_default_location_where($where, $table);
2529 2529
 		}
2530 2530
 
2531
-		if ( ! empty( $query_args['post_author'] ) ) {
2532
-			$where .= " AND " . $wpdb->posts . ".post_author = " . (int) $query_args['post_author'];
2531
+		if (!empty($query_args['post_author'])) {
2532
+			$where .= " AND ".$wpdb->posts.".post_author = ".(int) $query_args['post_author'];
2533 2533
 		}
2534 2534
 
2535
-		if ( ! empty( $query_args['show_featured_only'] ) ) {
2536
-			$where .= " AND " . $table . ".is_featured = '1'";
2535
+		if (!empty($query_args['show_featured_only'])) {
2536
+			$where .= " AND ".$table.".is_featured = '1'";
2537 2537
 		}
2538 2538
 
2539
-		if ( ! empty( $query_args['show_special_only'] ) ) {
2540
-			$where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2539
+		if (!empty($query_args['show_special_only'])) {
2540
+			$where .= " AND ( ".$table.".geodir_special_offers != '' AND ".$table.".geodir_special_offers IS NOT NULL )";
2541 2541
 		}
2542 2542
 
2543
-		if ( ! empty( $query_args['with_pics_only'] ) ) {
2544
-			$where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2543
+		if (!empty($query_args['with_pics_only'])) {
2544
+			$where .= " AND ".GEODIR_ATTACHMENT_TABLE.".ID IS NOT NULL ";
2545 2545
 		}
2546 2546
 
2547
-		if ( ! empty( $query_args['featured_image_only'] ) ) {
2548
-			$where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2547
+		if (!empty($query_args['featured_image_only'])) {
2548
+			$where .= " AND ".$table.".featured_image IS NOT NULL AND ".$table.".featured_image!='' ";
2549 2549
 		}
2550 2550
 
2551
-		if ( ! empty( $query_args['with_videos_only'] ) ) {
2552
-			$where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2551
+		if (!empty($query_args['with_videos_only'])) {
2552
+			$where .= " AND ( ".$table.".geodir_video != '' AND ".$table.".geodir_video IS NOT NULL )";
2553 2553
 		}
2554 2554
         
2555
-		if ( ! empty( $query_args['show_favorites_only'] ) ) {
2555
+		if (!empty($query_args['show_favorites_only'])) {
2556 2556
 			$user_favorites = '-1';
2557 2557
 			
2558
-			if ( !empty( $query_args['favorites_by_user'] ) ) {
2559
-				$user_favorites = get_user_meta( (int)$query_args['favorites_by_user'], 'gd_user_favourite_post', true );
2558
+			if (!empty($query_args['favorites_by_user'])) {
2559
+				$user_favorites = get_user_meta((int) $query_args['favorites_by_user'], 'gd_user_favourite_post', true);
2560 2560
 				$user_favorites = !empty($user_favorites) && is_array($user_favorites) ? implode("','", $user_favorites) : '-1';
2561 2561
 			}
2562 2562
 			
2563
-			$where .= " AND `" . $wpdb->posts . "`.`ID` IN('" . $user_favorites . "')";
2563
+			$where .= " AND `".$wpdb->posts."`.`ID` IN('".$user_favorites."')";
2564 2564
 		}
2565 2565
 
2566
-		if ( ! empty( $query_args['tax_query'] ) ) {
2567
-			$tax_queries = get_tax_sql( $query_args['tax_query'], $wpdb->posts, 'ID' );
2566
+		if (!empty($query_args['tax_query'])) {
2567
+			$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2568 2568
 
2569
-			if ( ! empty( $tax_queries['join'] ) && ! empty( $tax_queries['where'] ) ) {
2569
+			if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2570 2570
 				$where .= $tax_queries['where'];
2571 2571
 			}
2572 2572
 		}
@@ -2587,11 +2587,11 @@  discard block
 block discarded – undo
2587 2587
  *
2588 2588
  * @return string Modified orderby clause SQL.
2589 2589
  */
2590
-function geodir_function_widget_listings_orderby( $orderby ) {
2590
+function geodir_function_widget_listings_orderby($orderby) {
2591 2591
 	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2592 2592
 
2593 2593
 	$query_args = $gd_query_args_widgets;
2594
-	if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
2594
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2595 2595
 		return $orderby;
2596 2596
 	}
2597 2597
 
@@ -2610,15 +2610,15 @@  discard block
 block discarded – undo
2610 2610
  *
2611 2611
  * @return int Query limit.
2612 2612
  */
2613
-function geodir_function_widget_listings_limit( $limit ) {
2613
+function geodir_function_widget_listings_limit($limit) {
2614 2614
 	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2615 2615
 
2616 2616
 	$query_args = $gd_query_args_widgets;
2617
-	if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
2617
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2618 2618
 		return $limit;
2619 2619
 	}
2620 2620
 
2621
-	if ( ! empty( $query_args ) && ! empty( $query_args['posts_per_page'] ) ) {
2621
+	if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2622 2622
 		$limit = (int) $query_args['posts_per_page'];
2623 2623
 	}
2624 2624
 
@@ -2636,12 +2636,12 @@  discard block
 block discarded – undo
2636 2636
  *
2637 2637
  * @return int Large size width.
2638 2638
  */
2639
-function geodir_media_image_large_width( $default = 800, $params = '' ) {
2640
-	$large_size_w = get_option( 'large_size_w' );
2639
+function geodir_media_image_large_width($default = 800, $params = '') {
2640
+	$large_size_w = get_option('large_size_w');
2641 2641
 	$large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2642
-	$large_size_w = absint( $large_size_w );
2642
+	$large_size_w = absint($large_size_w);
2643 2643
 
2644
-	if ( ! get_option( 'geodir_use_wp_media_large_size' ) ) {
2644
+	if (!get_option('geodir_use_wp_media_large_size')) {
2645 2645
 		$large_size_w = 800;
2646 2646
 	}
2647 2647
 
@@ -2654,7 +2654,7 @@  discard block
 block discarded – undo
2654 2654
 	 * @param int $default         Default width.
2655 2655
 	 * @param string|array $params Image parameters.
2656 2656
 	 */
2657
-	$large_size_w = apply_filters( 'geodir_filter_media_image_large_width', $large_size_w, $default, $params );
2657
+	$large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2658 2658
 
2659 2659
 	return $large_size_w;
2660 2660
 }
@@ -2670,12 +2670,12 @@  discard block
 block discarded – undo
2670 2670
  *
2671 2671
  * @return int Large size height.
2672 2672
  */
2673
-function geodir_media_image_large_height( $default = 800, $params = '' ) {
2674
-	$large_size_h = get_option( 'large_size_h' );
2673
+function geodir_media_image_large_height($default = 800, $params = '') {
2674
+	$large_size_h = get_option('large_size_h');
2675 2675
 	$large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2676
-	$large_size_h = absint( $large_size_h );
2676
+	$large_size_h = absint($large_size_h);
2677 2677
 
2678
-	if ( ! get_option( 'geodir_use_wp_media_large_size' ) ) {
2678
+	if (!get_option('geodir_use_wp_media_large_size')) {
2679 2679
 		$large_size_h = 800;
2680 2680
 	}
2681 2681
 
@@ -2688,7 +2688,7 @@  discard block
 block discarded – undo
2688 2688
 	 * @param int $default         Default height.
2689 2689
 	 * @param string|array $params Image parameters.
2690 2690
 	 */
2691
-	$large_size_h = apply_filters( 'geodir_filter_media_image_large_height', $large_size_h, $default, $params );
2691
+	$large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2692 2692
 
2693 2693
 	return $large_size_h;
2694 2694
 }
@@ -2705,8 +2705,8 @@  discard block
 block discarded – undo
2705 2705
  *
2706 2706
  * @return string Sanitized name.
2707 2707
  */
2708
-function geodir_sanitize_location_name( $type, $name, $translate = true ) {
2709
-	if ( $name == '' ) {
2708
+function geodir_sanitize_location_name($type, $name, $translate = true) {
2709
+	if ($name == '') {
2710 2710
 		return null;
2711 2711
 	}
2712 2712
 
@@ -2715,13 +2715,13 @@  discard block
 block discarded – undo
2715 2715
 	$type = $type == 'gd_city' ? 'city' : $type;
2716 2716
 
2717 2717
 	$return = $name;
2718
-	if ( function_exists( 'get_actual_location_name' ) ) {
2719
-		$return = get_actual_location_name( $type, $name, $translate );
2718
+	if (function_exists('get_actual_location_name')) {
2719
+		$return = get_actual_location_name($type, $name, $translate);
2720 2720
 	} else {
2721
-		$return = preg_replace( '/-(\d+)$/', '', $return );
2722
-		$return = preg_replace( '/[_-]/', ' ', $return );
2723
-		$return = geodir_ucwords( $return );
2724
-		$return = $translate ? __( $return, 'geodirectory' ) : $return;
2721
+		$return = preg_replace('/-(\d+)$/', '', $return);
2722
+		$return = preg_replace('/[_-]/', ' ', $return);
2723
+		$return = geodir_ucwords($return);
2724
+		$return = $translate ? __($return, 'geodirectory') : $return;
2725 2725
 	}
2726 2726
 
2727 2727
 	return $return;
@@ -2739,26 +2739,26 @@  discard block
 block discarded – undo
2739 2739
  *
2740 2740
  * @param int $number Comments number.
2741 2741
  */
2742
-function geodir_comments_number( $number ) {
2742
+function geodir_comments_number($number) {
2743 2743
 	global $post;
2744 2744
 	
2745
-	if ( !empty( $post->post_type ) && geodir_cpt_has_rating_disabled( $post->post_type ) ) {
2745
+	if (!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type)) {
2746 2746
 		$number = get_comments_number();
2747 2747
 		
2748
-		if ( $number > 1 ) {
2749
-			$output = str_replace( '%', number_format_i18n( $number ), __( '% Comments', 'geodirectory' ) );
2750
-		} elseif ( $number == 0 || $number == '' ) {
2751
-			$output = __( 'No Comments', 'geodirectory' );
2748
+		if ($number > 1) {
2749
+			$output = str_replace('%', number_format_i18n($number), __('% Comments', 'geodirectory'));
2750
+		} elseif ($number == 0 || $number == '') {
2751
+			$output = __('No Comments', 'geodirectory');
2752 2752
 		} else { // must be one
2753
-			$output = __( '1 Comment', 'geodirectory' );
2753
+			$output = __('1 Comment', 'geodirectory');
2754 2754
 		}
2755 2755
 	} else {    
2756
-		if ( $number > 1 ) {
2757
-			$output = str_replace( '%', number_format_i18n( $number ), __( '% Reviews', 'geodirectory' ) );
2758
-		} elseif ( $number == 0 || $number == '' ) {
2759
-			$output = __( 'No Reviews', 'geodirectory' );
2756
+		if ($number > 1) {
2757
+			$output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2758
+		} elseif ($number == 0 || $number == '') {
2759
+			$output = __('No Reviews', 'geodirectory');
2760 2760
 		} else { // must be one
2761
-			$output = __( '1 Review', 'geodirectory' );
2761
+			$output = __('1 Review', 'geodirectory');
2762 2762
 		}
2763 2763
 	}
2764 2764
 	
@@ -2775,18 +2775,18 @@  discard block
 block discarded – undo
2775 2775
  */
2776 2776
 function is_page_geodir_home() {
2777 2777
 	global $wpdb;
2778
-	$cur_url = str_replace( array( "https://", "http://", "www." ), array( '', '', '' ), geodir_curPageURL() );
2779
-	if ( function_exists( 'geodir_location_geo_home_link' ) ) {
2780
-		remove_filter( 'home_url', 'geodir_location_geo_home_link', 100000 );
2778
+	$cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2779
+	if (function_exists('geodir_location_geo_home_link')) {
2780
+		remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2781 2781
 	}
2782
-	$home_url = home_url( '', 'http' );
2783
-	if ( function_exists( 'geodir_location_geo_home_link' ) ) {
2784
-		add_filter( 'home_url', 'geodir_location_geo_home_link', 100000, 2 );
2782
+	$home_url = home_url('', 'http');
2783
+	if (function_exists('geodir_location_geo_home_link')) {
2784
+		add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2785 2785
 	}
2786
-	$home_url = str_replace( "www.", "", $home_url );
2787
-	if ( ( strpos( $home_url, $cur_url ) !== false || strpos( $home_url . '/', $cur_url ) !== false ) && ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) && get_option( 'page_on_front' ) == get_option( 'geodir_home_page' ) ) ) {
2786
+	$home_url = str_replace("www.", "", $home_url);
2787
+	if ((strpos($home_url, $cur_url) !== false || strpos($home_url.'/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front') == get_option('geodir_home_page'))) {
2788 2788
 		return true;
2789
-	} elseif ( get_query_var( 'page_id' ) == get_option( 'page_on_front' ) && 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) && get_option( 'page_on_front' ) == get_option( 'geodir_home_page' ) ) {
2789
+	} elseif (get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front') == get_option('geodir_home_page')) {
2790 2790
 		return true;
2791 2791
 	} else {
2792 2792
 		return false;
@@ -2806,18 +2806,18 @@  discard block
 block discarded – undo
2806 2806
  *
2807 2807
  * @return string The canonical URL.
2808 2808
  */
2809
-function geodir_wpseo_homepage_canonical( $url ) {
2809
+function geodir_wpseo_homepage_canonical($url) {
2810 2810
 	global $post;
2811 2811
 
2812
-	if ( is_page_geodir_home() ) {
2812
+	if (is_page_geodir_home()) {
2813 2813
 		return home_url();
2814 2814
 	}
2815 2815
 
2816 2816
 	return $url;
2817 2817
 }
2818 2818
 
2819
-add_filter( 'wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10 );
2820
-add_filter( 'aioseop_canonical_url', 'geodir_wpseo_homepage_canonical', 10 );
2819
+add_filter('wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10);
2820
+add_filter('aioseop_canonical_url', 'geodir_wpseo_homepage_canonical', 10);
2821 2821
 
2822 2822
 /**
2823 2823
  * Add extra fields to google maps script call.
@@ -2830,20 +2830,20 @@  discard block
 block discarded – undo
2830 2830
  *
2831 2831
  * @return string Modified extra string.
2832 2832
  */
2833
-function geodir_googlemap_script_extra_details_page( $extra ) {
2833
+function geodir_googlemap_script_extra_details_page($extra) {
2834 2834
 	global $post;
2835 2835
 	$add_google_places_api = false;
2836
-	if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'gd_add_listing' ) ) {
2836
+	if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2837 2837
 		$add_google_places_api = true;
2838 2838
 	}
2839
-	if ( ! str_replace( 'libraries=places', '', $extra ) && ( geodir_is_page( 'detail' ) || $add_google_places_api ) ) {
2839
+	if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2840 2840
 		$extra .= "&amp;libraries=places";
2841 2841
 	}
2842 2842
 
2843 2843
 	return $extra;
2844 2844
 }
2845 2845
 
2846
-add_filter( 'geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1 );
2846
+add_filter('geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1);
2847 2847
 
2848 2848
 
2849 2849
 /**
@@ -2862,120 +2862,120 @@  discard block
 block discarded – undo
2862 2862
  *                                          after_widget.
2863 2863
  * @param array|string $instance            The settings for the particular instance of the widget.
2864 2864
  */
2865
-function geodir_popular_post_category_output( $args = '', $instance = '' ) {
2865
+function geodir_popular_post_category_output($args = '', $instance = '') {
2866 2866
 	// prints the widget
2867 2867
 	global $wpdb, $plugin_prefix, $geodir_post_category_str;
2868
-	extract( $args, EXTR_SKIP );
2868
+	extract($args, EXTR_SKIP);
2869 2869
 
2870 2870
 	echo $before_widget;
2871 2871
 
2872 2872
 	/** This filter is documented in geodirectory_widgets.php */
2873
-	$title = empty( $instance['title'] ) ? __( 'Popular Categories', 'geodirectory' ) : apply_filters( 'widget_title', __( $instance['title'], 'geodirectory' ) );
2873
+	$title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2874 2874
 
2875 2875
 	$gd_post_type = geodir_get_current_posttype();
2876 2876
 
2877
-	$category_limit = isset( $instance['category_limit'] ) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15;
2877
+	$category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15;
2878 2878
 	if (!isset($category_restrict)) {
2879 2879
 		$category_restrict = false;
2880 2880
 	}
2881
-	if ( ! empty( $gd_post_type ) ) {
2881
+	if (!empty($gd_post_type)) {
2882 2882
 		$default_post_type = $gd_post_type;
2883
-	} elseif ( isset( $instance['default_post_type'] ) && gdsc_is_post_type_valid( $instance['default_post_type'] ) ) {
2883
+	} elseif (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type'])) {
2884 2884
 		$default_post_type = $instance['default_post_type'];
2885 2885
 	} else {
2886 2886
 		$all_gd_post_type  = geodir_get_posttypes();
2887
-		$default_post_type = ( isset( $all_gd_post_type[0] ) ) ? $all_gd_post_type[0] : '';
2887
+		$default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : '';
2888 2888
 	}
2889
-	$parent_only = !empty( $instance['parent_only'] ) ? true : false;
2889
+	$parent_only = !empty($instance['parent_only']) ? true : false;
2890 2890
 
2891 2891
 	$taxonomy = array();
2892
-	if ( ! empty( $gd_post_type ) ) {
2893
-		$taxonomy[] = $gd_post_type . "category";
2892
+	if (!empty($gd_post_type)) {
2893
+		$taxonomy[] = $gd_post_type."category";
2894 2894
 	} else {
2895
-		$taxonomy = geodir_get_taxonomies( $gd_post_type );
2895
+		$taxonomy = geodir_get_taxonomies($gd_post_type);
2896 2896
 	}
2897 2897
 
2898 2898
 	$taxonomy = apply_filters('geodir_pp_category_taxonomy', $taxonomy);
2899 2899
 
2900
-	$term_args = array( 'taxonomy' => $taxonomy );
2901
-	if ( $parent_only ) {
2900
+	$term_args = array('taxonomy' => $taxonomy);
2901
+	if ($parent_only) {
2902 2902
 		$term_args['parent'] = 0;
2903 2903
 	}
2904 2904
 
2905
-	$terms   = get_terms( $term_args );
2905
+	$terms   = get_terms($term_args);
2906 2906
 	$a_terms = array();
2907 2907
 	$b_terms = array();
2908 2908
 
2909
-	foreach ( $terms as $term ) {
2910
-		if ( $term->count > 0 ) {
2911
-			$a_terms[ $term->taxonomy ][] = $term;
2909
+	foreach ($terms as $term) {
2910
+		if ($term->count > 0) {
2911
+			$a_terms[$term->taxonomy][] = $term;
2912 2912
 		}
2913 2913
 	}
2914 2914
 
2915
-	if ( ! empty( $a_terms ) ) {
2915
+	if (!empty($a_terms)) {
2916 2916
 		// Sort CPT taxonomies in categories widget.
2917
-		if ( !empty( $taxonomy ) && is_array( $taxonomy ) && count( $taxonomy ) > 1 ) {
2917
+		if (!empty($taxonomy) && is_array($taxonomy) && count($taxonomy) > 1) {
2918 2918
 			$gd_post_types = geodir_get_posttypes();
2919 2919
 			$sort_taxonomies = array();
2920 2920
 			
2921
-			foreach ( $gd_post_types as $gd_post_type ) {
2922
-				$taxonomy_name = $gd_post_type . 'category';
2921
+			foreach ($gd_post_types as $gd_post_type) {
2922
+				$taxonomy_name = $gd_post_type.'category';
2923 2923
 				
2924
-				if ( !empty( $a_terms[$taxonomy_name] ) ) {
2924
+				if (!empty($a_terms[$taxonomy_name])) {
2925 2925
 					$sort_taxonomies[$taxonomy_name] = $a_terms[$taxonomy_name];
2926 2926
 				}
2927 2927
 			}
2928
-			$a_terms = !empty( $sort_taxonomies ) ? $sort_taxonomies : $a_terms;
2928
+			$a_terms = !empty($sort_taxonomies) ? $sort_taxonomies : $a_terms;
2929 2929
 		}
2930 2930
 
2931 2931
 		$sort_by = apply_filters('geodir_pp_category_sort', 'count');
2932
-		foreach ( $a_terms as $b_key => $b_val ) {
2933
-			$b_terms[ $b_key ] = geodir_sort_terms( $b_val, $sort_by );
2932
+		foreach ($a_terms as $b_key => $b_val) {
2933
+			$b_terms[$b_key] = geodir_sort_terms($b_val, $sort_by);
2934 2934
 		}
2935 2935
 
2936
-		$default_taxonomy = $default_post_type != '' && isset( $b_terms[ $default_post_type . 'category' ] ) ? $default_post_type . 'category' : '';
2936
+		$default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type.'category']) ? $default_post_type.'category' : '';
2937 2937
 
2938 2938
 		$tax_change_output = '';
2939
-		if ( count( $b_terms ) > 1 ) {
2940
-			$tax_change_output .= "<select data-limit='$category_limit' data-parent='" . (int)$parent_only . "' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2941
-			foreach ( $b_terms as $key => $val ) {
2942
-				$ptype    = get_post_type_object( str_replace( "category", "", $key ) );
2943
-				$cpt_name = __( $ptype->labels->singular_name, 'geodirectory' );
2944
-				$tax_change_output .= "<option value='$key' " . selected( $key, $default_taxonomy, false ) . ">" . sprintf( __( '%s Categories', 'geodirectory' ), $cpt_name ) . "</option>";
2939
+		if (count($b_terms) > 1) {
2940
+			$tax_change_output .= "<select data-limit='$category_limit' data-parent='".(int) $parent_only."' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2941
+			foreach ($b_terms as $key => $val) {
2942
+				$ptype    = get_post_type_object(str_replace("category", "", $key));
2943
+				$cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2944
+				$tax_change_output .= "<option value='$key' ".selected($key, $default_taxonomy, false).">".sprintf(__('%s Categories', 'geodirectory'), $cpt_name)."</option>";
2945 2945
 			}
2946 2946
 			$tax_change_output .= "</select>";
2947 2947
 		}
2948 2948
 
2949
-		if ( ! empty( $b_terms ) ) {
2950
-			$terms = $default_taxonomy != '' && isset( $b_terms[ $default_taxonomy ] ) ? $b_terms[ $default_taxonomy ] : reset( $b_terms );// get the first array
2951
-			global $cat_count;//make global so we can change via function
2949
+		if (!empty($b_terms)) {
2950
+			$terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms); // get the first array
2951
+			global $cat_count; //make global so we can change via function
2952 2952
 			$cat_count = 0;
2953 2953
 			?>
2954 2954
 			<div class="geodir-category-list-in clearfix">
2955 2955
 				<div class="geodir-cat-list clearfix">
2956 2956
 					<?php
2957
-					echo $before_title . __( $title ) . $after_title;
2957
+					echo $before_title.__($title).$after_title;
2958 2958
 
2959 2959
 					echo $tax_change_output;
2960 2960
 
2961 2961
 					echo '<ul class="geodir-popular-cat-list">';
2962 2962
 
2963
-					geodir_helper_cat_list_output( $terms, $category_limit, $category_restrict);
2963
+					geodir_helper_cat_list_output($terms, $category_limit, $category_restrict);
2964 2964
 
2965 2965
 					echo '</ul>';
2966 2966
 					?>
2967 2967
 				</div>
2968 2968
 				<?php
2969 2969
 				$hide = '';
2970
-				if ( $cat_count < $category_limit ) {
2970
+				if ($cat_count < $category_limit) {
2971 2971
 					$hide = 'style="display:none;"';
2972 2972
 				}
2973 2973
 				echo "<div class='geodir-cat-list-more' $hide >";
2974
-				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __( 'More Categories', 'geodirectory' ) . '</a>';
2975
-				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __( 'Less Categories', 'geodirectory' ) . '</a>';
2974
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">'.__('More Categories', 'geodirectory').'</a>';
2975
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">'.__('Less Categories', 'geodirectory').'</a>';
2976 2976
 				echo "</div>";
2977 2977
 				/* add scripts */
2978
-				add_action( 'wp_footer', 'geodir_popular_category_add_scripts', 100 );
2978
+				add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2979 2979
 				?>
2980 2980
 			</div>
2981 2981
 			<?php
@@ -2995,28 +2995,28 @@  discard block
 block discarded – undo
2995 2995
  * @param int $category_limit               Number of categories to display by default.
2996 2996
  * @param bool $category_restrict           If the cat limit should be hidden or not shown.
2997 2997
  */
2998
-function geodir_helper_cat_list_output( $terms, $category_limit , $category_restrict=false) {
2998
+function geodir_helper_cat_list_output($terms, $category_limit, $category_restrict = false) {
2999 2999
 	global $geodir_post_category_str, $cat_count;
3000 3000
 	$term_icons = geodir_get_term_icon();
3001 3001
 
3002 3002
 	$geodir_post_category_str = array();
3003 3003
 
3004 3004
 
3005
-	foreach ( $terms as $cat ) {
3006
-		$post_type     = str_replace( "category", "", $cat->taxonomy );
3007
-		$term_icon_url = ! empty( $term_icons ) && isset( $term_icons[ $cat->term_id ] ) ? $term_icons[ $cat->term_id ] : '';
3005
+	foreach ($terms as $cat) {
3006
+		$post_type     = str_replace("category", "", $cat->taxonomy);
3007
+		$term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
3008 3008
 
3009
-		$cat_count ++;
3009
+		$cat_count++;
3010 3010
 
3011
-		$geodir_post_category_str[] = array( 'posttype' => $post_type, 'termid' => $cat->term_id );
3011
+		$geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
3012 3012
 
3013
-		$class_row  = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
3014
-		if($category_restrict && $cat_count > $category_limit ){
3013
+		$class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
3014
+		if ($category_restrict && $cat_count > $category_limit) {
3015 3015
 			continue;
3016 3016
 		}
3017 3017
 		$total_post = $cat->count;
3018 3018
 
3019
-		$term_link = get_term_link( $cat, $cat->taxonomy );
3019
+		$term_link = get_term_link($cat, $cat->taxonomy);
3020 3020
 		/**
3021 3021
 		 * Filer the category term link.
3022 3022
 		 *
@@ -3026,11 +3026,11 @@  discard block
 block discarded – undo
3026 3026
 		 * @param int $cat          ->term_id The term id.
3027 3027
 		 * @param string $post_type Wordpress post type.
3028 3028
 		 */
3029
-		$term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
3029
+		$term_link = apply_filters('geodir_category_term_link', $term_link, $cat->term_id, $post_type);
3030 3030
 
3031
-		echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
3032
-		echo '<img alt="' . esc_attr( $cat->name ) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">';
3033
-		echo $cat->name . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
3031
+		echo '<li class="'.$class_row.'"><a href="'.$term_link.'">';
3032
+		echo '<img alt="'.esc_attr($cat->name).' icon" style="height:20px;vertical-align:middle;" src="'.$term_icon_url.'"/> <span class="cat-link">';
3033
+		echo $cat->name.'</span> <span class="geodir_term_class geodir_link_span geodir_category_class_'.$post_type.'_'.$cat->term_id.'">('.$total_post.')</span> ';
3034 3034
 		echo '</a></li>';
3035 3035
 	}
3036 3036
 }
@@ -3045,14 +3045,14 @@  discard block
 block discarded – undo
3045 3045
  * @param array|string $args     Display arguments including before_title, after_title, before_widget, and after_widget.
3046 3046
  * @param array|string $instance The settings for the particular instance of the widget.
3047 3047
  */
3048
-function geodir_listing_slider_widget_output( $args = '', $instance = '' ) {
3048
+function geodir_listing_slider_widget_output($args = '', $instance = '') {
3049 3049
 	// prints the widget
3050
-	extract( $args, EXTR_SKIP );
3050
+	extract($args, EXTR_SKIP);
3051 3051
 
3052 3052
 	echo $before_widget;
3053 3053
 
3054 3054
 	/** This filter is documented in geodirectory_widgets.php */
3055
-	$title = empty( $instance['title'] ) ? '' : apply_filters( 'widget_title', __( $instance['title'], 'geodirectory' ) );
3055
+	$title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
3056 3056
 	/**
3057 3057
 	 * Filter the widget post type.
3058 3058
 	 *
@@ -3060,7 +3060,7 @@  discard block
 block discarded – undo
3060 3060
 	 *
3061 3061
 	 * @param string $instance ['post_type'] Post type of listing.
3062 3062
 	 */
3063
-	$post_type = empty( $instance['post_type'] ) ? 'gd_place' : apply_filters( 'widget_post_type', $instance['post_type'] );
3063
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
3064 3064
 	/**
3065 3065
 	 * Filter the widget's term.
3066 3066
 	 *
@@ -3068,7 +3068,7 @@  discard block
 block discarded – undo
3068 3068
 	 *
3069 3069
 	 * @param string $instance ['category'] Filter by term. Can be any valid term.
3070 3070
 	 */
3071
-	$category = empty( $instance['category'] ) ? '0' : apply_filters( 'widget_category', $instance['category'] );
3071
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
3072 3072
 	/**
3073 3073
 	 * Filter widget's "add_location_filter" value.
3074 3074
 	 *
@@ -3076,7 +3076,7 @@  discard block
 block discarded – undo
3076 3076
 	 *
3077 3077
 	 * @param string|bool $instance ['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3078 3078
 	 */
3079
-	$add_location_filter = empty( $instance['add_location_filter'] ) ? '0' : apply_filters( 'widget_add_location_filter', $instance['add_location_filter'] );
3079
+	$add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3080 3080
 	/**
3081 3081
 	 * Filter the widget listings limit.
3082 3082
 	 *
@@ -3084,7 +3084,7 @@  discard block
 block discarded – undo
3084 3084
 	 *
3085 3085
 	 * @param string $instance ['post_number'] Number of listings to display.
3086 3086
 	 */
3087
-	$post_number = empty( $instance['post_number'] ) ? '5' : apply_filters( 'widget_post_number', $instance['post_number'] );
3087
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3088 3088
 	/**
3089 3089
 	 * Filter the widget listings limit shown at one time.
3090 3090
 	 *
@@ -3092,7 +3092,7 @@  discard block
 block discarded – undo
3092 3092
 	 *
3093 3093
 	 * @param string $instance ['max_show'] Number of listings to display on screen.
3094 3094
 	 */
3095
-	$max_show = empty( $instance['max_show'] ) ? '1' : apply_filters( 'widget_max_show', $instance['max_show'] );
3095
+	$max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
3096 3096
 	/**
3097 3097
 	 * Filter the widget slide width.
3098 3098
 	 *
@@ -3100,7 +3100,7 @@  discard block
 block discarded – undo
3100 3100
 	 *
3101 3101
 	 * @param string $instance ['slide_width'] Width of the slides shown.
3102 3102
 	 */
3103
-	$slide_width = empty( $instance['slide_width'] ) ? '' : apply_filters( 'widget_slide_width', $instance['slide_width'] );
3103
+	$slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
3104 3104
 	/**
3105 3105
 	 * Filter widget's "show title" value.
3106 3106
 	 *
@@ -3108,7 +3108,7 @@  discard block
 block discarded – undo
3108 3108
 	 *
3109 3109
 	 * @param string|bool $instance ['show_title'] Do you want to display title? Can be 1 or 0.
3110 3110
 	 */
3111
-	$show_title = empty( $instance['show_title'] ) ? '' : apply_filters( 'widget_show_title', $instance['show_title'] );
3111
+	$show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
3112 3112
 	/**
3113 3113
 	 * Filter widget's "slideshow" value.
3114 3114
 	 *
@@ -3116,7 +3116,7 @@  discard block
 block discarded – undo
3116 3116
 	 *
3117 3117
 	 * @param int $instance ['slideshow'] Setup a slideshow for the slider to animate automatically.
3118 3118
 	 */
3119
-	$slideshow = empty( $instance['slideshow'] ) ? 0 : apply_filters( 'widget_slideshow', $instance['slideshow'] );
3119
+	$slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
3120 3120
 	/**
3121 3121
 	 * Filter widget's "animationLoop" value.
3122 3122
 	 *
@@ -3124,7 +3124,7 @@  discard block
 block discarded – undo
3124 3124
 	 *
3125 3125
 	 * @param int $instance ['animationLoop'] Gives the slider a seamless infinite loop.
3126 3126
 	 */
3127
-	$animationLoop = empty( $instance['animationLoop'] ) ? 0 : apply_filters( 'widget_animationLoop', $instance['animationLoop'] );
3127
+	$animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
3128 3128
 	/**
3129 3129
 	 * Filter widget's "directionNav" value.
3130 3130
 	 *
@@ -3132,7 +3132,7 @@  discard block
 block discarded – undo
3132 3132
 	 *
3133 3133
 	 * @param int $instance ['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
3134 3134
 	 */
3135
-	$directionNav = empty( $instance['directionNav'] ) ? 0 : apply_filters( 'widget_directionNav', $instance['directionNav'] );
3135
+	$directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
3136 3136
 	/**
3137 3137
 	 * Filter widget's "slideshowSpeed" value.
3138 3138
 	 *
@@ -3140,7 +3140,7 @@  discard block
 block discarded – undo
3140 3140
 	 *
3141 3141
 	 * @param int $instance ['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
3142 3142
 	 */
3143
-	$slideshowSpeed = empty( $instance['slideshowSpeed'] ) ? 5000 : apply_filters( 'widget_slideshowSpeed', $instance['slideshowSpeed'] );
3143
+	$slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
3144 3144
 	/**
3145 3145
 	 * Filter widget's "animationSpeed" value.
3146 3146
 	 *
@@ -3148,7 +3148,7 @@  discard block
 block discarded – undo
3148 3148
 	 *
3149 3149
 	 * @param int $instance ['animationSpeed'] Set the speed of animations, in milliseconds.
3150 3150
 	 */
3151
-	$animationSpeed = empty( $instance['animationSpeed'] ) ? 600 : apply_filters( 'widget_animationSpeed', $instance['animationSpeed'] );
3151
+	$animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
3152 3152
 	/**
3153 3153
 	 * Filter widget's "animation" value.
3154 3154
 	 *
@@ -3156,7 +3156,7 @@  discard block
 block discarded – undo
3156 3156
 	 *
3157 3157
 	 * @param string $instance ['animation'] Controls the animation type, "fade" or "slide".
3158 3158
 	 */
3159
-	$animation = empty( $instance['animation'] ) ? 'slide' : apply_filters( 'widget_animation', $instance['animation'] );
3159
+	$animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
3160 3160
 	/**
3161 3161
 	 * Filter widget's "list_sort" type.
3162 3162
 	 *
@@ -3164,10 +3164,10 @@  discard block
 block discarded – undo
3164 3164
 	 *
3165 3165
 	 * @param string $instance ['list_sort'] Listing sort by type.
3166 3166
 	 */
3167
-	$list_sort          = empty( $instance['list_sort'] ) ? 'latest' : apply_filters( 'widget_list_sort', $instance['list_sort'] );
3168
-	$show_featured_only = ! empty( $instance['show_featured_only'] ) ? 1 : null;
3167
+	$list_sort          = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3168
+	$show_featured_only = !empty($instance['show_featured_only']) ? 1 : null;
3169 3169
 
3170
-	wp_enqueue_script( 'geodirectory-jquery-flexslider-js' );
3170
+	wp_enqueue_script('geodirectory-jquery-flexslider-js');
3171 3171
 	?>
3172 3172
 		<script type="text/javascript">
3173 3173
 		jQuery(window).load(function () {
@@ -3186,7 +3186,7 @@  discard block
 block discarded – undo
3186 3186
 				itemWidth: 75,
3187 3187
 				itemMargin: 5,
3188 3188
 				asNavFor: '#geodir_widget_slider',
3189
-				rtl: <?php echo( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>,
3189
+				rtl: <?php echo(is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?>,
3190 3190
 				start: function (slider) {
3191 3191
 					// chrome 53 introduced a bug, so we need to repaint the slider when shown.
3192 3192
 					jQuery('.geodir-slides', jQuery(slider)).removeClass('flexslider-fix-rtl');
@@ -3194,19 +3194,19 @@  discard block
 block discarded – undo
3194 3194
 			});
3195 3195
 			
3196 3196
 			jQuery('#geodir_widget_slider').flexslider({
3197
-				animation: "<?php echo $animation;?>",
3197
+				animation: "<?php echo $animation; ?>",
3198 3198
 				selector: ".geodir-slides > li",
3199 3199
 				namespace: "geodir-",
3200 3200
 				controlNav: true,
3201
-				animationLoop: <?php echo $animationLoop;?>,
3202
-				slideshow: <?php echo $slideshow;?>,
3203
-				slideshowSpeed: <?php echo $slideshowSpeed;?>,
3204
-				animationSpeed: <?php echo $animationSpeed;?>,
3205
-				directionNav: <?php echo $directionNav;?>,
3206
-				maxItems: <?php echo $max_show;?>,
3201
+				animationLoop: <?php echo $animationLoop; ?>,
3202
+				slideshow: <?php echo $slideshow; ?>,
3203
+				slideshowSpeed: <?php echo $slideshowSpeed; ?>,
3204
+				animationSpeed: <?php echo $animationSpeed; ?>,
3205
+				directionNav: <?php echo $directionNav; ?>,
3206
+				maxItems: <?php echo $max_show; ?>,
3207 3207
 				move: 1,
3208
-				<?php if ( $slide_width ) {
3209
-				echo "itemWidth: " . $slide_width . ",";
3208
+				<?php if ($slide_width) {
3209
+				echo "itemWidth: ".$slide_width.",";
3210 3210
 			}?>
3211 3211
 				sync: "#geodir_widget_carousel",
3212 3212
 				start: function (slider) {
@@ -3217,7 +3217,7 @@  discard block
 block discarded – undo
3217 3217
 					jQuery('#geodir_widget_slider').css({'visibility': 'visible'});
3218 3218
 					jQuery('#geodir_widget_carousel').css({'visibility': 'visible'});
3219 3219
 				},
3220
-				rtl: <?php echo( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>
3220
+				rtl: <?php echo(is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?>
3221 3221
 			});
3222 3222
 		});
3223 3223
 	</script>
@@ -3230,62 +3230,62 @@  discard block
 block discarded – undo
3230 3230
 		'order_by'       => $list_sort
3231 3231
 	);
3232 3232
 
3233
-	if ( $show_featured_only ) {
3233
+	if ($show_featured_only) {
3234 3234
 		$query_args['show_featured_only'] = 1;
3235 3235
 	}
3236 3236
 
3237
-	if ( $category != 0 || $category != '' ) {
3238
-		$category_taxonomy = geodir_get_taxonomies( $post_type );
3237
+	if ($category != 0 || $category != '') {
3238
+		$category_taxonomy = geodir_get_taxonomies($post_type);
3239 3239
 		$tax_query         = array(
3240 3240
 			'taxonomy' => $category_taxonomy[0],
3241 3241
 			'field'    => 'id',
3242 3242
 			'terms'    => $category
3243 3243
 		);
3244 3244
 
3245
-		$query_args['tax_query'] = array( $tax_query );
3245
+		$query_args['tax_query'] = array($tax_query);
3246 3246
 	}
3247 3247
 
3248 3248
 	// we want listings with featured image only
3249 3249
 	$query_args['featured_image_only'] = 1;
3250 3250
 
3251
-	if ( $post_type == 'gd_event' ) {
3251
+	if ($post_type == 'gd_event') {
3252 3252
 		$query_args['gedir_event_listing_filter'] = 'upcoming';
3253 3253
 	}// show only upcoming events
3254 3254
 
3255
-	$widget_listings = geodir_get_widget_listings( $query_args );
3256
-	if ( ! empty( $widget_listings ) || ( isset( $with_no_results ) && $with_no_results ) ) {
3257
-		if ( $title ) {
3258
-			echo $before_title . $title . $after_title;
3255
+	$widget_listings = geodir_get_widget_listings($query_args);
3256
+	if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
3257
+		if ($title) {
3258
+			echo $before_title.$title.$after_title;
3259 3259
 		}
3260 3260
 
3261 3261
 		global $post;
3262 3262
 
3263
-		$current_post = $post;// keep current post info
3263
+		$current_post = $post; // keep current post info
3264 3264
 
3265 3265
 		$widget_main_slides = '';
3266 3266
 		$nav_slides         = '';
3267 3267
 		$widget_slides      = 0;
3268 3268
 
3269
-		foreach ( $widget_listings as $widget_listing ) {
3269
+		foreach ($widget_listings as $widget_listing) {
3270 3270
 			global $gd_widget_listing_type;
3271 3271
 			$post         = $widget_listing;
3272
-			$widget_image = geodir_get_featured_image( $post->ID, 'thumbnail', get_option( 'geodir_listing_no_img' ) );
3272
+			$widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
3273 3273
 
3274
-			if ( ! empty( $widget_image ) ) {
3275
-				if ( $widget_image->height >= 200 ) {
3274
+			if (!empty($widget_image)) {
3275
+				if ($widget_image->height >= 200) {
3276 3276
 					$widget_spacer_height = 0;
3277 3277
 				} else {
3278
-					$widget_spacer_height = ( ( 200 - $widget_image->height ) / 2 );
3278
+					$widget_spacer_height = ((200 - $widget_image->height) / 2);
3279 3279
 				}
3280 3280
 
3281
-				$widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:' . $widget_spacer_height . 'px !important;margin:0 auto;" width="100" />';
3281
+				$widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="'.geodir_plugin_url()."/geodirectory-assets/images/spacer.gif".'" alt="'.$widget_image->title.'" title="'.$widget_image->title.'" style="max-height:'.$widget_spacer_height.'px !important;margin:0 auto;" width="100" />';
3282 3282
 
3283 3283
 				$title = '';
3284
-				if ( $show_title ) {
3285
-					$title_html     = '<div class="geodir-slider-title"><a href="' . get_permalink( $post->ID ) . '">' . get_the_title( $post->ID ) . '</a></div>';
3284
+				if ($show_title) {
3285
+					$title_html     = '<div class="geodir-slider-title"><a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a></div>';
3286 3286
 					$post_id        = $post->ID;
3287
-					$post_permalink = get_permalink( $post->ID );
3288
-					$post_title     = get_the_title( $post->ID );
3287
+					$post_permalink = get_permalink($post->ID);
3288
+					$post_title     = get_the_title($post->ID);
3289 3289
 					/**
3290 3290
 					 * Filter the listing slider widget title.
3291 3291
 					 *
@@ -3296,12 +3296,12 @@  discard block
 block discarded – undo
3296 3296
 					 * @param string $post_permalink The post permalink url.
3297 3297
 					 * @param string $post_title     The post title text.
3298 3298
 					 */
3299
-					$title = apply_filters( 'geodir_listing_slider_title', $title_html, $post_id, $post_permalink, $post_title );
3299
+					$title = apply_filters('geodir_listing_slider_title', $title_html, $post_id, $post_permalink, $post_title);
3300 3300
 				}
3301 3301
 
3302
-				$widget_main_slides .= $title . '<a href="' . get_permalink( $post->ID ) . '"><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:200px;margin:0 auto;" /></a></li>';
3303
-				$nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
3304
-				$widget_slides ++;
3302
+				$widget_main_slides .= $title.'<a href="'.get_permalink($post->ID).'"><img src="'.$widget_image->src.'" alt="'.$widget_image->title.'" title="'.$widget_image->title.'" style="max-height:200px;margin:0 auto;" /></a></li>';
3303
+				$nav_slides .= '<li><img src="'.$widget_image->src.'" alt="'.$widget_image->title.'" title="'.$widget_image->title.'" style="max-height:48px;margin:0 auto;" /></li>';
3304
+				$widget_slides++;
3305 3305
 			}
3306 3306
 		}
3307 3307
 		?>
@@ -3310,7 +3310,7 @@  discard block
 block discarded – undo
3310 3310
 			<div id="geodir_widget_slider" class="geodir_flexslider">
3311 3311
 				<ul class="geodir-slides clearfix"><?php echo $widget_main_slides; ?></ul>
3312 3312
 			</div>
3313
-			<?php if ( $widget_slides > 1 ) { ?>
3313
+			<?php if ($widget_slides > 1) { ?>
3314 3314
 				<div id="geodir_widget_carousel" class="geodir_flexslider">
3315 3315
 					<ul class="geodir-slides clearfix"><?php echo $nav_slides; ?></ul>
3316 3316
 				</div>
@@ -3318,7 +3318,7 @@  discard block
 block discarded – undo
3318 3318
 		</div>
3319 3319
 		<?php
3320 3320
 		$GLOBALS['post'] = $current_post;
3321
-		setup_postdata( $current_post );
3321
+		setup_postdata($current_post);
3322 3322
 	}
3323 3323
 	echo $after_widget;
3324 3324
 }
@@ -3334,50 +3334,50 @@  discard block
 block discarded – undo
3334 3334
  * @param array|string $args     Display arguments including before_title, after_title, before_widget, and after_widget.
3335 3335
  * @param array|string $instance The settings for the particular instance of the widget.
3336 3336
  */
3337
-function geodir_loginwidget_output( $args = '', $instance = '' ) {
3337
+function geodir_loginwidget_output($args = '', $instance = '') {
3338 3338
 	//print_r($args);
3339 3339
 	//print_r($instance);
3340 3340
 	// prints the widget
3341
-	extract( $args, EXTR_SKIP );
3341
+	extract($args, EXTR_SKIP);
3342 3342
 
3343 3343
 	/** This filter is documented in geodirectory_widgets.php */
3344
-	$title = empty( $instance['title'] ) ? __( 'My Dashboard', 'geodirectory' ) : apply_filters( 'my_dashboard_widget_title', __( $instance['title'], 'geodirectory' ) );
3344
+	$title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('my_dashboard_widget_title', __($instance['title'], 'geodirectory'));
3345 3345
 
3346 3346
 	echo $before_widget;
3347
-	echo $before_title . $title . $after_title;
3347
+	echo $before_title.$title.$after_title;
3348 3348
 
3349 3349
 //	global $gd_session;
3350 3350
 //	print_r($gd_session);
3351 3351
 //	print_r($_SESSION);
3352 3352
 
3353
-	if ( is_user_logged_in() ) {
3353
+	if (is_user_logged_in()) {
3354 3354
 		global $current_user;
3355 3355
 
3356
-		$author_link = get_author_posts_url( $current_user->data->ID );
3357
-		$author_link = geodir_getlink( $author_link, array( 'geodir_dashbord' => 'true' ), false );
3356
+		$author_link = get_author_posts_url($current_user->data->ID);
3357
+		$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
3358 3358
 
3359 3359
 		echo '<ul class="geodir-loginbox-list">';
3360 3360
 		ob_start();
3361 3361
 		?>
3362 3362
 		<li><a class="signin"
3363
-		       href="<?php echo wp_logout_url( home_url() ); ?>"><?php _e( 'Logout', 'geodirectory' ); ?></a></li>
3363
+		       href="<?php echo wp_logout_url(home_url()); ?>"><?php _e('Logout', 'geodirectory'); ?></a></li>
3364 3364
 		<?php
3365
-		$post_types                           = geodir_get_posttypes( 'object' );
3366
-		$show_add_listing_post_types_main_nav = get_option( 'geodir_add_listing_link_user_dashboard' );
3367
-		$geodir_allow_posttype_frontend       = get_option( 'geodir_allow_posttype_frontend' );
3365
+		$post_types                           = geodir_get_posttypes('object');
3366
+		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
3367
+		$geodir_allow_posttype_frontend       = get_option('geodir_allow_posttype_frontend');
3368 3368
 
3369
-		if ( ! empty( $show_add_listing_post_types_main_nav ) ) {
3369
+		if (!empty($show_add_listing_post_types_main_nav)) {
3370 3370
 			$addlisting_links = '';
3371
-			foreach ( $post_types as $key => $postobj ) {
3371
+			foreach ($post_types as $key => $postobj) {
3372 3372
 
3373
-				if ( in_array( $key, $show_add_listing_post_types_main_nav ) ) {
3373
+				if (in_array($key, $show_add_listing_post_types_main_nav)) {
3374 3374
 
3375
-					if ( $add_link = geodir_get_addlisting_link( $key ) ) {
3375
+					if ($add_link = geodir_get_addlisting_link($key)) {
3376 3376
 
3377 3377
 						$name = $postobj->labels->name;
3378 3378
 
3379 3379
 						$selected = '';
3380
-						if ( geodir_get_current_posttype() == $key && geodir_is_page( 'add-listing' ) ) {
3380
+						if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing')) {
3381 3381
 							$selected = 'selected="selected"';
3382 3382
 						}
3383 3383
 
@@ -3390,23 +3390,23 @@  discard block
 block discarded – undo
3390 3390
 						 * @param string $key       Add listing array key.
3391 3391
 						 * @param int $current_user ->ID Current user ID.
3392 3392
 						 */
3393
-						$add_link = apply_filters( 'geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID );
3394
-						$name = apply_filters( 'geodir_dashboard_label_add_listing', $name, $key, $current_user->ID );
3393
+						$add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
3394
+						$name = apply_filters('geodir_dashboard_label_add_listing', $name, $key, $current_user->ID);
3395 3395
 
3396
-						$addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __( geodir_utf8_ucfirst( $name ), 'geodirectory' ) . '</option>';
3396
+						$addlisting_links .= '<option '.$selected.' value="'.$add_link.'">'.__(geodir_utf8_ucfirst($name), 'geodirectory').'</option>';
3397 3397
 
3398 3398
 					}
3399 3399
 				}
3400 3400
 
3401 3401
 			}
3402 3402
 
3403
-			if ( $addlisting_links != '' ) { ?>
3403
+			if ($addlisting_links != '') { ?>
3404 3404
 
3405 3405
 				<li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value"
3406 3406
 				            option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false"
3407
-				            data-placeholder="<?php echo esc_attr( __( 'Add Listing', 'geodirectory' ) ); ?>">
3407
+				            data-placeholder="<?php echo esc_attr(__('Add Listing', 'geodirectory')); ?>">
3408 3408
 						<option value="" disabled="disabled" selected="selected"
3409
-						        style='display:none;'><?php echo esc_attr( __( 'Add Listing', 'geodirectory' ) ); ?></option>
3409
+						        style='display:none;'><?php echo esc_attr(__('Add Listing', 'geodirectory')); ?></option>
3410 3410
 						<?php echo $addlisting_links; ?>
3411 3411
 					</select></li> <?php
3412 3412
 
@@ -3414,24 +3414,24 @@  discard block
 block discarded – undo
3414 3414
 
3415 3415
 		}
3416 3416
 		// My Favourites in Dashboard
3417
-		$show_favorite_link_user_dashboard = get_option( 'geodir_favorite_link_user_dashboard' );
3417
+		$show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
3418 3418
 		$user_favourite                    = geodir_user_favourite_listing_count();
3419 3419
 
3420
-		if ( ! empty( $show_favorite_link_user_dashboard ) && ! empty( $user_favourite ) ) {
3420
+		if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
3421 3421
 			$favourite_links = '';
3422 3422
 
3423
-			foreach ( $post_types as $key => $postobj ) {
3424
-				if ( in_array( $key, $show_favorite_link_user_dashboard ) && array_key_exists( $key, $user_favourite ) ) {
3423
+			foreach ($post_types as $key => $postobj) {
3424
+				if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
3425 3425
 					$name           = $postobj->labels->name;
3426 3426
 					$fav_author_link = apply_filters('gd_dash_fav_author_link', $author_link, $current_user->data->ID);
3427
-					$post_type_link = geodir_getlink( $fav_author_link, array(
3427
+					$post_type_link = geodir_getlink($fav_author_link, array(
3428 3428
 						'stype' => $key,
3429 3429
 						'list'  => 'favourite'
3430
-					), false );
3430
+					), false);
3431 3431
 
3432 3432
 					$selected = '';
3433 3433
 
3434
-					if ( isset( $_REQUEST['list'] ) && $_REQUEST['list'] == 'favourite' && isset( $_REQUEST['stype'] ) && $_REQUEST['stype'] == $key && isset( $_REQUEST['geodir_dashbord'] ) ) {
3434
+					if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
3435 3435
 						$selected = 'selected="selected"';
3436 3436
 					}
3437 3437
 					/**
@@ -3443,20 +3443,20 @@  discard block
 block discarded – undo
3443 3443
 					 * @param string $key            Favorite listing array key.
3444 3444
 					 * @param int $current_user      ->ID Current user ID.
3445 3445
 					 */
3446
-					$post_type_link = apply_filters( 'geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID );
3446
+					$post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
3447 3447
 
3448
-					$favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __( geodir_utf8_ucfirst( $name ), 'geodirectory' ) . '</option>';
3448
+					$favourite_links .= '<option '.$selected.' value="'.$post_type_link.'">'.__(geodir_utf8_ucfirst($name), 'geodirectory').'</option>';
3449 3449
 				}
3450 3450
 			}
3451 3451
 
3452
-			if ( $favourite_links != '' ) {
3452
+			if ($favourite_links != '') {
3453 3453
 				?>
3454 3454
 				<li>
3455 3455
 					<select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value"
3456 3456
 					        option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false"
3457
-					        data-placeholder="<?php echo esc_attr( __( 'My Favorites', 'geodirectory' ) ); ?>">
3457
+					        data-placeholder="<?php echo esc_attr(__('My Favorites', 'geodirectory')); ?>">
3458 3458
 						<option value="" disabled="disabled" selected="selected"
3459
-						        style='display:none;'><?php echo esc_attr( __( 'My Favorites', 'geodirectory' ) ); ?></option>
3459
+						        style='display:none;'><?php echo esc_attr(__('My Favorites', 'geodirectory')); ?></option>
3460 3460
 						<?php echo $favourite_links; ?>
3461 3461
 					</select>
3462 3462
 				</li>
@@ -3465,20 +3465,20 @@  discard block
 block discarded – undo
3465 3465
 		}
3466 3466
 
3467 3467
 
3468
-		$show_listing_link_user_dashboard = get_option( 'geodir_listing_link_user_dashboard' );
3468
+		$show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
3469 3469
 		$user_listing                     = geodir_user_post_listing_count();
3470 3470
 
3471
-		if ( ! empty( $show_listing_link_user_dashboard ) && ! empty( $user_listing ) ) {
3471
+		if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
3472 3472
 			$listing_links = '';
3473 3473
 
3474
-			foreach ( $post_types as $key => $postobj ) {
3475
-				if ( in_array( $key, $show_listing_link_user_dashboard ) && array_key_exists( $key, $user_listing ) ) {
3474
+			foreach ($post_types as $key => $postobj) {
3475
+				if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
3476 3476
 					$name         = $postobj->labels->name;
3477 3477
 					$listing_author_link = apply_filters('gd_dash_listing_author_link', $author_link, $current_user->data->ID);
3478
-					$listing_link = geodir_getlink( $listing_author_link, array( 'stype' => $key ), false );
3478
+					$listing_link = geodir_getlink($listing_author_link, array('stype' => $key), false);
3479 3479
 
3480 3480
 					$selected = '';
3481
-					if ( ! isset( $_REQUEST['list'] ) && isset( $_REQUEST['geodir_dashbord'] ) && isset( $_REQUEST['stype'] ) && $_REQUEST['stype'] == $key ) {
3481
+					if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
3482 3482
 						$selected = 'selected="selected"';
3483 3483
 					}
3484 3484
 
@@ -3491,20 +3491,20 @@  discard block
 block discarded – undo
3491 3491
 					 * @param string $key          My listing array key.
3492 3492
 					 * @param int $current_user    ->ID Current user ID.
3493 3493
 					 */
3494
-					$listing_link = apply_filters( 'geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID );
3494
+					$listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
3495 3495
 
3496
-					$listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __( geodir_utf8_ucfirst( $name ), 'geodirectory' ) . '</option>';
3496
+					$listing_links .= '<option '.$selected.' value="'.$listing_link.'">'.__(geodir_utf8_ucfirst($name), 'geodirectory').'</option>';
3497 3497
 				}
3498 3498
 			}
3499 3499
 
3500
-			if ( $listing_links != '' ) {
3500
+			if ($listing_links != '') {
3501 3501
 				?>
3502 3502
 				<li>
3503 3503
 					<select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value"
3504 3504
 					        option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false"
3505
-					        data-placeholder="<?php echo esc_attr( __( 'My Listings', 'geodirectory' ) ); ?>">
3505
+					        data-placeholder="<?php echo esc_attr(__('My Listings', 'geodirectory')); ?>">
3506 3506
 						<option value="" disabled="disabled" selected="selected"
3507
-						        style='display:none;'><?php echo esc_attr( __( 'My Listings', 'geodirectory' ) ); ?></option>
3507
+						        style='display:none;'><?php echo esc_attr(__('My Listings', 'geodirectory')); ?></option>
3508 3508
 						<?php echo $listing_links; ?>
3509 3509
 					</select>
3510 3510
 				</li>
@@ -3520,7 +3520,7 @@  discard block
 block discarded – undo
3520 3520
 		 *
3521 3521
 		 * @param string $dashboard_link Dashboard links HTML.
3522 3522
 		 */
3523
-		echo apply_filters( 'geodir_dashboard_links', $dashboard_link );
3523
+		echo apply_filters('geodir_dashboard_links', $dashboard_link);
3524 3524
 		echo '</ul>';
3525 3525
 
3526 3526
 		/**
@@ -3528,7 +3528,7 @@  discard block
 block discarded – undo
3528 3528
 		 *
3529 3529
 		 * @since 1.6.6
3530 3530
 		 */
3531
-		do_action( 'geodir_after_loginwidget_form_logged_in' );
3531
+		do_action('geodir_after_loginwidget_form_logged_in');
3532 3532
 
3533 3533
 
3534 3534
 	} else {
@@ -3543,18 +3543,18 @@  discard block
 block discarded – undo
3543 3543
 		<form name="loginform" class="loginform1"
3544 3544
 		      action="<?php echo geodir_login_url(); ?>"
3545 3545
 		      method="post">
3546
-			<div class="geodir_form_row"><input placeholder="<?php echo apply_filters('gd_login_wid_login_placeholder', __( 'Email', 'geodirectory' )); ?>" name="<?php echo apply_filters('gd_login_wid_login_name', 'log'); ?>"
3546
+			<div class="geodir_form_row"><input placeholder="<?php echo apply_filters('gd_login_wid_login_placeholder', __('Email', 'geodirectory')); ?>" name="<?php echo apply_filters('gd_login_wid_login_name', 'log'); ?>"
3547 3547
 			                                    type="text" class="textfield user_login1"/> <span
3548 3548
 					class="user_loginInfo"></span></div>
3549
-			<div class="geodir_form_row"><input placeholder="<?php _e( 'Password', 'geodirectory' ); ?>"
3549
+			<div class="geodir_form_row"><input placeholder="<?php _e('Password', 'geodirectory'); ?>"
3550 3550
 			                                    name="<?php echo apply_filters('gd_login_wid_login_pwd', 'pwd'); ?>" type="password"
3551 3551
 			                                    class="textfield user_pass1 input-text"/><span
3552 3552
 					class="user_passInfo"></span></div>
3553 3553
 
3554
-			<input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars( geodir_curPageURL() ); ?>"/>
3554
+			<input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars(geodir_curPageURL()); ?>"/>
3555 3555
 			<input type="hidden" name="testcookie" value="1"/>
3556 3556
 
3557
-				<?php do_action( 'login_form' ); ?>
3557
+				<?php do_action('login_form'); ?>
3558 3558
 
3559 3559
 			<div class="geodir_form_row clearfix"><input type="submit" name="submit"
3560 3560
 			                                             value="<?php echo SIGN_IN_BUTTON; ?>" class="b_signin"/>
@@ -3566,11 +3566,11 @@  discard block
 block discarded – undo
3566 3566
 					 *
3567 3567
 					 * @since 1.0.0
3568 3568
 					 */
3569
-					$is_enable_signup = get_option( 'users_can_register' );
3569
+					$is_enable_signup = get_option('users_can_register');
3570 3570
 					
3571
-					if ( $is_enable_signup ) {
3571
+					if ($is_enable_signup) {
3572 3572
 					?>
3573
-						<a href="<?php echo geodir_login_url( array( 'signup' => true ) ); ?>"
3573
+						<a href="<?php echo geodir_login_url(array('signup' => true)); ?>"
3574 3574
 						   class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?></a>
3575 3575
 
3576 3576
 					<?php
@@ -3581,7 +3581,7 @@  discard block
 block discarded – undo
3581 3581
 					 * @since 1.0.0
3582 3582
 					 */
3583 3583
 					?>
3584
-					<a href="<?php echo geodir_login_url( array( 'forgot' => true ) ); ?>"
3584
+					<a href="<?php echo geodir_login_url(array('forgot' => true)); ?>"
3585 3585
 					   class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?></a></p></div>
3586 3586
 		</form>
3587 3587
 		<?php
@@ -3590,7 +3590,7 @@  discard block
 block discarded – undo
3590 3590
 		 *
3591 3591
 		 * @since 1.6.6
3592 3592
 		 */
3593
-		do_action( 'geodir_after_loginwidget_form_logged_out' );
3593
+		do_action('geodir_after_loginwidget_form_logged_out');
3594 3594
 	}
3595 3595
 
3596 3596
 	echo $after_widget;
@@ -3612,14 +3612,14 @@  discard block
 block discarded – undo
3612 3612
  *                                         after_widget.
3613 3613
  * @param array|string $instance           The settings for the particular instance of the widget.
3614 3614
  */
3615
-function geodir_popular_postview_output( $args = '', $instance = '' ) {
3615
+function geodir_popular_postview_output($args = '', $instance = '') {
3616 3616
 	global $gd_session;
3617 3617
 
3618 3618
 	// prints the widget
3619
-	extract( $args, EXTR_SKIP );
3619
+	extract($args, EXTR_SKIP);
3620 3620
 
3621 3621
 	/** This filter is documented in geodirectory_widgets.php */
3622
-	$title = empty( $instance['title'] ) ? geodir_ucwords( $instance['category_title'] ) : apply_filters( 'widget_title', __( $instance['title'], 'geodirectory' ) );
3622
+	$title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
3623 3623
 	/**
3624 3624
 	 * Filter the widget post type.
3625 3625
 	 *
@@ -3627,7 +3627,7 @@  discard block
 block discarded – undo
3627 3627
 	 *
3628 3628
 	 * @param string $instance ['post_type'] Post type of listing.
3629 3629
 	 */
3630
-	$post_type = empty( $instance['post_type'] ) ? 'gd_place' : apply_filters( 'widget_post_type', $instance['post_type'] );
3630
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
3631 3631
 	/**
3632 3632
 	 * Filter the widget's term.
3633 3633
 	 *
@@ -3635,7 +3635,7 @@  discard block
 block discarded – undo
3635 3635
 	 *
3636 3636
 	 * @param string $instance ['category'] Filter by term. Can be any valid term.
3637 3637
 	 */
3638
-	$category = empty( $instance['category'] ) ? '0' : apply_filters( 'widget_category', $instance['category'] );
3638
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
3639 3639
 	/**
3640 3640
 	 * Filter the widget listings limit.
3641 3641
 	 *
@@ -3643,7 +3643,7 @@  discard block
 block discarded – undo
3643 3643
 	 *
3644 3644
 	 * @param string $instance ['post_number'] Number of listings to display.
3645 3645
 	 */
3646
-	$post_number = empty( $instance['post_number'] ) ? '5' : apply_filters( 'widget_post_number', $instance['post_number'] );
3646
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3647 3647
 	/**
3648 3648
 	 * Filter widget's "layout" type.
3649 3649
 	 *
@@ -3651,7 +3651,7 @@  discard block
 block discarded – undo
3651 3651
 	 *
3652 3652
 	 * @param string $instance ['layout'] Widget layout type.
3653 3653
 	 */
3654
-	$layout = empty( $instance['layout'] ) ? 'gridview_onehalf' : apply_filters( 'widget_layout', $instance['layout'] );
3654
+	$layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
3655 3655
 	/**
3656 3656
 	 * Filter widget's "add_location_filter" value.
3657 3657
 	 *
@@ -3659,7 +3659,7 @@  discard block
 block discarded – undo
3659 3659
 	 *
3660 3660
 	 * @param string|bool $instance ['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3661 3661
 	 */
3662
-	$add_location_filter = empty( $instance['add_location_filter'] ) ? '0' : apply_filters( 'widget_add_location_filter', $instance['add_location_filter'] );
3662
+	$add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3663 3663
 	/**
3664 3664
 	 * Filter widget's listing width.
3665 3665
 	 *
@@ -3667,7 +3667,7 @@  discard block
 block discarded – undo
3667 3667
 	 *
3668 3668
 	 * @param string $instance ['listing_width'] Listing width.
3669 3669
 	 */
3670
-	$listing_width = empty( $instance['listing_width'] ) ? '' : apply_filters( 'widget_listing_width', $instance['listing_width'] );
3670
+	$listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
3671 3671
 	/**
3672 3672
 	 * Filter widget's "list_sort" type.
3673 3673
 	 *
@@ -3675,36 +3675,36 @@  discard block
 block discarded – undo
3675 3675
 	 *
3676 3676
 	 * @param string $instance ['list_sort'] Listing sort by type.
3677 3677
 	 */
3678
-	$list_sort             = empty( $instance['list_sort'] ) ? 'latest' : apply_filters( 'widget_list_sort', $instance['list_sort'] );
3679
-	$use_viewing_post_type = ! empty( $instance['use_viewing_post_type'] ) ? true : false;
3678
+	$list_sort             = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3679
+	$use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3680 3680
 
3681 3681
 	// set post type to current viewing post type
3682
-	if ( $use_viewing_post_type ) {
3682
+	if ($use_viewing_post_type) {
3683 3683
 		$current_post_type = geodir_get_current_posttype();
3684
-		if ( $current_post_type != '' && $current_post_type != $post_type ) {
3684
+		if ($current_post_type != '' && $current_post_type != $post_type) {
3685 3685
 			$post_type = $current_post_type;
3686 3686
 			$category  = array(); // old post type category will not work for current changed post type
3687 3687
 		}
3688 3688
 	}
3689 3689
 	// replace widget title dynamically
3690
-	$posttype_plural_label   = __( get_post_type_plural_label( $post_type ), 'geodirectory' );
3691
-	$posttype_singular_label = __( get_post_type_singular_label( $post_type ), 'geodirectory' );
3690
+	$posttype_plural_label   = __(get_post_type_plural_label($post_type), 'geodirectory');
3691
+	$posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3692 3692
 
3693
-	$title = str_replace( "%posttype_plural_label%", $posttype_plural_label, $title );
3694
-	$title = str_replace( "%posttype_singular_label%", $posttype_singular_label, $title );
3693
+	$title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3694
+	$title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3695 3695
     
3696 3696
 	$categories = $category;
3697
-	if ( ! empty( $category ) && $category[0] != '0' ) {
3698
-		$category_taxonomy = geodir_get_taxonomies( $post_type );
3697
+	if (!empty($category) && $category[0] != '0') {
3698
+		$category_taxonomy = geodir_get_taxonomies($post_type);
3699 3699
 		
3700 3700
 		######### WPML #########
3701
-		if ( geodir_wpml_is_taxonomy_translated( $category_taxonomy[0] ) ) {
3702
-			$category = gd_lang_object_ids( $category, $category_taxonomy[0] );
3701
+		if (geodir_wpml_is_taxonomy_translated($category_taxonomy[0])) {
3702
+			$category = gd_lang_object_ids($category, $category_taxonomy[0]);
3703 3703
 		}
3704 3704
 		######### WPML #########
3705 3705
 	}
3706 3706
 
3707
-	if ( isset( $instance['character_count'] ) ) {
3707
+	if (isset($instance['character_count'])) {
3708 3708
 		/**
3709 3709
 		 * Filter the widget's excerpt character count.
3710 3710
 		 *
@@ -3712,38 +3712,38 @@  discard block
 block discarded – undo
3712 3712
 		 *
3713 3713
 		 * @param int $instance ['character_count'] Excerpt character count.
3714 3714
 		 */
3715
-		$character_count = apply_filters( 'widget_list_character_count', $instance['character_count'] );
3715
+		$character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3716 3716
 	} else {
3717 3717
 		$character_count = '';
3718 3718
 	}
3719 3719
 
3720
-	if ( empty( $title ) || $title == 'All' ) {
3721
-		$post_type_name = __( get_post_type_plural_label( $post_type ), 'geodirectory' );
3722
-		$title = !empty( $title ) ? wp_sprintf( __( 'All %s', 'geodirectory' ), $post_type_name ) : $post_type_name;
3720
+	if (empty($title) || $title == 'All') {
3721
+		$post_type_name = __(get_post_type_plural_label($post_type), 'geodirectory');
3722
+		$title = !empty($title) ? wp_sprintf(__('All %s', 'geodirectory'), $post_type_name) : $post_type_name;
3723 3723
 	}
3724 3724
 
3725 3725
 	$location_url = array();
3726
-	$city         = get_query_var( 'gd_city' );
3727
-	if ( ! empty( $city ) ) {
3728
-		$country = get_query_var( 'gd_country' );
3729
-		$region  = get_query_var( 'gd_region' );
3726
+	$city         = get_query_var('gd_city');
3727
+	if (!empty($city)) {
3728
+		$country = get_query_var('gd_country');
3729
+		$region  = get_query_var('gd_region');
3730 3730
 
3731
-		$geodir_show_location_url = get_option( 'geodir_show_location_url' );
3731
+		$geodir_show_location_url = get_option('geodir_show_location_url');
3732 3732
 
3733
-		if ( $geodir_show_location_url == 'all' ) {
3734
-			if ( $country != '' ) {
3733
+		if ($geodir_show_location_url == 'all') {
3734
+			if ($country != '') {
3735 3735
 				$location_url[] = $country;
3736 3736
 			}
3737 3737
 
3738
-			if ( $region != '' ) {
3738
+			if ($region != '') {
3739 3739
 				$location_url[] = $region;
3740 3740
 			}
3741
-		} else if ( $geodir_show_location_url == 'country_city' ) {
3742
-			if ( $country != '' ) {
3741
+		} else if ($geodir_show_location_url == 'country_city') {
3742
+			if ($country != '') {
3743 3743
 				$location_url[] = $country;
3744 3744
 			}
3745
-		} else if ( $geodir_show_location_url == 'region_city' ) {
3746
-			if ( $region != '' ) {
3745
+		} else if ($geodir_show_location_url == 'region_city') {
3746
+			if ($region != '') {
3747 3747
 				$location_url[] = $region;
3748 3748
 			}
3749 3749
 		}
@@ -3751,37 +3751,37 @@  discard block
 block discarded – undo
3751 3751
 		$location_url[] = $city;
3752 3752
 	}
3753 3753
 
3754
-	$location_url  = implode( '/', $location_url );
3754
+	$location_url  = implode('/', $location_url);
3755 3755
 	$skip_location = false;
3756
-	if ( ! $add_location_filter && $gd_session->get( 'gd_multi_location' ) ) {
3756
+	if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3757 3757
 		$skip_location = true;
3758
-		$gd_session->un_set( 'gd_multi_location' );
3758
+		$gd_session->un_set('gd_multi_location');
3759 3759
 	}
3760 3760
 
3761
-	if ( get_option( 'permalink_structure' ) ) {
3762
-		$viewall_url = get_post_type_archive_link( $post_type );
3761
+	if (get_option('permalink_structure')) {
3762
+		$viewall_url = get_post_type_archive_link($post_type);
3763 3763
 	} else {
3764
-		$viewall_url = get_post_type_archive_link( $post_type );
3764
+		$viewall_url = get_post_type_archive_link($post_type);
3765 3765
 	}
3766 3766
 
3767
-	if ( ! empty( $category ) && $category[0] != '0' ) {
3767
+	if (!empty($category) && $category[0] != '0') {
3768 3768
 		global $geodir_add_location_url;
3769 3769
 
3770 3770
 		$geodir_add_location_url = '0';
3771 3771
 
3772
-		if ( $add_location_filter != '0' ) {
3772
+		if ($add_location_filter != '0') {
3773 3773
 			$geodir_add_location_url = '1';
3774 3774
 		}
3775 3775
 
3776
-		$viewall_url = get_term_link( (int) $category[0], $post_type . 'category' );
3776
+		$viewall_url = get_term_link((int) $category[0], $post_type.'category');
3777 3777
 
3778 3778
 		$geodir_add_location_url = null;
3779 3779
 	}
3780
-	if ( $skip_location ) {
3781
-		$gd_session->set( 'gd_multi_location', 1 );
3780
+	if ($skip_location) {
3781
+		$gd_session->set('gd_multi_location', 1);
3782 3782
 	}
3783 3783
 
3784
-	if ( is_wp_error( $viewall_url ) ) {
3784
+	if (is_wp_error($viewall_url)) {
3785 3785
 		$viewall_url = '';
3786 3786
 	}
3787 3787
 
@@ -3793,43 +3793,43 @@  discard block
 block discarded – undo
3793 3793
 		'order_by'       => $list_sort
3794 3794
 	);
3795 3795
 
3796
-	if ( $character_count ) {
3796
+	if ($character_count) {
3797 3797
 		$query_args['excerpt_length'] = $character_count;
3798 3798
 	}
3799 3799
 
3800
-	if ( ! empty( $instance['show_featured_only'] ) ) {
3800
+	if (!empty($instance['show_featured_only'])) {
3801 3801
 		$query_args['show_featured_only'] = 1;
3802 3802
 	}
3803 3803
 
3804
-	if ( ! empty( $instance['show_special_only'] ) ) {
3804
+	if (!empty($instance['show_special_only'])) {
3805 3805
 		$query_args['show_special_only'] = 1;
3806 3806
 	}
3807 3807
 
3808
-	if ( ! empty( $instance['with_pics_only'] ) ) {
3808
+	if (!empty($instance['with_pics_only'])) {
3809 3809
 		$query_args['with_pics_only']      = 0;
3810 3810
 		$query_args['featured_image_only'] = 1;
3811 3811
 	}
3812 3812
 
3813
-	if ( ! empty( $instance['with_videos_only'] ) ) {
3813
+	if (!empty($instance['with_videos_only'])) {
3814 3814
 		$query_args['with_videos_only'] = 1;
3815 3815
 	}
3816
-	$hide_if_empty = ! empty( $instance['hide_if_empty'] ) ? true : false;
3816
+	$hide_if_empty = !empty($instance['hide_if_empty']) ? true : false;
3817 3817
 
3818
-	if ( ! empty( $categories ) && $categories[0] != '0' && !empty( $category_taxonomy ) ) {
3818
+	if (!empty($categories) && $categories[0] != '0' && !empty($category_taxonomy)) {
3819 3819
 		$tax_query = array(
3820 3820
 			'taxonomy' => $category_taxonomy[0],
3821 3821
 			'field'    => 'id',
3822 3822
 			'terms'    => $category
3823 3823
 		);
3824 3824
 
3825
-		$query_args['tax_query'] = array( $tax_query );
3825
+		$query_args['tax_query'] = array($tax_query);
3826 3826
 	}
3827 3827
 
3828 3828
 	global $gridview_columns_widget, $geodir_is_widget_listing;
3829 3829
 
3830
-	$widget_listings = geodir_get_widget_listings( $query_args );
3830
+	$widget_listings = geodir_get_widget_listings($query_args);
3831 3831
     
3832
-	if ( $hide_if_empty && empty( $widget_listings ) ) {
3832
+	if ($hide_if_empty && empty($widget_listings)) {
3833 3833
 		return;
3834 3834
 	}
3835 3835
     
@@ -3844,11 +3844,11 @@  discard block
 block discarded – undo
3844 3844
 		 *
3845 3845
 		 * @since 1.0.0
3846 3846
 		 */
3847
-		do_action( 'geodir_before_view_all_link_in_widget' ); ?>
3847
+		do_action('geodir_before_view_all_link_in_widget'); ?>
3848 3848
 		<div class="geodir_list_heading clearfix">
3849
-			<?php echo $before_title . $title . $after_title; ?>
3849
+			<?php echo $before_title.$title.$after_title; ?>
3850 3850
 			<a href="<?php echo $viewall_url; ?>"
3851
-			   class="geodir-viewall"><?php _e( 'View all', 'geodirectory' ); ?></a>
3851
+			   class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
3852 3852
 		</div>
3853 3853
 		<?php
3854 3854
 		/**
@@ -3856,10 +3856,10 @@  discard block
 block discarded – undo
3856 3856
 		 *
3857 3857
 		 * @since 1.0.0
3858 3858
 		 */
3859
-		do_action( 'geodir_after_view_all_link_in_widget' ); ?>
3859
+		do_action('geodir_after_view_all_link_in_widget'); ?>
3860 3860
 		<?php
3861
-		if ( strstr( $layout, 'gridview' ) ) {
3862
-			$listing_view_exp        = explode( '_', $layout );
3861
+		if (strstr($layout, 'gridview')) {
3862
+			$listing_view_exp        = explode('_', $layout);
3863 3863
 			$gridview_columns_widget = $layout;
3864 3864
 			$layout                  = $listing_view_exp[0];
3865 3865
 		} else {
@@ -3870,8 +3870,8 @@  discard block
 block discarded – undo
3870 3870
 		 *
3871 3871
 		 * @since 1.0.0
3872 3872
 		 */
3873
-		$template = apply_filters( "geodir_template_part-widget-listing-listview", geodir_locate_template( 'widget-listing-listview' ) );
3874
-		if ( ! isset( $character_count ) ) {
3873
+		$template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3874
+		if (!isset($character_count)) {
3875 3875
 			/**
3876 3876
 			 * Filter the widget's excerpt character count.
3877 3877
 			 *
@@ -3879,7 +3879,7 @@  discard block
 block discarded – undo
3879 3879
 			 *
3880 3880
 			 * @param int $instance ['character_count'] Excerpt character count.
3881 3881
 			 */
3882
-			$character_count = $character_count == '' ? 50 : apply_filters( 'widget_character_count', $character_count );
3882
+			$character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3883 3883
 		}
3884 3884
 
3885 3885
 		global $post, $map_jason, $map_canvas_arr;
@@ -3894,13 +3894,13 @@  discard block
 block discarded – undo
3894 3894
 		 *
3895 3895
 		 * @since 1.0.0
3896 3896
 		 */
3897
-		include( $template );
3897
+		include($template);
3898 3898
 
3899 3899
 		$geodir_is_widget_listing = false;
3900 3900
 
3901 3901
 		$GLOBALS['post'] = $current_post;
3902
-		if ( ! empty( $current_post ) ) {
3903
-			setup_postdata( $current_post );
3902
+		if (!empty($current_post)) {
3903
+			setup_postdata($current_post);
3904 3904
 		}
3905 3905
 		$map_jason      = $current_map_jason;
3906 3906
 		$map_canvas_arr = $current_map_canvas_arr;
@@ -3929,12 +3929,12 @@  discard block
 block discarded – undo
3929 3929
  *
3930 3930
  * @return int Reviews count.
3931 3931
  */
3932
-function geodir_count_reviews_by_term_id( $term_id, $taxonomy, $post_type ) {
3932
+function geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type) {
3933 3933
 	global $wpdb, $plugin_prefix;
3934 3934
 
3935
-	$detail_table = $plugin_prefix . $post_type . '_detail';
3935
+	$detail_table = $plugin_prefix.$post_type.'_detail';
3936 3936
 
3937
-	$sql = "SELECT COALESCE(SUM(rating_count),0) FROM " . $detail_table . " WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(" . $term_id . ", " . $taxonomy . ")";
3937
+	$sql = "SELECT COALESCE(SUM(rating_count),0) FROM ".$detail_table." WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(".$term_id.", ".$taxonomy.")";
3938 3938
 
3939 3939
 	/**
3940 3940
 	 * Filter count review sql query.
@@ -3946,9 +3946,9 @@  discard block
 block discarded – undo
3946 3946
 	 * @param int $taxonomy     The taxonomy Id.
3947 3947
 	 * @param string $post_type The post type.
3948 3948
 	 */
3949
-	$sql = apply_filters( 'geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type );
3949
+	$sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3950 3950
 
3951
-	$count = $wpdb->get_var( $sql );
3951
+	$count = $wpdb->get_var($sql);
3952 3952
 
3953 3953
 	return $count;
3954 3954
 }
@@ -3966,7 +3966,7 @@  discard block
 block discarded – undo
3966 3966
  *
3967 3967
  * @return array Term array data.
3968 3968
  */
3969
-function geodir_count_reviews_by_terms( $force_update = false, $post_ID = 0 ) {
3969
+function geodir_count_reviews_by_terms($force_update = false, $post_ID = 0) {
3970 3970
 	/**
3971 3971
 	 * Filter review count option data.
3972 3972
 	 *
@@ -3976,78 +3976,78 @@  discard block
 block discarded – undo
3976 3976
 	 * @param bool $force_update Force update option value?. Default.false.
3977 3977
 	 * @param int $post_ID       The post id to update if any.
3978 3978
 	 */
3979
-	$option_data = apply_filters( 'geodir_count_reviews_by_terms_before', '', $force_update, $post_ID );
3980
-	if ( ! empty( $option_data ) ) {
3979
+	$option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update, $post_ID);
3980
+	if (!empty($option_data)) {
3981 3981
 		return $option_data;
3982 3982
 	}
3983 3983
 
3984
-	$option_data = get_option( 'geodir_global_review_count' );
3984
+	$option_data = get_option('geodir_global_review_count');
3985 3985
 
3986
-	if ( ! $option_data || $force_update ) {
3987
-		if ( (int) $post_ID > 0 ) { // Update reviews count for specific post categories only.
3986
+	if (!$option_data || $force_update) {
3987
+		if ((int) $post_ID > 0) { // Update reviews count for specific post categories only.
3988 3988
 			global $gd_session;
3989 3989
 			$term_array = (array) $option_data;
3990
-			$post_type  = get_post_type( $post_ID );
3991
-			$taxonomy   = $post_type . 'category';
3992
-			$terms      = wp_get_object_terms( $post_ID, $taxonomy, array( 'fields' => 'ids' ) );
3993
-
3994
-			if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
3995
-				foreach ( $terms as $term_id ) {
3996
-					$count                  = geodir_count_reviews_by_term_id( $term_id, $taxonomy, $post_type );
3997
-					$children               = get_term_children( $term_id, $taxonomy );
3998
-					$term_array[ $term_id ] = $count;
3990
+			$post_type  = get_post_type($post_ID);
3991
+			$taxonomy   = $post_type.'category';
3992
+			$terms      = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3993
+
3994
+			if (!empty($terms) && !is_wp_error($terms)) {
3995
+				foreach ($terms as $term_id) {
3996
+					$count                  = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3997
+					$children               = get_term_children($term_id, $taxonomy);
3998
+					$term_array[$term_id] = $count;
3999 3999
 				}
4000 4000
 			}
4001 4001
 
4002
-			$session_listing = $gd_session->get( 'listing' );
4002
+			$session_listing = $gd_session->get('listing');
4003 4003
 
4004 4004
 			$terms = array();
4005
-			if ( isset( $_POST['post_category'][ $taxonomy ] ) ) {
4006
-				$terms = (array) $_POST['post_category'][ $taxonomy ];
4007
-			} else if ( ! empty( $session_listing ) && isset( $session_listing['post_category'][ $taxonomy ] ) ) {
4008
-				$terms = (array) $session_listing['post_category'][ $taxonomy ];
4005
+			if (isset($_POST['post_category'][$taxonomy])) {
4006
+				$terms = (array) $_POST['post_category'][$taxonomy];
4007
+			} else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
4008
+				$terms = (array) $session_listing['post_category'][$taxonomy];
4009 4009
 			}
4010 4010
 
4011
-			if ( ! empty( $terms ) ) {
4012
-				foreach ( $terms as $term_id ) {
4013
-					if ( $term_id > 0 ) {
4014
-						$count                  = geodir_count_reviews_by_term_id( $term_id, $taxonomy, $post_type );
4015
-						$children               = get_term_children( $term_id, $taxonomy );
4016
-						$term_array[ $term_id ] = $count;
4011
+			if (!empty($terms)) {
4012
+				foreach ($terms as $term_id) {
4013
+					if ($term_id > 0) {
4014
+						$count                  = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
4015
+						$children               = get_term_children($term_id, $taxonomy);
4016
+						$term_array[$term_id] = $count;
4017 4017
 					}
4018 4018
 				}
4019 4019
 			}
4020 4020
 		} else { // Update reviews count for all post categories.
4021 4021
 			$term_array = array();
4022 4022
 			$post_types = geodir_get_posttypes();
4023
-			foreach ( $post_types as $post_type ) {
4023
+			foreach ($post_types as $post_type) {
4024 4024
 
4025
-				$taxonomy = geodir_get_taxonomies( $post_type );
4025
+				$taxonomy = geodir_get_taxonomies($post_type);
4026 4026
 				$taxonomy = $taxonomy[0];
4027 4027
 
4028 4028
 				$args = array(
4029 4029
 					'hide_empty' => false
4030 4030
 				);
4031 4031
 
4032
-				$terms = get_terms( $taxonomy, $args );
4032
+				$terms = get_terms($taxonomy, $args);
4033 4033
 
4034
-				foreach ( $terms as $term ) {
4035
-					$count    = geodir_count_reviews_by_term_id( $term->term_id, $taxonomy, $post_type );
4036
-					$children = get_term_children( $term->term_id, $taxonomy );
4034
+				foreach ($terms as $term) {
4035
+					$count    = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
4036
+					$children = get_term_children($term->term_id, $taxonomy);
4037 4037
 					/*if ( is_array( $children ) ) {
4038 4038
                         foreach ( $children as $child_id ) {
4039 4039
                             $child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type);
4040 4040
                             $count = $count + $child_count;
4041 4041
                         }
4042 4042
                     }*/
4043
-					$term_array[ $term->term_id ] = $count;
4043
+					$term_array[$term->term_id] = $count;
4044 4044
 				}
4045 4045
 			}
4046 4046
 		}
4047 4047
 
4048
-		update_option( 'geodir_global_review_count', $term_array );
4048
+		update_option('geodir_global_review_count', $term_array);
4049 4049
 		//clear cache
4050
-		wp_cache_delete( 'geodir_global_review_count' );
4050
+		wp_cache_delete('geodir_global_review_count');
4051 4051
 
4052 4052
 		return $term_array;
4053 4053
 	} else {
@@ -4063,39 +4063,39 @@  discard block
 block discarded – undo
4063 4063
  * @package GeoDirectory
4064 4064
  * @return bool
4065 4065
  */
4066
-function geodir_term_review_count_force_update( $new_status, $old_status = '', $post = '' ) {
4067
-	if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'geodir_import_export' ) {
4066
+function geodir_term_review_count_force_update($new_status, $old_status = '', $post = '') {
4067
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
4068 4068
 		return; // do not run if importing listings
4069 4069
 	}
4070 4070
 
4071
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
4071
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
4072 4072
 		return;
4073 4073
 	}
4074 4074
 
4075 4075
 	$post_ID = 0;
4076
-	if ( ! empty( $post ) ) {
4077
-		if ( isset( $post->post_type ) && strpos( $post->post_type, 'gd_' ) !== 0 ) {
4076
+	if (!empty($post)) {
4077
+		if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
4078 4078
 			return;
4079 4079
 		}
4080 4080
 
4081
-		if ( $new_status == 'auto-draft' && $old_status == 'new' ) {
4081
+		if ($new_status == 'auto-draft' && $old_status == 'new') {
4082 4082
 			return;
4083 4083
 		}
4084 4084
 
4085
-		if ( ! empty( $post->ID ) ) {
4085
+		if (!empty($post->ID)) {
4086 4086
 			$post_ID = $post->ID;
4087 4087
 		}
4088 4088
 	}
4089 4089
 
4090
-	if ( $new_status != $old_status ) {
4091
-		geodir_count_reviews_by_terms( true, $post_ID );
4090
+	if ($new_status != $old_status) {
4091
+		geodir_count_reviews_by_terms(true, $post_ID);
4092 4092
 	}
4093 4093
 
4094 4094
 	return true;
4095 4095
 }
4096 4096
 
4097
-function geodir_term_review_count_force_update_single_post( $post_id ) {
4098
-	geodir_count_reviews_by_terms( true, $post_id );
4097
+function geodir_term_review_count_force_update_single_post($post_id) {
4098
+	geodir_count_reviews_by_terms(true, $post_id);
4099 4099
 }
4100 4100
 
4101 4101
 /*-----------------------------------------------------------------------------------*/
@@ -4112,11 +4112,11 @@  discard block
 block discarded – undo
4112 4112
  *
4113 4113
  * @return int Post count.
4114 4114
  */
4115
-function geodir_count_posts_by_term( $data, $term ) {
4115
+function geodir_count_posts_by_term($data, $term) {
4116 4116
 
4117
-	if ( $data ) {
4118
-		if ( isset( $data[ $term->term_id ] ) ) {
4119
-			return $data[ $term->term_id ];
4117
+	if ($data) {
4118
+		if (isset($data[$term->term_id])) {
4119
+			return $data[$term->term_id];
4120 4120
 		} else {
4121 4121
 			return 0;
4122 4122
 		}
@@ -4133,8 +4133,8 @@  discard block
 block discarded – undo
4133 4133
  * param array $terms An array of term objects.
4134 4134
  * @return array Sorted terms array.
4135 4135
  */
4136
-function geodir_sort_terms_by_count( $terms ) {
4137
-	usort( $terms, "geodir_sort_by_count_obj" );
4136
+function geodir_sort_terms_by_count($terms) {
4137
+	usort($terms, "geodir_sort_by_count_obj");
4138 4138
 
4139 4139
 	return $terms;
4140 4140
 }
@@ -4149,8 +4149,8 @@  discard block
 block discarded – undo
4149 4149
  *
4150 4150
  * @return array Sorted terms array.
4151 4151
  */
4152
-function geodir_sort_terms_by_review_count( $terms ) {
4153
-	usort( $terms, "geodir_sort_by_review_count_obj" );
4152
+function geodir_sort_terms_by_review_count($terms) {
4153
+	usort($terms, "geodir_sort_by_review_count_obj");
4154 4154
 
4155 4155
 	return $terms;
4156 4156
 }
@@ -4166,12 +4166,12 @@  discard block
 block discarded – undo
4166 4166
  *
4167 4167
  * @return array Sorted terms array.
4168 4168
  */
4169
-function geodir_sort_terms( $terms, $sort = 'count' ) {
4170
-	if ( $sort == 'count' ) {
4171
-		return geodir_sort_terms_by_count( $terms );
4169
+function geodir_sort_terms($terms, $sort = 'count') {
4170
+	if ($sort == 'count') {
4171
+		return geodir_sort_terms_by_count($terms);
4172 4172
 	}
4173
-	if ( $sort == 'review_count' ) {
4174
-		return geodir_sort_terms_by_review_count( $terms );
4173
+	if ($sort == 'review_count') {
4174
+		return geodir_sort_terms_by_review_count($terms);
4175 4175
 	}
4176 4176
 	return $terms;
4177 4177
 }
@@ -4190,7 +4190,7 @@  discard block
 block discarded – undo
4190 4190
  *
4191 4191
  * @return bool
4192 4192
  */
4193
-function geodir_sort_by_count( $a, $b ) {
4193
+function geodir_sort_by_count($a, $b) {
4194 4194
 	return $a['count'] < $b['count'];
4195 4195
 }
4196 4196
 
@@ -4205,7 +4205,7 @@  discard block
 block discarded – undo
4205 4205
  *
4206 4206
  * @return bool
4207 4207
  */
4208
-function geodir_sort_by_count_obj( $a, $b ) {
4208
+function geodir_sort_by_count_obj($a, $b) {
4209 4209
 	return $a->count < $b->count;
4210 4210
 }
4211 4211
 
@@ -4220,7 +4220,7 @@  discard block
 block discarded – undo
4220 4220
  *
4221 4221
  * @return bool
4222 4222
  */
4223
-function geodir_sort_by_review_count_obj( $a, $b ) {
4223
+function geodir_sort_by_review_count_obj($a, $b) {
4224 4224
 	return $a->review_count < $b->review_count;
4225 4225
 }
4226 4226
 
@@ -4237,35 +4237,35 @@  discard block
 block discarded – undo
4237 4237
 	 * @since   1.4.2
4238 4238
 	 * @package GeoDirectory
4239 4239
 	 */
4240
-	$locale = apply_filters( 'plugin_locale', get_locale(), 'geodirectory' );
4240
+	$locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
4241 4241
 
4242
-	load_textdomain( 'geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo' );
4243
-	load_plugin_textdomain( 'geodirectory', false, plugin_basename( dirname( dirname( __FILE__ ) ) ) . '/geodirectory-languages' );
4242
+	load_textdomain('geodirectory', WP_LANG_DIR.'/'.'geodirectory'.'/'.'geodirectory'.'-'.$locale.'.mo');
4243
+	load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))).'/geodirectory-languages');
4244 4244
 
4245 4245
 	/**
4246 4246
 	 * Define language constants.
4247 4247
 	 *
4248 4248
 	 * @since 1.0.0
4249 4249
 	 */
4250
-	require_once( geodir_plugin_path() . '/language.php' );
4250
+	require_once(geodir_plugin_path().'/language.php');
4251 4251
 
4252
-	$language_file = geodir_plugin_path() . '/db-language.php';
4252
+	$language_file = geodir_plugin_path().'/db-language.php';
4253 4253
 
4254 4254
 	// Load language string file if not created yet
4255
-	if ( ! file_exists( $language_file ) ) {
4255
+	if (!file_exists($language_file)) {
4256 4256
 		geodirectory_load_db_language();
4257 4257
 	}
4258 4258
 
4259
-	if ( file_exists( $language_file ) ) {
4259
+	if (file_exists($language_file)) {
4260 4260
 		/**
4261 4261
 		 * Language strings from database.
4262 4262
 		 *
4263 4263
 		 * @since 1.4.2
4264 4264
 		 */
4265 4265
 		try {
4266
-			require_once( $language_file );
4267
-		} catch ( Exception $e ) {
4268
-			error_log( 'Language Error: ' . $e->getMessage() );
4266
+			require_once($language_file);
4267
+		} catch (Exception $e) {
4268
+			error_log('Language Error: '.$e->getMessage());
4269 4269
 		}
4270 4270
 	}
4271 4271
 }
@@ -4282,19 +4282,19 @@  discard block
 block discarded – undo
4282 4282
  */
4283 4283
 function geodirectory_load_db_language() {
4284 4284
 	global $wp_filesystem;
4285
-	if ( empty( $wp_filesystem ) ) {
4286
-		require_once( ABSPATH . '/wp-admin/includes/file.php' );
4285
+	if (empty($wp_filesystem)) {
4286
+		require_once(ABSPATH.'/wp-admin/includes/file.php');
4287 4287
 		WP_Filesystem();
4288 4288
 		global $wp_filesystem;
4289 4289
 	}
4290 4290
 
4291
-	$language_file = geodir_plugin_path() . '/db-language.php';
4291
+	$language_file = geodir_plugin_path().'/db-language.php';
4292 4292
 
4293
-	if ( is_file( $language_file ) && ! is_writable( $language_file ) ) {
4293
+	if (is_file($language_file) && !is_writable($language_file)) {
4294 4294
 		return false;
4295 4295
 	} // Not possible to create.
4296 4296
 
4297
-	if ( ! is_file( $language_file ) && ! is_writable( dirname( $language_file ) ) ) {
4297
+	if (!is_file($language_file) && !is_writable(dirname($language_file))) {
4298 4298
 		return false;
4299 4299
 	} // Not possible to create.
4300 4300
 
@@ -4308,9 +4308,9 @@  discard block
 block discarded – undo
4308 4308
 	 *
4309 4309
 	 * @param array $contents_strings Array of strings.
4310 4310
 	 */
4311
-	$contents_strings = apply_filters( 'geodir_load_db_language', $contents_strings );
4311
+	$contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
4312 4312
 
4313
-	$contents_strings = array_unique( $contents_strings );
4313
+	$contents_strings = array_unique($contents_strings);
4314 4314
 
4315 4315
 	$contents_head   = array();
4316 4316
 	$contents_head[] = "<?php";
@@ -4327,21 +4327,21 @@  discard block
 block discarded – undo
4327 4327
 	$contents_foot[] = "";
4328 4328
 	$contents_foot[] = "";
4329 4329
 
4330
-	$contents = implode( PHP_EOL, $contents_head );
4330
+	$contents = implode(PHP_EOL, $contents_head);
4331 4331
 
4332
-	if ( ! empty( $contents_strings ) ) {
4333
-		foreach ( $contents_strings as $string ) {
4334
-			if ( is_scalar( $string ) && $string != '' ) {
4335
-				$string = str_replace( "'", "\'", $string );
4336
-				geodir_wpml_register_string( $string );
4337
-				$contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
4332
+	if (!empty($contents_strings)) {
4333
+		foreach ($contents_strings as $string) {
4334
+			if (is_scalar($string) && $string != '') {
4335
+				$string = str_replace("'", "\'", $string);
4336
+				geodir_wpml_register_string($string);
4337
+				$contents .= PHP_EOL."__('".$string."', 'geodirectory');";
4338 4338
 			}
4339 4339
 		}
4340 4340
 	}
4341 4341
 
4342
-	$contents .= implode( PHP_EOL, $contents_foot );
4342
+	$contents .= implode(PHP_EOL, $contents_foot);
4343 4343
 
4344
-	if ( $wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE ) ) {
4344
+	if ($wp_filesystem->put_contents($language_file, $contents, FS_CHMOD_FILE)) {
4345 4345
 		return false;
4346 4346
 	} // Failure; could not write file.
4347 4347
 
@@ -4362,49 +4362,49 @@  discard block
 block discarded – undo
4362 4362
  *
4363 4363
  * @return array Translation texts.
4364 4364
  */
4365
-function geodir_load_custom_field_translation( $translation_texts = array() ) {
4365
+function geodir_load_custom_field_translation($translation_texts = array()) {
4366 4366
 	global $wpdb;
4367 4367
 
4368 4368
 	// Custom fields table
4369
-	$sql  = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values, validation_msg FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
4370
-	$rows = $wpdb->get_results( $sql );
4369
+	$sql  = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values, validation_msg FROM ".GEODIR_CUSTOM_FIELDS_TABLE;
4370
+	$rows = $wpdb->get_results($sql);
4371 4371
 
4372
-	if ( ! empty( $rows ) ) {
4373
-		foreach ( $rows as $row ) {
4374
-			if ( ! empty( $row->admin_title ) ) {
4375
-				$translation_texts[] = stripslashes_deep( $row->admin_title );
4372
+	if (!empty($rows)) {
4373
+		foreach ($rows as $row) {
4374
+			if (!empty($row->admin_title)) {
4375
+				$translation_texts[] = stripslashes_deep($row->admin_title);
4376 4376
 			}
4377 4377
 
4378
-			if ( ! empty( $row->admin_desc ) ) {
4379
-				$translation_texts[] = stripslashes_deep( $row->admin_desc );
4378
+			if (!empty($row->admin_desc)) {
4379
+				$translation_texts[] = stripslashes_deep($row->admin_desc);
4380 4380
 			}
4381 4381
 
4382
-			if ( ! empty( $row->site_title ) ) {
4383
-				$translation_texts[] = stripslashes_deep( $row->site_title );
4382
+			if (!empty($row->site_title)) {
4383
+				$translation_texts[] = stripslashes_deep($row->site_title);
4384 4384
 			}
4385 4385
 
4386
-			if ( ! empty( $row->clabels ) ) {
4387
-				$translation_texts[] = stripslashes_deep( $row->clabels );
4386
+			if (!empty($row->clabels)) {
4387
+				$translation_texts[] = stripslashes_deep($row->clabels);
4388 4388
 			}
4389 4389
 
4390
-			if ( ! empty( $row->required_msg ) ) {
4391
-				$translation_texts[] = stripslashes_deep( $row->required_msg );
4390
+			if (!empty($row->required_msg)) {
4391
+				$translation_texts[] = stripslashes_deep($row->required_msg);
4392 4392
 			}
4393 4393
             
4394
-			if ( ! empty( $row->validation_msg ) ) {
4395
-				$translation_texts[] = stripslashes_deep( $row->validation_msg );
4394
+			if (!empty($row->validation_msg)) {
4395
+				$translation_texts[] = stripslashes_deep($row->validation_msg);
4396 4396
 			}
4397 4397
 
4398
-			if ( ! empty( $row->default_value ) ) {
4399
-				$translation_texts[] = stripslashes_deep( $row->default_value );
4398
+			if (!empty($row->default_value)) {
4399
+				$translation_texts[] = stripslashes_deep($row->default_value);
4400 4400
 			}
4401 4401
 
4402
-			if ( ! empty( $row->option_values ) ) {
4403
-				$option_values = geodir_string_values_to_options( stripslashes_deep( $row->option_values ) );
4402
+			if (!empty($row->option_values)) {
4403
+				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
4404 4404
 
4405
-				if ( ! empty( $option_values ) ) {
4406
-					foreach ( $option_values as $option_value ) {
4407
-						if ( ! empty( $option_value['label'] ) ) {
4405
+				if (!empty($option_values)) {
4406
+					foreach ($option_values as $option_value) {
4407
+						if (!empty($option_value['label'])) {
4408 4408
 							$translation_texts[] = $option_value['label'];
4409 4409
 						}
4410 4410
 					}
@@ -4414,56 +4414,56 @@  discard block
 block discarded – undo
4414 4414
 	}
4415 4415
 
4416 4416
 	// Custom sorting fields table
4417
-	$sql  = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
4418
-	$rows = $wpdb->get_results( $sql );
4417
+	$sql  = "SELECT site_title, asc_title, desc_title FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE;
4418
+	$rows = $wpdb->get_results($sql);
4419 4419
 
4420
-	if ( ! empty( $rows ) ) {
4421
-		foreach ( $rows as $row ) {
4422
-			if ( ! empty( $row->site_title ) ) {
4423
-				$translation_texts[] = stripslashes_deep( $row->site_title );
4420
+	if (!empty($rows)) {
4421
+		foreach ($rows as $row) {
4422
+			if (!empty($row->site_title)) {
4423
+				$translation_texts[] = stripslashes_deep($row->site_title);
4424 4424
 			}
4425 4425
 
4426
-			if ( ! empty( $row->asc_title ) ) {
4427
-				$translation_texts[] = stripslashes_deep( $row->asc_title );
4426
+			if (!empty($row->asc_title)) {
4427
+				$translation_texts[] = stripslashes_deep($row->asc_title);
4428 4428
 			}
4429 4429
 
4430
-			if ( ! empty( $row->desc_title ) ) {
4431
-				$translation_texts[] = stripslashes_deep( $row->desc_title );
4430
+			if (!empty($row->desc_title)) {
4431
+				$translation_texts[] = stripslashes_deep($row->desc_title);
4432 4432
 			}
4433 4433
 		}
4434 4434
 	}
4435 4435
 
4436 4436
 	// Advance search filter fields table
4437
-	if ( defined( 'GEODIR_ADVANCE_SEARCH_TABLE' ) ) {
4438
-		$sql  = "SELECT field_site_name, front_search_title, first_search_text, last_search_text, field_desc FROM " . GEODIR_ADVANCE_SEARCH_TABLE;
4439
-		$rows = $wpdb->get_results( $sql );
4440
-
4441
-		if ( ! empty( $rows ) ) {
4442
-			foreach ( $rows as $row ) {
4443
-				if ( ! empty( $row->field_site_name ) ) {
4444
-					$translation_texts[] = stripslashes_deep( $row->field_site_name );
4437
+	if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
4438
+		$sql  = "SELECT field_site_name, front_search_title, first_search_text, last_search_text, field_desc FROM ".GEODIR_ADVANCE_SEARCH_TABLE;
4439
+		$rows = $wpdb->get_results($sql);
4440
+
4441
+		if (!empty($rows)) {
4442
+			foreach ($rows as $row) {
4443
+				if (!empty($row->field_site_name)) {
4444
+					$translation_texts[] = stripslashes_deep($row->field_site_name);
4445 4445
 				}
4446 4446
 
4447
-				if ( ! empty( $row->front_search_title ) ) {
4448
-					$translation_texts[] = stripslashes_deep( $row->front_search_title );
4447
+				if (!empty($row->front_search_title)) {
4448
+					$translation_texts[] = stripslashes_deep($row->front_search_title);
4449 4449
 				}
4450 4450
 
4451
-				if ( ! empty( $row->first_search_text ) ) {
4452
-					$translation_texts[] = stripslashes_deep( $row->first_search_text );
4451
+				if (!empty($row->first_search_text)) {
4452
+					$translation_texts[] = stripslashes_deep($row->first_search_text);
4453 4453
 				}
4454 4454
 
4455
-				if ( ! empty( $row->last_search_text ) ) {
4456
-					$translation_texts[] = stripslashes_deep( $row->last_search_text );
4455
+				if (!empty($row->last_search_text)) {
4456
+					$translation_texts[] = stripslashes_deep($row->last_search_text);
4457 4457
 				}
4458 4458
 
4459
-				if ( ! empty( $row->field_desc ) ) {
4460
-					$translation_texts[] = stripslashes_deep( $row->field_desc );
4459
+				if (!empty($row->field_desc)) {
4460
+					$translation_texts[] = stripslashes_deep($row->field_desc);
4461 4461
 				}
4462 4462
 			}
4463 4463
 		}
4464 4464
 	}
4465 4465
 
4466
-	$translation_texts = ! empty( $translation_texts ) ? array_unique( $translation_texts ) : $translation_texts;
4466
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4467 4467
 
4468 4468
 	return $translation_texts;
4469 4469
 }
@@ -4485,7 +4485,7 @@  discard block
 block discarded – undo
4485 4485
 	 *
4486 4486
 	 * @param array $geodir_allowed_mime_types and file extensions.
4487 4487
 	 */
4488
-	return apply_filters( 'geodir_allowed_mime_types', array(
4488
+	return apply_filters('geodir_allowed_mime_types', array(
4489 4489
 			'Image'       => array( // Image formats.
4490 4490
 				'jpg'  => 'image/jpeg',
4491 4491
 				'jpe'  => 'image/jpeg',
@@ -4554,18 +4554,18 @@  discard block
 block discarded – undo
4554 4554
  *
4555 4555
  * @return string User display name.
4556 4556
  */
4557
-function geodir_get_client_name( $user_id ) {
4557
+function geodir_get_client_name($user_id) {
4558 4558
 	$client_name = '';
4559 4559
 
4560
-	$user_data = get_userdata( $user_id );
4560
+	$user_data = get_userdata($user_id);
4561 4561
 
4562
-	if ( ! empty( $user_data ) ) {
4563
-		if ( isset( $user_data->display_name ) && trim( $user_data->display_name ) != '' ) {
4564
-			$client_name = trim( $user_data->display_name );
4565
-		} else if ( isset( $user_data->user_nicename ) && trim( $user_data->user_nicename ) != '' ) {
4566
-			$client_name = trim( $user_data->user_nicename );
4562
+	if (!empty($user_data)) {
4563
+		if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
4564
+			$client_name = trim($user_data->display_name);
4565
+		} else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
4566
+			$client_name = trim($user_data->user_nicename);
4567 4567
 		} else {
4568
-			$client_name = trim( $user_data->user_login );
4568
+			$client_name = trim($user_data->user_login);
4569 4569
 		}
4570 4570
 	}
4571 4571
 
@@ -4573,17 +4573,17 @@  discard block
 block discarded – undo
4573 4573
 }
4574 4574
 
4575 4575
 
4576
-add_filter( 'wpseo_replacements', 'geodir_wpseo_replacements', 10, 1 );
4576
+add_filter('wpseo_replacements', 'geodir_wpseo_replacements', 10, 1);
4577 4577
 /*
4578 4578
  * Add location variables to wpseo replacements.
4579 4579
  *
4580 4580
  * @since 1.5.4
4581 4581
  */
4582
-function geodir_wpseo_replacements( $vars ) {
4582
+function geodir_wpseo_replacements($vars) {
4583 4583
 
4584 4584
 	// location variables
4585 4585
 	$gd_post_type   = geodir_get_current_posttype();
4586
-	$location_array = geodir_get_current_location_terms( 'query_vars', $gd_post_type );
4586
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4587 4587
 	/**
4588 4588
 	 * Filter the title variables location variables array
4589 4589
 	 *
@@ -4593,7 +4593,7 @@  discard block
 block discarded – undo
4593 4593
 	 * @param array $location_array The array of location variables.
4594 4594
 	 * @param array $vars           The page title variables.
4595 4595
 	 */
4596
-	$location_array  = apply_filters( 'geodir_filter_title_variables_location_arr_seo', $location_array, $vars );
4596
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr_seo', $location_array, $vars);
4597 4597
 
4598 4598
 
4599 4599
 	$location_replace_vars = geodir_location_replace_vars($location_array, NULL, '');
@@ -4608,13 +4608,13 @@  discard block
 block discarded – undo
4608 4608
 	 * @param string $vars          The title with variables.
4609 4609
 	 * @param array $location_array The array of location variables.
4610 4610
 	 */
4611
-	return apply_filters( 'geodir_wpseo_replacements_vars', $vars, $location_array );
4611
+	return apply_filters('geodir_wpseo_replacements_vars', $vars, $location_array);
4612 4612
 }
4613 4613
 
4614 4614
 
4615
-add_filter( 'geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3 );
4616
-add_filter( 'geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2 );
4617
-add_filter( 'geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3 );
4615
+add_filter('geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3);
4616
+add_filter('geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2);
4617
+add_filter('geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3);
4618 4618
 
4619 4619
 /**
4620 4620
  * Filter the title variables.
@@ -4656,14 +4656,14 @@  discard block
 block discarded – undo
4656 4656
  *
4657 4657
  * @return string Title after filtered variables.
4658 4658
  */
4659
-function geodir_filter_title_variables( $title, $gd_page, $sep = '' ) {
4659
+function geodir_filter_title_variables($title, $gd_page, $sep = '') {
4660 4660
 	global $wp, $post;
4661 4661
 
4662
-	if ( ! $gd_page || ! $title ) {
4662
+	if (!$gd_page || !$title) {
4663 4663
 		return $title; // if no a GD page then bail.
4664 4664
 	}
4665 4665
 
4666
-	if ( $sep == '' ) {
4666
+	if ($sep == '') {
4667 4667
 		/**
4668 4668
 		 * Filter the page title separator.
4669 4669
 		 *
@@ -4672,100 +4672,100 @@  discard block
 block discarded – undo
4672 4672
 		 *
4673 4673
 		 * @param string $sep The separator, default: `|`.
4674 4674
 		 */
4675
-		$sep = apply_filters( 'geodir_page_title_separator', '|' );
4675
+		$sep = apply_filters('geodir_page_title_separator', '|');
4676 4676
 	}
4677 4677
 
4678
-	if ( strpos( $title, '%%title%%' ) !== false ) {
4679
-		$title = str_replace( "%%title%%", $post->post_title, $title );
4678
+	if (strpos($title, '%%title%%') !== false) {
4679
+		$title = str_replace("%%title%%", $post->post_title, $title);
4680 4680
 	}
4681 4681
 
4682
-	if ( strpos( $title, '%%sitename%%' ) !== false ) {
4683
-		$title = str_replace( "%%sitename%%", get_bloginfo( 'name' ), $title );
4682
+	if (strpos($title, '%%sitename%%') !== false) {
4683
+		$title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
4684 4684
 	}
4685 4685
 
4686
-	if ( strpos( $title, '%%sitedesc%%' ) !== false ) {
4687
-		$title = str_replace( "%%sitedesc%%", get_bloginfo( 'description' ), $title );
4686
+	if (strpos($title, '%%sitedesc%%') !== false) {
4687
+		$title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
4688 4688
 	}
4689 4689
 
4690
-	if ( strpos( $title, '%%excerpt%%' ) !== false ) {
4691
-		$title = str_replace( "%%excerpt%%", strip_tags( get_the_excerpt() ), $title );
4690
+	if (strpos($title, '%%excerpt%%') !== false) {
4691
+		$title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
4692 4692
 	}
4693 4693
 
4694
-	if ( $gd_page == 'search' || $gd_page == 'author' ) {
4695
-		$post_type = isset( $_REQUEST['stype'] ) ? sanitize_text_field( $_REQUEST['stype'] ) : '';
4696
-	} else if ( $gd_page == 'add-listing' ) {
4697
-		$post_type = ( isset( $_REQUEST['listing_type'] ) ) ? sanitize_text_field( $_REQUEST['listing_type'] ) : '';
4698
-		$post_type = ! $post_type && ! empty( $_REQUEST['pid'] ) ? get_post_type( (int) $_REQUEST['pid'] ) : $post_type;
4699
-	} else if ( isset( $post->post_type ) && $post->post_type && in_array( $post->post_type, geodir_get_posttypes() ) ) {
4694
+	if ($gd_page == 'search' || $gd_page == 'author') {
4695
+		$post_type = isset($_REQUEST['stype']) ? sanitize_text_field($_REQUEST['stype']) : '';
4696
+	} else if ($gd_page == 'add-listing') {
4697
+		$post_type = (isset($_REQUEST['listing_type'])) ? sanitize_text_field($_REQUEST['listing_type']) : '';
4698
+		$post_type = !$post_type && !empty($_REQUEST['pid']) ? get_post_type((int) $_REQUEST['pid']) : $post_type;
4699
+	} else if (isset($post->post_type) && $post->post_type && in_array($post->post_type, geodir_get_posttypes())) {
4700 4700
 		$post_type = $post->post_type;
4701 4701
 	} else {
4702
-		$post_type = get_query_var( 'post_type' );
4702
+		$post_type = get_query_var('post_type');
4703 4703
 	}
4704 4704
 
4705
-	if ( strpos( $title, '%%pt_single%%' ) !== false ) {
4705
+	if (strpos($title, '%%pt_single%%') !== false) {
4706 4706
 		$singular_name = '';
4707
-		if ( $post_type && $singular_name = get_post_type_singular_label( $post_type ) ) {
4708
-			$singular_name = __( $singular_name, 'geodirectory' );
4707
+		if ($post_type && $singular_name = get_post_type_singular_label($post_type)) {
4708
+			$singular_name = __($singular_name, 'geodirectory');
4709 4709
 		}
4710 4710
 
4711
-		$title = str_replace( "%%pt_single%%", $singular_name, $title );
4711
+		$title = str_replace("%%pt_single%%", $singular_name, $title);
4712 4712
 	}
4713 4713
 
4714
-	if ( strpos( $title, '%%pt_plural%%' ) !== false ) {
4714
+	if (strpos($title, '%%pt_plural%%') !== false) {
4715 4715
 		$plural_name = '';
4716
-		if ( $post_type && $plural_name = get_post_type_plural_label( $post_type ) ) {
4717
-			$plural_name = __( $plural_name, 'geodirectory' );
4716
+		if ($post_type && $plural_name = get_post_type_plural_label($post_type)) {
4717
+			$plural_name = __($plural_name, 'geodirectory');
4718 4718
 		}
4719 4719
 
4720
-		$title = str_replace( "%%pt_plural%%", $plural_name, $title );
4720
+		$title = str_replace("%%pt_plural%%", $plural_name, $title);
4721 4721
 	}
4722 4722
 
4723
-	if ( strpos( $title, '%%category%%' ) !== false ) {
4723
+	if (strpos($title, '%%category%%') !== false) {
4724 4724
 		$cat_name = '';
4725 4725
 
4726
-		if ( $gd_page == 'detail' ) {
4727
-			if ( $post->default_category ) {
4728
-				$cat      = get_term( $post->default_category, $post->post_type . 'category' );
4729
-				$cat_name = ( isset( $cat->name ) ) ? $cat->name : '';
4726
+		if ($gd_page == 'detail') {
4727
+			if ($post->default_category) {
4728
+				$cat      = get_term($post->default_category, $post->post_type.'category');
4729
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4730 4730
 			}
4731
-		} else if ( $gd_page == 'listing' ) {
4731
+		} else if ($gd_page == 'listing') {
4732 4732
 			$queried_object = get_queried_object();
4733
-			if ( isset( $queried_object->name ) ) {
4733
+			if (isset($queried_object->name)) {
4734 4734
 				$cat_name = $queried_object->name;
4735 4735
 			}
4736 4736
 		}
4737
-		$title = str_replace( "%%category%%", $cat_name, $title );
4737
+		$title = str_replace("%%category%%", $cat_name, $title);
4738 4738
 	}
4739 4739
 
4740
-	if ( strpos( $title, '%%tag%%' ) !== false ) {
4740
+	if (strpos($title, '%%tag%%') !== false) {
4741 4741
 		$cat_name = '';
4742 4742
 
4743
-		if ( $gd_page == 'detail' ) {
4744
-			if ( $post->default_category ) {
4745
-				$cat      = get_term( $post->default_category, $post->post_type . 'category' );
4746
-				$cat_name = ( isset( $cat->name ) ) ? $cat->name : '';
4743
+		if ($gd_page == 'detail') {
4744
+			if ($post->default_category) {
4745
+				$cat      = get_term($post->default_category, $post->post_type.'category');
4746
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4747 4747
 			}
4748
-		} else if ( $gd_page == 'listing' ) {
4748
+		} else if ($gd_page == 'listing') {
4749 4749
 			$queried_object = get_queried_object();
4750
-			if ( isset( $queried_object->name ) ) {
4750
+			if (isset($queried_object->name)) {
4751 4751
 				$cat_name = $queried_object->name;
4752 4752
 			}
4753 4753
 		}
4754
-		$title = str_replace( "%%tag%%", $cat_name, $title );
4754
+		$title = str_replace("%%tag%%", $cat_name, $title);
4755 4755
 	}
4756 4756
 
4757
-	if ( strpos( $title, '%%id%%' ) !== false ) {
4758
-		$ID    = ( isset( $post->ID ) ) ? $post->ID : '';
4759
-		$title = str_replace( "%%id%%", $ID, $title );
4757
+	if (strpos($title, '%%id%%') !== false) {
4758
+		$ID    = (isset($post->ID)) ? $post->ID : '';
4759
+		$title = str_replace("%%id%%", $ID, $title);
4760 4760
 	}
4761 4761
 
4762
-	if ( strpos( $title, '%%sep%%' ) !== false ) {
4763
-		$title = str_replace( "%%sep%%", $sep, $title );
4762
+	if (strpos($title, '%%sep%%') !== false) {
4763
+		$title = str_replace("%%sep%%", $sep, $title);
4764 4764
 	}
4765 4765
 
4766 4766
 	// location variables
4767 4767
 	$gd_post_type   = geodir_get_current_posttype();
4768
-	$location_array = geodir_get_current_location_terms( 'query_vars', $gd_post_type );
4768
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4769 4769
 	
4770 4770
 	/**
4771 4771
 	 * Filter the title variables location variables array
@@ -4778,20 +4778,20 @@  discard block
 block discarded – undo
4778 4778
 	 * @param string $gd_page       The page being filtered.
4779 4779
 	 * @param string $sep           The separator, default: `|`.
4780 4780
 	 */
4781
-	$location_array  = apply_filters( 'geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep );
4781
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep);
4782 4782
 	
4783
-	if ( $gd_page == 'location' && get_query_var( 'gd_country_full' ) ) {
4784
-		if ( get_query_var( 'gd_country_full' ) ) {
4785
-			$location_array['gd_country'] = get_query_var( 'gd_country_full' );
4783
+	if ($gd_page == 'location' && get_query_var('gd_country_full')) {
4784
+		if (get_query_var('gd_country_full')) {
4785
+			$location_array['gd_country'] = get_query_var('gd_country_full');
4786 4786
 		}
4787
-		if ( get_query_var( 'gd_region_full' ) ) {
4788
-			$location_array['gd_region'] = get_query_var( 'gd_region_full' );
4787
+		if (get_query_var('gd_region_full')) {
4788
+			$location_array['gd_region'] = get_query_var('gd_region_full');
4789 4789
 		}
4790
-		if ( get_query_var( 'gd_city_full' ) ) {
4791
-			$location_array['gd_city'] = get_query_var( 'gd_city_full' );
4790
+		if (get_query_var('gd_city_full')) {
4791
+			$location_array['gd_city'] = get_query_var('gd_city_full');
4792 4792
 		}
4793
-		if ( get_query_var( 'gd_neighbourhood_full' ) ) {
4794
-			$location_array['gd_neighbourhood'] = get_query_var( 'gd_neighbourhood_full' );
4793
+		if (get_query_var('gd_neighbourhood_full')) {
4794
+			$location_array['gd_neighbourhood'] = get_query_var('gd_neighbourhood_full');
4795 4795
 		}
4796 4796
 	}
4797 4797
 	
@@ -4806,57 +4806,57 @@  discard block
 block discarded – undo
4806 4806
 	 * @param string $gd_page       The page being filtered.
4807 4807
 	 * @param string $sep           The separator, default: `|`.
4808 4808
 	 */
4809
-	$title = apply_filters( 'geodir_replace_location_variables', $title, $location_array, $gd_page, $sep );
4809
+	$title = apply_filters('geodir_replace_location_variables', $title, $location_array, $gd_page, $sep);
4810 4810
 	
4811
-	if ( strpos( $title, '%%search_term%%' ) !== false ) {
4811
+	if (strpos($title, '%%search_term%%') !== false) {
4812 4812
 		$search_term = '';
4813
-		if ( isset( $_REQUEST['s'] ) ) {
4814
-			$search_term = esc_attr( $_REQUEST['s'] );
4813
+		if (isset($_REQUEST['s'])) {
4814
+			$search_term = esc_attr($_REQUEST['s']);
4815 4815
 		}
4816
-		$title = str_replace( "%%search_term%%", $search_term, $title );
4816
+		$title = str_replace("%%search_term%%", $search_term, $title);
4817 4817
 	}
4818 4818
 
4819
-	if ( strpos( $title, '%%search_near%%' ) !== false ) {
4819
+	if (strpos($title, '%%search_near%%') !== false) {
4820 4820
 		$search_term = '';
4821
-		if ( isset( $_REQUEST['snear'] ) ) {
4822
-			$search_term = esc_attr( $_REQUEST['snear'] );
4821
+		if (isset($_REQUEST['snear'])) {
4822
+			$search_term = esc_attr($_REQUEST['snear']);
4823 4823
 		}
4824
-		$title = str_replace( "%%search_near%%", $search_term, $title );
4824
+		$title = str_replace("%%search_near%%", $search_term, $title);
4825 4825
 	}
4826 4826
 
4827
-	if ( strpos( $title, '%%name%%' ) !== false ) {
4828
-		if ( is_author() ) {
4829
-			$curauth     = ( get_query_var( 'author_name' ) ) ? get_user_by( 'slug', get_query_var( 'author_name' ) ) : get_userdata( get_query_var( 'author' ) );
4827
+	if (strpos($title, '%%name%%') !== false) {
4828
+		if (is_author()) {
4829
+			$curauth     = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
4830 4830
 			$author_name = $curauth->display_name;
4831 4831
 		} else {
4832 4832
 			$author_name = get_the_author();
4833 4833
 		}
4834
-		if ( ! $author_name || $author_name === '' ) {
4834
+		if (!$author_name || $author_name === '') {
4835 4835
 			$queried_object = get_queried_object();
4836 4836
 
4837
-			if ( isset( $queried_object->data->user_nicename ) ) {
4837
+			if (isset($queried_object->data->user_nicename)) {
4838 4838
 				$author_name = $queried_object->data->display_name;
4839 4839
 			}
4840 4840
 		}
4841
-		$title = str_replace( "%%name%%", $author_name, $title );
4841
+		$title = str_replace("%%name%%", $author_name, $title);
4842 4842
 	}
4843 4843
 
4844
-	if ( strpos( $title, '%%page%%' ) !== false ) {
4845
-		$page  = geodir_title_meta_page( $sep );
4846
-		$title = str_replace( "%%page%%", $page, $title );
4844
+	if (strpos($title, '%%page%%') !== false) {
4845
+		$page  = geodir_title_meta_page($sep);
4846
+		$title = str_replace("%%page%%", $page, $title);
4847 4847
 	}
4848
-	if ( strpos( $title, '%%pagenumber%%' ) !== false ) {
4848
+	if (strpos($title, '%%pagenumber%%') !== false) {
4849 4849
 		$pagenumber = geodir_title_meta_pagenumber();
4850
-		$title      = str_replace( "%%pagenumber%%", $pagenumber, $title );
4850
+		$title      = str_replace("%%pagenumber%%", $pagenumber, $title);
4851 4851
 	}
4852
-	if ( strpos( $title, '%%pagetotal%%' ) !== false ) {
4852
+	if (strpos($title, '%%pagetotal%%') !== false) {
4853 4853
 		$pagetotal = geodir_title_meta_pagetotal();
4854
-		$title     = str_replace( "%%pagetotal%%", $pagetotal, $title );
4854
+		$title     = str_replace("%%pagetotal%%", $pagetotal, $title);
4855 4855
 	}
4856 4856
 
4857
-	$title = wptexturize( $title );
4858
-	$title = convert_chars( $title );
4859
-	$title = esc_html( $title );
4857
+	$title = wptexturize($title);
4858
+	$title = convert_chars($title);
4859
+	$title = esc_html($title);
4860 4860
 
4861 4861
 	/**
4862 4862
 	 * Filter the title variables after standard ones have been filtered.
@@ -4870,7 +4870,7 @@  discard block
 block discarded – undo
4870 4870
 	 * @param string $sep           The separator, default: `|`.
4871 4871
 	 */
4872 4872
 
4873
-	return apply_filters( 'geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep );
4873
+	return apply_filters('geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep);
4874 4874
 }
4875 4875
 
4876 4876
 /**
@@ -4883,82 +4883,82 @@  discard block
 block discarded – undo
4883 4883
  *
4884 4884
  * @return array Translation texts.
4885 4885
  */
4886
-function geodir_load_cpt_text_translation( $translation_texts = array() ) {
4887
-	$gd_post_types = geodir_get_posttypes( 'array' );
4886
+function geodir_load_cpt_text_translation($translation_texts = array()) {
4887
+	$gd_post_types = geodir_get_posttypes('array');
4888 4888
 
4889
-	if ( ! empty( $gd_post_types ) ) {
4890
-		foreach ( $gd_post_types as $post_type => $cpt_info ) {
4891
-			$labels      = isset( $cpt_info['labels'] ) ? $cpt_info['labels'] : '';
4892
-			$description = isset( $cpt_info['description'] ) ? $cpt_info['description'] : '';
4893
-			$seo         = isset( $cpt_info['seo'] ) ? $cpt_info['seo'] : '';
4889
+	if (!empty($gd_post_types)) {
4890
+		foreach ($gd_post_types as $post_type => $cpt_info) {
4891
+			$labels      = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4892
+			$description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4893
+			$seo         = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4894 4894
 
4895
-			if ( ! empty( $labels ) ) {
4896
-				if ( $labels['name'] != '' && ! in_array( $labels['name'], $translation_texts ) ) {
4895
+			if (!empty($labels)) {
4896
+				if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) {
4897 4897
 					$translation_texts[] = $labels['name'];
4898 4898
 				}
4899
-				if ( $labels['singular_name'] != '' && ! in_array( $labels['singular_name'], $translation_texts ) ) {
4899
+				if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) {
4900 4900
 					$translation_texts[] = $labels['singular_name'];
4901 4901
 				}
4902
-				if ( $labels['add_new'] != '' && ! in_array( $labels['add_new'], $translation_texts ) ) {
4902
+				if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) {
4903 4903
 					$translation_texts[] = $labels['add_new'];
4904 4904
 				}
4905
-				if ( $labels['add_new_item'] != '' && ! in_array( $labels['add_new_item'], $translation_texts ) ) {
4905
+				if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) {
4906 4906
 					$translation_texts[] = $labels['add_new_item'];
4907 4907
 				}
4908
-				if ( $labels['edit_item'] != '' && ! in_array( $labels['edit_item'], $translation_texts ) ) {
4908
+				if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) {
4909 4909
 					$translation_texts[] = $labels['edit_item'];
4910 4910
 				}
4911
-				if ( $labels['new_item'] != '' && ! in_array( $labels['new_item'], $translation_texts ) ) {
4911
+				if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) {
4912 4912
 					$translation_texts[] = $labels['new_item'];
4913 4913
 				}
4914
-				if ( $labels['view_item'] != '' && ! in_array( $labels['view_item'], $translation_texts ) ) {
4914
+				if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) {
4915 4915
 					$translation_texts[] = $labels['view_item'];
4916 4916
 				}
4917
-				if ( $labels['search_items'] != '' && ! in_array( $labels['search_items'], $translation_texts ) ) {
4917
+				if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) {
4918 4918
 					$translation_texts[] = $labels['search_items'];
4919 4919
 				}
4920
-				if ( $labels['not_found'] != '' && ! in_array( $labels['not_found'], $translation_texts ) ) {
4920
+				if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) {
4921 4921
 					$translation_texts[] = $labels['not_found'];
4922 4922
 				}
4923
-				if ( $labels['not_found_in_trash'] != '' && ! in_array( $labels['not_found_in_trash'], $translation_texts ) ) {
4923
+				if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) {
4924 4924
 					$translation_texts[] = $labels['not_found_in_trash'];
4925 4925
 				}
4926
-				if ( isset( $labels['label_post_profile'] ) && $labels['label_post_profile'] != '' && ! in_array( $labels['label_post_profile'], $translation_texts ) ) {
4926
+				if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) {
4927 4927
 					$translation_texts[] = $labels['label_post_profile'];
4928 4928
 				}
4929
-				if ( isset( $labels['label_post_info'] ) && $labels['label_post_info'] != '' && ! in_array( $labels['label_post_info'], $translation_texts ) ) {
4929
+				if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) {
4930 4930
 					$translation_texts[] = $labels['label_post_info'];
4931 4931
 				}
4932
-				if ( isset( $labels['label_post_images'] ) && $labels['label_post_images'] != '' && ! in_array( $labels['label_post_images'], $translation_texts ) ) {
4932
+				if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) {
4933 4933
 					$translation_texts[] = $labels['label_post_images'];
4934 4934
 				}
4935
-				if ( isset( $labels['label_post_map'] ) && $labels['label_post_map'] != '' && ! in_array( $labels['label_post_map'], $translation_texts ) ) {
4935
+				if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) {
4936 4936
 					$translation_texts[] = $labels['label_post_map'];
4937 4937
 				}
4938
-				if ( isset( $labels['label_reviews'] ) && $labels['label_reviews'] != '' && ! in_array( $labels['label_reviews'], $translation_texts ) ) {
4938
+				if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) {
4939 4939
 					$translation_texts[] = $labels['label_reviews'];
4940 4940
 				}
4941
-				if ( isset( $labels['label_related_listing'] ) && $labels['label_related_listing'] != '' && ! in_array( $labels['label_related_listing'], $translation_texts ) ) {
4941
+				if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) {
4942 4942
 					$translation_texts[] = $labels['label_related_listing'];
4943 4943
 				}
4944 4944
 			}
4945 4945
 
4946
-			if ( $description != '' && ! in_array( $description, $translation_texts ) ) {
4947
-				$translation_texts[] = normalize_whitespace( $description );
4946
+			if ($description != '' && !in_array($description, $translation_texts)) {
4947
+				$translation_texts[] = normalize_whitespace($description);
4948 4948
 			}
4949 4949
 
4950
-			if ( ! empty( $seo ) ) {
4951
-				if ( isset( $seo['meta_keyword'] ) && $seo['meta_keyword'] != '' && ! in_array( $seo['meta_keyword'], $translation_texts ) ) {
4952
-					$translation_texts[] = normalize_whitespace( $seo['meta_keyword'] );
4950
+			if (!empty($seo)) {
4951
+				if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) {
4952
+					$translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4953 4953
 				}
4954 4954
 
4955
-				if ( isset( $seo['meta_description'] ) && $seo['meta_description'] != '' && ! in_array( $seo['meta_description'], $translation_texts ) ) {
4956
-					$translation_texts[] = normalize_whitespace( $seo['meta_description'] );
4955
+				if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) {
4956
+					$translation_texts[] = normalize_whitespace($seo['meta_description']);
4957 4957
 				}
4958 4958
 			}
4959 4959
 		}
4960 4960
 	}
4961
-	$translation_texts = ! empty( $translation_texts ) ? array_unique( $translation_texts ) : $translation_texts;
4961
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4962 4962
 
4963 4963
 	return $translation_texts;
4964 4964
 }
@@ -4973,27 +4973,27 @@  discard block
 block discarded – undo
4973 4973
  *
4974 4974
  * @return array Location terms.
4975 4975
  */
4976
-function geodir_remove_location_terms( $location_terms = array() ) {
4977
-	$location_manager = defined( 'POST_LOCATION_TABLE' ) ? true : false;
4976
+function geodir_remove_location_terms($location_terms = array()) {
4977
+	$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4978 4978
 
4979
-	if ( ! empty( $location_terms ) && $location_manager ) {
4980
-		$hide_country_part = get_option( 'geodir_location_hide_country_part' );
4981
-		$hide_region_part  = get_option( 'geodir_location_hide_region_part' );
4979
+	if (!empty($location_terms) && $location_manager) {
4980
+		$hide_country_part = get_option('geodir_location_hide_country_part');
4981
+		$hide_region_part  = get_option('geodir_location_hide_region_part');
4982 4982
 
4983
-		if ( $hide_region_part && $hide_country_part ) {
4984
-			if ( isset( $location_terms['gd_country'] ) ) {
4985
-				unset( $location_terms['gd_country'] );
4983
+		if ($hide_region_part && $hide_country_part) {
4984
+			if (isset($location_terms['gd_country'])) {
4985
+				unset($location_terms['gd_country']);
4986 4986
 			}
4987
-			if ( isset( $location_terms['gd_region'] ) ) {
4988
-				unset( $location_terms['gd_region'] );
4987
+			if (isset($location_terms['gd_region'])) {
4988
+				unset($location_terms['gd_region']);
4989 4989
 			}
4990
-		} else if ( $hide_region_part && ! $hide_country_part ) {
4991
-			if ( isset( $location_terms['gd_region'] ) ) {
4992
-				unset( $location_terms['gd_region'] );
4990
+		} else if ($hide_region_part && !$hide_country_part) {
4991
+			if (isset($location_terms['gd_region'])) {
4992
+				unset($location_terms['gd_region']);
4993 4993
 			}
4994
-		} else if ( ! $hide_region_part && $hide_country_part ) {
4995
-			if ( isset( $location_terms['gd_country'] ) ) {
4996
-				unset( $location_terms['gd_country'] );
4994
+		} else if (!$hide_region_part && $hide_country_part) {
4995
+			if (isset($location_terms['gd_country'])) {
4996
+				unset($location_terms['gd_country']);
4997 4997
 			}
4998 4998
 		}
4999 4999
 	}
@@ -5004,7 +5004,7 @@  discard block
 block discarded – undo
5004 5004
 	 * @since 1.6.22
5005 5005
 	 * @param array $location_terms The array of location terms.
5006 5006
 	 */
5007
-	return apply_filters('geodir_remove_location_terms',$location_terms);
5007
+	return apply_filters('geodir_remove_location_terms', $location_terms);
5008 5008
 }
5009 5009
 
5010 5010
 /**
@@ -5021,32 +5021,32 @@  discard block
 block discarded – undo
5021 5021
  * @param WP_Post $post Post object.
5022 5022
  * @param bool $update  Whether this is an existing listing being updated or not.
5023 5023
  */
5024
-function geodir_on_wp_insert_post( $post_ID, $post, $update ) {
5024
+function geodir_on_wp_insert_post($post_ID, $post, $update) {
5025 5025
 	global $gd_set_listing_edited;
5026 5026
 	
5027
-	if ( ! $update ) {
5027
+	if (!$update) {
5028 5028
 		return;
5029 5029
 	}
5030 5030
 
5031
-	$action      = isset( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
5032
-	$is_admin    = is_admin() && ( ! defined( 'DOING_AJAX' ) || ( defined( 'DOING_AJAX' ) && ! DOING_AJAX ) ) ? true : false;
5031
+	$action      = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
5032
+	$is_admin    = is_admin() && (!defined('DOING_AJAX') || (defined('DOING_AJAX') && !DOING_AJAX)) ? true : false;
5033 5033
 	$inline_save = $action == 'inline-save' ? true : false;
5034 5034
 
5035
-	if ( empty( $post->post_type ) || $is_admin || $inline_save || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ) {
5035
+	if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
5036 5036
 		return;
5037 5037
 	}
5038 5038
 
5039
-	if ( $action != '' && in_array( $action, array( 'geodir_import_export' ) ) ) {
5039
+	if ($action != '' && in_array($action, array('geodir_import_export'))) {
5040 5040
 		return;
5041 5041
 	}
5042 5042
 
5043 5043
 	$user_id = (int) get_current_user_id();
5044 5044
 
5045
-	if ( $user_id > 0 && get_option( 'geodir_notify_post_edited' ) && ! wp_is_post_revision( $post_ID ) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
5046
-		$author_id = ! empty( $post->post_author ) ? $post->post_author : 0;
5045
+	if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
5046
+		$author_id = !empty($post->post_author) ? $post->post_author : 0;
5047 5047
 
5048
-		if ( $user_id == $author_id && ! is_super_admin() && empty( $gd_set_listing_edited[$post_ID] ) ) {
5049
-			if ( !empty( $gd_set_listing_edited ) ) {
5048
+		if ($user_id == $author_id && !is_super_admin() && empty($gd_set_listing_edited[$post_ID])) {
5049
+			if (!empty($gd_set_listing_edited)) {
5050 5050
 				$gd_set_listing_edited = array();
5051 5051
 			}
5052 5052
 			$gd_set_listing_edited[$post_ID] = true;
@@ -5064,14 +5064,14 @@  discard block
 block discarded – undo
5064 5064
  *
5065 5065
  * @return string|null The current page start & end numbering.
5066 5066
  */
5067
-function geodir_title_meta_page( $sep ) {
5067
+function geodir_title_meta_page($sep) {
5068 5068
 	$replacement = null;
5069 5069
 
5070
-	$max = geodir_title_meta_pagenumbering( 'max' );
5071
-	$nr  = geodir_title_meta_pagenumbering( 'nr' );
5070
+	$max = geodir_title_meta_pagenumbering('max');
5071
+	$nr  = geodir_title_meta_pagenumbering('nr');
5072 5072
 
5073
-	if ( $max > 1 && $nr > 1 ) {
5074
-		$replacement = sprintf( $sep . ' ' . __( 'Page %1$d of %2$d', 'geodirectory' ), $nr, $max );
5073
+	if ($max > 1 && $nr > 1) {
5074
+		$replacement = sprintf($sep.' '.__('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
5075 5075
 	}
5076 5076
 
5077 5077
 	return $replacement;
@@ -5088,8 +5088,8 @@  discard block
 block discarded – undo
5088 5088
 function geodir_title_meta_pagenumber() {
5089 5089
 	$replacement = null;
5090 5090
 
5091
-	$nr = geodir_title_meta_pagenumbering( 'nr' );
5092
-	if ( isset( $nr ) && $nr > 0 ) {
5091
+	$nr = geodir_title_meta_pagenumbering('nr');
5092
+	if (isset($nr) && $nr > 0) {
5093 5093
 		$replacement = (string) $nr;
5094 5094
 	}
5095 5095
 
@@ -5107,8 +5107,8 @@  discard block
 block discarded – undo
5107 5107
 function geodir_title_meta_pagetotal() {
5108 5108
 	$replacement = null;
5109 5109
 
5110
-	$max = geodir_title_meta_pagenumbering( 'max' );
5111
-	if ( isset( $max ) && $max > 0 ) {
5110
+	$max = geodir_title_meta_pagenumbering('max');
5111
+	if (isset($max) && $max > 0) {
5112 5112
 		$replacement = (string) $max;
5113 5113
 	}
5114 5114
 
@@ -5128,36 +5128,36 @@  discard block
 block discarded – undo
5128 5128
  *
5129 5129
  * @return int|null The current page numbering.
5130 5130
  */
5131
-function geodir_title_meta_pagenumbering( $request = 'nr' ) {
5131
+function geodir_title_meta_pagenumbering($request = 'nr') {
5132 5132
 	global $wp_query, $post;
5133 5133
 	$max_num_pages = null;
5134 5134
 	$page_number   = null;
5135 5135
 
5136 5136
 	$max_num_pages = 1;
5137 5137
 
5138
-	if ( ! is_singular() ) {
5139
-		$page_number = get_query_var( 'paged' );
5140
-		if ( $page_number === 0 || $page_number === '' ) {
5138
+	if (!is_singular()) {
5139
+		$page_number = get_query_var('paged');
5140
+		if ($page_number === 0 || $page_number === '') {
5141 5141
 			$page_number = 1;
5142 5142
 		}
5143 5143
 
5144
-		if ( isset( $wp_query->max_num_pages ) && ( $wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0 ) ) {
5144
+		if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
5145 5145
 			$max_num_pages = $wp_query->max_num_pages;
5146 5146
 		}
5147 5147
 	} else {
5148
-		$page_number = get_query_var( 'page' );
5149
-		if ( $page_number === 0 || $page_number === '' ) {
5148
+		$page_number = get_query_var('page');
5149
+		if ($page_number === 0 || $page_number === '') {
5150 5150
 			$page_number = 1;
5151 5151
 		}
5152 5152
 
5153
-		if ( isset( $post->post_content ) ) {
5154
-			$max_num_pages = ( substr_count( $post->post_content, '<!--nextpage-->' ) + 1 );
5153
+		if (isset($post->post_content)) {
5154
+			$max_num_pages = (substr_count($post->post_content, '<!--nextpage-->') + 1);
5155 5155
 		}
5156 5156
 	}
5157 5157
 
5158 5158
 	$return = null;
5159 5159
 
5160
-	switch ( $request ) {
5160
+	switch ($request) {
5161 5161
 		case 'nr':
5162 5162
 			$return = $page_number;
5163 5163
 			break;
@@ -5178,14 +5178,14 @@  discard block
 block discarded – undo
5178 5178
  *
5179 5179
  * @return array Terms.
5180 5180
  */
5181
-function geodir_filter_empty_terms( $terms ) {
5182
-	if ( empty( $terms ) ) {
5181
+function geodir_filter_empty_terms($terms) {
5182
+	if (empty($terms)) {
5183 5183
 		return $terms;
5184 5184
 	}
5185 5185
 
5186 5186
 	$return = array();
5187
-	foreach ( $terms as $term ) {
5188
-		if ( isset( $term->count ) && $term->count > 0 ) {
5187
+	foreach ($terms as $term) {
5188
+		if (isset($term->count) && $term->count > 0) {
5189 5189
 			$return[] = $term;
5190 5190
 		} else {
5191 5191
 			/**
@@ -5196,7 +5196,7 @@  discard block
 block discarded – undo
5196 5196
 			 * @param array $return The array of terms to return.
5197 5197
 			 * @param object $term  The term object.
5198 5198
 			 */
5199
-			$return = apply_filters( 'geodir_filter_empty_terms_filter', $return, $term );
5199
+			$return = apply_filters('geodir_filter_empty_terms_filter', $return, $term);
5200 5200
 		}
5201 5201
 	}
5202 5202
 
@@ -5213,15 +5213,15 @@  discard block
 block discarded – undo
5213 5213
  *
5214 5214
  * @return array
5215 5215
  */
5216
-function geodir_remove_hentry( $class ) {
5217
-	if ( geodir_is_page( 'detail' ) ) {
5218
-		$class = array_diff( $class, array( 'hentry' ) );
5216
+function geodir_remove_hentry($class) {
5217
+	if (geodir_is_page('detail')) {
5218
+		$class = array_diff($class, array('hentry'));
5219 5219
 	}
5220 5220
 
5221 5221
 	return $class;
5222 5222
 }
5223 5223
 
5224
-add_filter( 'post_class', 'geodir_remove_hentry' );
5224
+add_filter('post_class', 'geodir_remove_hentry');
5225 5225
 
5226 5226
 /**
5227 5227
  * Registers a individual text string for WPML translation.
@@ -5233,8 +5233,8 @@  discard block
 block discarded – undo
5233 5233
  * @param string $domain The plugin domain. Default geodirectory.
5234 5234
  * @param string $name The name of the string which helps to know what's being translated.
5235 5235
  */
5236
-function geodir_wpml_register_string( $string, $domain = 'geodirectory', $name = '' ) {
5237
-    do_action( 'wpml_register_single_string', $domain, $name, $string );
5236
+function geodir_wpml_register_string($string, $domain = 'geodirectory', $name = '') {
5237
+    do_action('wpml_register_single_string', $domain, $name, $string);
5238 5238
 }
5239 5239
 
5240 5240
 /**
@@ -5249,8 +5249,8 @@  discard block
 block discarded – undo
5249 5249
  * @param string $language_code Return the translation in this language. Default is NULL which returns the current language.
5250 5250
  * @return string The translated string.
5251 5251
  */
5252
-function geodir_wpml_translate_string( $string, $domain = 'geodirectory', $name = '', $language_code = NULL ) {
5253
-    return apply_filters( 'wpml_translate_single_string', $string, $domain, $name, $language_code );
5252
+function geodir_wpml_translate_string($string, $domain = 'geodirectory', $name = '', $language_code = NULL) {
5253
+    return apply_filters('wpml_translate_single_string', $string, $domain, $name, $language_code);
5254 5254
 }
5255 5255
 
5256 5256
 /**
@@ -5265,19 +5265,19 @@  discard block
 block discarded – undo
5265 5265
  * @param int $post_ID  Post ID.
5266 5266
  * @param array $data Post data.
5267 5267
  */
5268
-function geodir_send_listing_edited_notification( $post_ID, $data ) {
5268
+function geodir_send_listing_edited_notification($post_ID, $data) {
5269 5269
     global $gd_notified_edited, $gd_set_listing_edited;
5270 5270
     
5271
-    if ( !empty( $gd_set_listing_edited[ $post_ID ] ) && empty( $gd_notified_edited[ $post_ID ] ) ) {
5272
-        if ( !empty( $gd_notified_edited ) ) {
5271
+    if (!empty($gd_set_listing_edited[$post_ID]) && empty($gd_notified_edited[$post_ID])) {
5272
+        if (!empty($gd_notified_edited)) {
5273 5273
             $gd_notified_edited = array();
5274 5274
         }
5275
-        $gd_notified_edited[ $post_ID ] = true;
5275
+        $gd_notified_edited[$post_ID] = true;
5276 5276
         
5277
-        $from_email   = get_option( 'site_email' );
5277
+        $from_email   = get_option('site_email');
5278 5278
         $from_name    = get_site_emailName();
5279
-        $to_email     = get_option( 'admin_email' );
5280
-        $to_name      = get_option( 'name' );
5279
+        $to_email     = get_option('admin_email');
5280
+        $to_name      = get_option('name');
5281 5281
         $message_type = 'listing_edited';
5282 5282
 
5283 5283
         $notify_edited = true;
@@ -5289,11 +5289,11 @@  discard block
 block discarded – undo
5289 5289
          * @param bool $notify_edited Notify on listing edited by author?
5290 5290
          * @param object $post        The current post object.
5291 5291
          */
5292
-        $notify_edited = apply_filters( 'geodir_notify_on_listing_edited', $notify_edited, $post_ID );
5292
+        $notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post_ID);
5293 5293
 
5294
-        if ( $notify_edited ) {
5295
-            geodir_sendEmail( $from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID );
5294
+        if ($notify_edited) {
5295
+            geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
5296 5296
         }
5297 5297
     }
5298 5298
 }
5299
-add_action( 'geodir_after_save_listing', 'geodir_send_listing_edited_notification', 1000, 2 );
5300 5299
\ No newline at end of file
5300
+add_action('geodir_after_save_listing', 'geodir_send_listing_edited_notification', 1000, 2);
5301 5301
\ No newline at end of file
Please login to merge, or discard this patch.