Test Failed
Pull Request — master (#473)
by Kiran
12:54
created
geodirectory-functions/comments_functions.php 1 patch
Indentation   +471 added lines, -471 removed lines patch added patch discarded remove patch
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function geodir_comment_meta_row_action($a)
33 33
 {
34
-    global $comment;
34
+	global $comment;
35 35
 
36
-    $rating = geodir_get_commentoverall($comment->comment_ID);
37
-    if ($rating != 0) {
38
-        echo geodir_get_rating_stars($rating, $comment->comment_ID);
39
-    }
40
-    return $a;
36
+	$rating = geodir_get_commentoverall($comment->comment_ID);
37
+	if ($rating != 0) {
38
+		echo geodir_get_rating_stars($rating, $comment->comment_ID);
39
+	}
40
+	return $a;
41 41
 }
42 42
 
43 43
 add_action('add_meta_boxes_comment', 'geodir_comment_add_meta_box');
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
  */
53 53
 function geodir_comment_add_meta_box($comment)
54 54
 {
55
-    add_meta_box('gd-comment-rating', __('Comment Rating', 'geodirectory'), 'geodir_comment_rating_meta', 'comment', 'normal', 'high');
55
+	add_meta_box('gd-comment-rating', __('Comment Rating', 'geodirectory'), 'geodir_comment_rating_meta', 'comment', 'normal', 'high');
56 56
 }
57 57
 
58 58
 /**
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
  * @param object $comment The comment object.
67 67
  */
68 68
 function geodir_comment_rating_meta($comment) {
69
-    $post_type = get_post_type($comment->comment_post_ID);
69
+	$post_type = get_post_type($comment->comment_post_ID);
70 70
 	if (in_array($post_type, (array)geodir_get_posttypes()) && (int)$comment->comment_parent == 0 && !(!empty($post_type) && geodir_cpt_has_rating_disabled($post_type))) {
71 71
 		$rating = geodir_get_commentoverall($comment->comment_ID);
72 72
 		
@@ -106,24 +106,24 @@  discard block
 block discarded – undo
106 106
  * @global object $post The post object.
107 107
  */
108 108
 function geodir_comment_rating_fields() {
109
-    global $post;
109
+	global $post;
110 110
 
111
-    $post_types = geodir_get_posttypes();
111
+	$post_types = geodir_get_posttypes();
112 112
 
113
-    if (!empty($post->post_type) && in_array($post->post_type, $post_types) && !(!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type))) {
114
-        $star_texts = array();
115
-        $star_texts[] = __('Terrible', 'geodirectory');
116
-        $star_texts[] = __('Poor', 'geodirectory');
117
-        $star_texts[] = __('Average', 'geodirectory');
118
-        $star_texts[] = __('Very Good', 'geodirectory');
119
-        $star_texts[] = __('Excellent', 'geodirectory');
113
+	if (!empty($post->post_type) && in_array($post->post_type, $post_types) && !(!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type))) {
114
+		$star_texts = array();
115
+		$star_texts[] = __('Terrible', 'geodirectory');
116
+		$star_texts[] = __('Poor', 'geodirectory');
117
+		$star_texts[] = __('Average', 'geodirectory');
118
+		$star_texts[] = __('Very Good', 'geodirectory');
119
+		$star_texts[] = __('Excellent', 'geodirectory');
120 120
         
121
-        $gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts);
122
-        echo $gd_rating_html;
123
-        ?>
121
+		$gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts);
122
+		echo $gd_rating_html;
123
+		?>
124 124
         <input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="0"/>
125 125
         <?php
126
-    }
126
+	}
127 127
 }
128 128
 
129 129
 add_filter('comment_reply_link', 'geodir_comment_replaylink');
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 function geodir_comment_replaylink($link)
140 140
 {
141 141
 
142
-    if (strpos($link, 'wp-login.php?') !== false) {
143
-        $link = str_replace(wp_login_url(),geodir_login_url(),$link);
144
-    }
145
-    $link = '<div class="gd_comment_replaylink">' . $link . '</div>';
142
+	if (strpos($link, 'wp-login.php?') !== false) {
143
+		$link = str_replace(wp_login_url(),geodir_login_url(),$link);
144
+	}
145
+	$link = '<div class="gd_comment_replaylink">' . $link . '</div>';
146 146
 
147
-    return $link;
147
+	return $link;
148 148
 }
149 149
 
150 150
 add_filter('cancel_comment_reply_link', 'geodir_cancle_replaylink');
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 function geodir_cancle_replaylink($link)
160 160
 {
161 161
 
162
-    $link = '<span class="gd-cancel-replaylink">' . $link . '</span>';
162
+	$link = '<span class="gd-cancel-replaylink">' . $link . '</span>';
163 163
 
164
-    return $link;
164
+	return $link;
165 165
 }
166 166
 
167 167
 add_action('comment_post', 'geodir_save_rating');
@@ -177,32 +177,32 @@  discard block
 block discarded – undo
177 177
  */
178 178
 function geodir_save_rating($comment = 0)
179 179
 {
180
-    global $wpdb, $user_ID, $plugin_prefix;
180
+	global $wpdb, $user_ID, $plugin_prefix;
181 181
 
182
-    $comment_info = get_comment($comment);
182
+	$comment_info = get_comment($comment);
183 183
 
184
-    $post_id = $comment_info->comment_post_ID;
185
-    $status = $comment_info->comment_approved;
186
-    $rating_ip = geodir_get_ip();
184
+	$post_id = $comment_info->comment_post_ID;
185
+	$status = $comment_info->comment_approved;
186
+	$rating_ip = geodir_get_ip();
187 187
 	
188
-    $post = geodir_get_post_info($post_id);
189
-    if (empty($post)) {
190
-        return;
191
-    }
192
-
193
-    if ($post->post_status == 'publish') {
194
-        $post_status = '1';
195
-    } else {
196
-        $post_status = '0';
197
-    }
188
+	$post = geodir_get_post_info($post_id);
189
+	if (empty($post)) {
190
+		return;
191
+	}
192
+
193
+	if ($post->post_status == 'publish') {
194
+		$post_status = '1';
195
+	} else {
196
+		$post_status = '0';
197
+	}
198 198
 	
199
-    if (isset($_REQUEST['geodir_overallrating'])) {
200
-        $overall_rating = $_REQUEST['geodir_overallrating'];
199
+	if (isset($_REQUEST['geodir_overallrating'])) {
200
+		$overall_rating = $_REQUEST['geodir_overallrating'];
201 201
         
202 202
 		if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
203
-            $overall_rating = $overall_rating > 0 ? $overall_rating : '0';
203
+			$overall_rating = $overall_rating > 0 ? $overall_rating : '0';
204 204
 
205
-            $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
205
+			$sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
206 206
 					post_id		= %d,
207 207
 					post_type = %s,
208 208
 					post_title	= %s,
@@ -220,35 +220,35 @@  discard block
 block discarded – undo
220 220
 					post_latitude	= %s,
221 221
 					comment_content	= %s 
222 222
 					",
223
-                array($post_id, $post->post_type, $post->post_title, $user_ID, $comment, $rating_ip, $overall_rating, $status, $post_status, date_i18n('Y-m-d H:i:s', current_time('timestamp')), $post->post_city, $post->post_region, $post->post_country, $post->post_latitude, $post->post_longitude, $comment_info->comment_content)
224
-            );
225
-
226
-            $wpdb->query($sqlqry);
227
-
228
-            /**
229
-             * Called after saving the comment.
230
-             *
231
-             * @since 1.0.0
232
-             * @package GeoDirectory
233
-             * @param array $_REQUEST {
234
-             *    Attributes of the $_REQUEST variable.
235
-             *
236
-             *    @type string $geodir_overallrating Overall rating.
237
-             *    @type string $comment Comment text.
238
-             *    @type string $submit Submit button text.
239
-             *    @type string $comment_post_ID Comment post ID.
240
-             *    @type string $comment_parent Comment Parent ID.
241
-             *    @type string $_wp_unfiltered_html_comment Unfiltered html comment string.
242
-             *
243
-             * }
244
-             */
245
-            do_action('geodir_after_save_comment', $_REQUEST, 'Comment Your Post');
246
-
247
-            if ($status) {
248
-                geodir_update_postrating($post_id);
249
-            }
250
-        }
251
-    }
223
+				array($post_id, $post->post_type, $post->post_title, $user_ID, $comment, $rating_ip, $overall_rating, $status, $post_status, date_i18n('Y-m-d H:i:s', current_time('timestamp')), $post->post_city, $post->post_region, $post->post_country, $post->post_latitude, $post->post_longitude, $comment_info->comment_content)
224
+			);
225
+
226
+			$wpdb->query($sqlqry);
227
+
228
+			/**
229
+			 * Called after saving the comment.
230
+			 *
231
+			 * @since 1.0.0
232
+			 * @package GeoDirectory
233
+			 * @param array $_REQUEST {
234
+			 *    Attributes of the $_REQUEST variable.
235
+			 *
236
+			 *    @type string $geodir_overallrating Overall rating.
237
+			 *    @type string $comment Comment text.
238
+			 *    @type string $submit Submit button text.
239
+			 *    @type string $comment_post_ID Comment post ID.
240
+			 *    @type string $comment_parent Comment Parent ID.
241
+			 *    @type string $_wp_unfiltered_html_comment Unfiltered html comment string.
242
+			 *
243
+			 * }
244
+			 */
245
+			do_action('geodir_after_save_comment', $_REQUEST, 'Comment Your Post');
246
+
247
+			if ($status) {
248
+				geodir_update_postrating($post_id);
249
+			}
250
+		}
251
+	}
252 252
 }
253 253
 
254 254
 
@@ -266,51 +266,51 @@  discard block
 block discarded – undo
266 266
  */
267 267
 function geodir_update_rating_status_change($comment_id, $status)
268 268
 {
269
-    if ($status == 'delete') {
270
-        return;
271
-    }
272
-    global $wpdb, $plugin_prefix, $user_ID;
269
+	if ($status == 'delete') {
270
+		return;
271
+	}
272
+	global $wpdb, $plugin_prefix, $user_ID;
273 273
 
274
-    $comment_info = get_comment($comment_id);
274
+	$comment_info = get_comment($comment_id);
275 275
 
276
-    $post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : '';
276
+	$post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : '';
277 277
 
278
-    if (!empty($comment_info))
279
-        $status = $comment_info->comment_approved;
278
+	if (!empty($comment_info))
279
+		$status = $comment_info->comment_approved;
280 280
 
281
-    if ($status == 'approve' || $status == 1) {
282
-        $status = 1;
283
-    } else {
284
-        $status = 0;
285
-    }
281
+	if ($status == 'approve' || $status == 1) {
282
+		$status = 1;
283
+	} else {
284
+		$status = 0;
285
+	}
286 286
 
287
-    $comment_info_ID = isset($comment_info->comment_ID) ? $comment_info->comment_ID : '';
288
-    $old_rating = geodir_get_commentoverall($comment_info_ID);
287
+	$comment_info_ID = isset($comment_info->comment_ID) ? $comment_info->comment_ID : '';
288
+	$old_rating = geodir_get_commentoverall($comment_info_ID);
289 289
 
290
-    $post_type = get_post_type($post_id);
290
+	$post_type = get_post_type($post_id);
291 291
 
292
-    $detail_table = $plugin_prefix . $post_type . '_detail';
292
+	$detail_table = $plugin_prefix . $post_type . '_detail';
293 293
 
294
-    if ($comment_id) {
294
+	if ($comment_id) {
295 295
 
296
-        $overall_rating = $old_rating;
296
+		$overall_rating = $old_rating;
297 297
 
298
-        if (isset($old_rating)) {
298
+		if (isset($old_rating)) {
299 299
 
300
-            $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
300
+			$sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
301 301
 						overall_rating = %f,
302 302
 						status		= %s,
303 303
 						comment_content = %s 
304 304
 						WHERE comment_id = %d ", array($overall_rating, $status, $comment_info->comment_content, $comment_id));
305 305
 
306
-            $wpdb->query($sqlqry);
306
+			$wpdb->query($sqlqry);
307 307
 
308
-            //update rating
309
-            geodir_update_postrating($post_id, $post_type);
308
+			//update rating
309
+			geodir_update_postrating($post_id, $post_type);
310 310
 
311
-        }
311
+		}
312 312
 
313
-    }
313
+	}
314 314
 
315 315
 }
316 316
 
@@ -329,41 +329,41 @@  discard block
 block discarded – undo
329 329
 function geodir_update_rating($comment_id = 0)
330 330
 {
331 331
 
332
-    global $wpdb, $plugin_prefix, $user_ID;
332
+	global $wpdb, $plugin_prefix, $user_ID;
333 333
 
334
-    $comment_info = get_comment($comment_id);
334
+	$comment_info = get_comment($comment_id);
335 335
 
336
-    $post_id = $comment_info->comment_post_ID;
337
-    $status = $comment_info->comment_approved;
338
-    $old_rating = geodir_get_commentoverall($comment_info->comment_ID);
336
+	$post_id = $comment_info->comment_post_ID;
337
+	$status = $comment_info->comment_approved;
338
+	$old_rating = geodir_get_commentoverall($comment_info->comment_ID);
339 339
 
340
-    $post_type = get_post_type($post_id);
340
+	$post_type = get_post_type($post_id);
341 341
 
342
-    $detail_table = $plugin_prefix . $post_type . '_detail';
342
+	$detail_table = $plugin_prefix . $post_type . '_detail';
343 343
 
344
-    if (isset($_REQUEST['geodir_overallrating'])) {
344
+	if (isset($_REQUEST['geodir_overallrating'])) {
345 345
 
346
-        $overall_rating = $_REQUEST['geodir_overallrating'];
346
+		$overall_rating = $_REQUEST['geodir_overallrating'];
347 347
 
348
-        if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
349
-            $overall_rating = $overall_rating > 0 ? $overall_rating : '0';
348
+		if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
349
+			$overall_rating = $overall_rating > 0 ? $overall_rating : '0';
350 350
 
351
-            if (isset($old_rating)) {
351
+			if (isset($old_rating)) {
352 352
 
353
-                $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
353
+				$sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
354 354
 						overall_rating = %f,
355 355
 						status		= %s,
356 356
 						comment_content	= %s 
357 357
 						WHERE comment_id = %d ", array($overall_rating, $status, $comment_info->comment_content, $comment_id));
358 358
 
359
-                $wpdb->query($sqlqry);
359
+				$wpdb->query($sqlqry);
360 360
 
361
-                //update rating
362
-                geodir_update_postrating($post_id, $post_type);
361
+				//update rating
362
+				geodir_update_postrating($post_id, $post_type);
363 363
 
364
-            }
365
-        }
366
-    }
364
+			}
365
+		}
366
+	}
367 367
 
368 368
 
369 369
 }
@@ -379,19 +379,19 @@  discard block
 block discarded – undo
379 379
  */
380 380
 function geodir_comment_delete_comment($comment_id)
381 381
 {
382
-    global $wpdb;
382
+	global $wpdb;
383 383
 
384
-    $review_info = geodir_get_review($comment_id);
385
-    if ($review_info) {
386
-        geodir_update_postrating($review_info->post_id);
387
-    }
384
+	$review_info = geodir_get_review($comment_id);
385
+	if ($review_info) {
386
+		geodir_update_postrating($review_info->post_id);
387
+	}
388 388
 
389
-    $wpdb->query(
390
-        $wpdb->prepare(
391
-            "DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d",
392
-            array($comment_id)
393
-        )
394
-    );
389
+	$wpdb->query(
390
+		$wpdb->prepare(
391
+			"DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d",
392
+			array($comment_id)
393
+		)
394
+	);
395 395
 
396 396
 }
397 397
 
@@ -407,21 +407,21 @@  discard block
 block discarded – undo
407 407
  * @return string The comment content.
408 408
  */
409 409
 function geodir_wrap_comment_text($content, $comment = '') {
410
-    if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) {
411
-        if (!is_admin()) {
412
-            return '<div class="description">' . $content . '</div>';
413
-        } else {
414
-            return $content;
415
-        }
416
-    } else {
417
-        $rating = 0;
418
-        if (!empty($comment))
419
-            $rating = geodir_get_commentoverall($comment->comment_ID);
420
-        if ($rating != 0 && !is_admin()) {
421
-            return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
422
-        } else
423
-            return $content;
424
-    }
410
+	if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) {
411
+		if (!is_admin()) {
412
+			return '<div class="description">' . $content . '</div>';
413
+		} else {
414
+			return $content;
415
+		}
416
+	} else {
417
+		$rating = 0;
418
+		if (!empty($comment))
419
+			$rating = geodir_get_commentoverall($comment->comment_ID);
420
+		if ($rating != 0 && !is_admin()) {
421
+			return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
422
+		} else
423
+			return $content;
424
+	}
425 425
 }
426 426
 
427 427
 
@@ -438,41 +438,41 @@  discard block
 block discarded – undo
438 438
  */
439 439
 function geodir_update_postrating($post_id = 0, $post_type = '', $delete = false)
440 440
 {
441
-    global $wpdb, $plugin_prefix, $comment;
442
-    if (!$post_type) {
443
-        $post_type = get_post_type($post_id);
444
-    }
445
-    $detail_table = $plugin_prefix . $post_type . '_detail';
446
-    $post_newrating = geodir_get_post_rating($post_id, 1);
447
-    $post_newrating_count = geodir_get_review_count_total($post_id);
441
+	global $wpdb, $plugin_prefix, $comment;
442
+	if (!$post_type) {
443
+		$post_type = get_post_type($post_id);
444
+	}
445
+	$detail_table = $plugin_prefix . $post_type . '_detail';
446
+	$post_newrating = geodir_get_post_rating($post_id, 1);
447
+	$post_newrating_count = geodir_get_review_count_total($post_id);
448 448
 
449 449
 
450
-    //$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ;
450
+	//$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ;
451 451
 
452
-    if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
452
+	if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
453 453
 
454
-        $wpdb->query(
455
-            $wpdb->prepare(
456
-                "UPDATE " . $detail_table . " SET
454
+		$wpdb->query(
455
+			$wpdb->prepare(
456
+				"UPDATE " . $detail_table . " SET
457 457
 						overall_rating = %f,
458 458
 						rating_count = %f
459 459
 						where post_id = %d",
460
-                array($post_newrating, $post_newrating_count, $post_id)
461
-            )
462
-        );
463
-
464
-        update_post_meta($post_id, 'overall_rating', $post_newrating);
465
-        update_post_meta($post_id, 'rating_count', $post_newrating_count);
466
-    }
467
-    /**
468
-     * Called after Updating post overall rating and rating count.
469
-     *
470
-     * @since 1.0.0
471
-     * @since 1.4.3 Added `$post_id` param.
472
-     * @package GeoDirectory
473
-     * @param int $post_id The post ID.
474
-     */
475
-    do_action('geodir_update_postrating',$post_id);
460
+				array($post_newrating, $post_newrating_count, $post_id)
461
+			)
462
+		);
463
+
464
+		update_post_meta($post_id, 'overall_rating', $post_newrating);
465
+		update_post_meta($post_id, 'rating_count', $post_newrating_count);
466
+	}
467
+	/**
468
+	 * Called after Updating post overall rating and rating count.
469
+	 *
470
+	 * @since 1.0.0
471
+	 * @since 1.4.3 Added `$post_id` param.
472
+	 * @package GeoDirectory
473
+	 * @param int $post_id The post ID.
474
+	 */
475
+	do_action('geodir_update_postrating',$post_id);
476 476
 
477 477
 }
478 478
 
@@ -490,29 +490,29 @@  discard block
 block discarded – undo
490 490
  */
491 491
 function geodir_get_postoverall($post_id = 0)
492 492
 {
493
-    global $wpdb, $plugin_prefix;
493
+	global $wpdb, $plugin_prefix;
494 494
 
495
-    $post_type = get_post_type($post_id);
496
-    $detail_table = $plugin_prefix . $post_type . '_detail';
495
+	$post_type = get_post_type($post_id);
496
+	$detail_table = $plugin_prefix . $post_type . '_detail';
497 497
 
498
-    if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
498
+	if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
499 499
 
500
-        $post_ratings = $wpdb->get_var(
501
-            $wpdb->prepare(
502
-                "SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d",
503
-                array($post_id)
504
-            )
505
-        );
500
+		$post_ratings = $wpdb->get_var(
501
+			$wpdb->prepare(
502
+				"SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d",
503
+				array($post_id)
504
+			)
505
+		);
506 506
 
507 507
 
508
-    } else {
509
-        $post_ratings = get_post_meta($post_id, 'overall_rating');
510
-    }
508
+	} else {
509
+		$post_ratings = get_post_meta($post_id, 'overall_rating');
510
+	}
511 511
 
512
-    if ($post_ratings)
513
-        return $post_ratings;
514
-    else
515
-        return false;
512
+	if ($post_ratings)
513
+		return $post_ratings;
514
+	else
515
+		return false;
516 516
 }
517 517
 
518 518
 
@@ -529,19 +529,19 @@  discard block
 block discarded – undo
529 529
  */
530 530
 function geodir_get_review($comment_id = 0)
531 531
 {
532
-    global $wpdb;
533
-
534
-    $reatings = $wpdb->get_row(
535
-        $wpdb->prepare(
536
-            "SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
537
-            array($comment_id)
538
-        )
539
-    );
540
-
541
-    if (!empty($reatings))
542
-        return $reatings;
543
-    else
544
-        return false;
532
+	global $wpdb;
533
+
534
+	$reatings = $wpdb->get_row(
535
+		$wpdb->prepare(
536
+			"SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
537
+			array($comment_id)
538
+		)
539
+	);
540
+
541
+	if (!empty($reatings))
542
+		return $reatings;
543
+	else
544
+		return false;
545 545
 }
546 546
 
547 547
 /**
@@ -557,19 +557,19 @@  discard block
 block discarded – undo
557 557
  */
558 558
 function geodir_get_review_total($post_id = 0)
559 559
 {
560
-    global $wpdb;
561
-
562
-    $results = $wpdb->get_var(
563
-        $wpdb->prepare(
564
-            "SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
565
-            array($post_id)
566
-        )
567
-    );
568
-
569
-    if (!empty($results))
570
-        return $results;
571
-    else
572
-        return false;
560
+	global $wpdb;
561
+
562
+	$results = $wpdb->get_var(
563
+		$wpdb->prepare(
564
+			"SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
565
+			array($post_id)
566
+		)
567
+	);
568
+
569
+	if (!empty($results))
570
+		return $results;
571
+	else
572
+		return false;
573 573
 }
574 574
 
575 575
 /**
@@ -585,18 +585,18 @@  discard block
 block discarded – undo
585 585
  */
586 586
 function geodir_get_review_count_by_user_id($user_id = 0)
587 587
 {
588
-    global $wpdb;
589
-    $results = $wpdb->get_var(
590
-        $wpdb->prepare(
591
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0",
592
-            array($user_id)
593
-        )
594
-    );
595
-
596
-    if (!empty($results))
597
-        return $results;
598
-    else
599
-        return false;
588
+	global $wpdb;
589
+	$results = $wpdb->get_var(
590
+		$wpdb->prepare(
591
+			"SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0",
592
+			array($user_id)
593
+		)
594
+	);
595
+
596
+	if (!empty($results))
597
+		return $results;
598
+	else
599
+		return false;
600 600
 }
601 601
 
602 602
 /**
@@ -614,27 +614,27 @@  discard block
 block discarded – undo
614 614
  */
615 615
 function geodir_get_post_rating($post_id = 0, $force_query = 0)
616 616
 {
617
-    global $wpdb, $post;
618
-
619
-    if (isset($post->ID) && $post->ID == $post_id && !$force_query) {
620
-        if (isset($post->rating_count) && $post->rating_count > 0 && isset($post->overall_rating) && $post->overall_rating > 0) {
621
-            return $post->overall_rating;
622
-        } else {
623
-            return 0;
624
-        }
625
-    }
626
-
627
-    $results = $wpdb->get_var(
628
-        $wpdb->prepare(
629
-            "SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
630
-            array($post_id)
631
-        )
632
-    );
633
-
634
-    if (!empty($results))
635
-        return $results;
636
-    else
637
-        return false;
617
+	global $wpdb, $post;
618
+
619
+	if (isset($post->ID) && $post->ID == $post_id && !$force_query) {
620
+		if (isset($post->rating_count) && $post->rating_count > 0 && isset($post->overall_rating) && $post->overall_rating > 0) {
621
+			return $post->overall_rating;
622
+		} else {
623
+			return 0;
624
+		}
625
+	}
626
+
627
+	$results = $wpdb->get_var(
628
+		$wpdb->prepare(
629
+			"SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
630
+			array($post_id)
631
+		)
632
+	);
633
+
634
+	if (!empty($results))
635
+		return $results;
636
+	else
637
+		return false;
638 638
 }
639 639
 
640 640
 /**
@@ -650,19 +650,19 @@  discard block
 block discarded – undo
650 650
  */
651 651
 function geodir_get_review_count_total($post_id = 0)
652 652
 {
653
-    global $wpdb;
654
-
655
-    $results = $wpdb->get_var(
656
-        $wpdb->prepare(
657
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
658
-            array($post_id)
659
-        )
660
-    );
661
-
662
-    if (!empty($results))
663
-        return $results;
664
-    else
665
-        return false;
653
+	global $wpdb;
654
+
655
+	$results = $wpdb->get_var(
656
+		$wpdb->prepare(
657
+			"SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
658
+			array($post_id)
659
+		)
660
+	);
661
+
662
+	if (!empty($results))
663
+		return $results;
664
+	else
665
+		return false;
666 666
 }
667 667
 
668 668
 /**
@@ -679,20 +679,20 @@  discard block
 block discarded – undo
679 679
  */
680 680
 function geodir_get_comments_number($post_id = 0)
681 681
 {
682
-    global $wpdb;
682
+	global $wpdb;
683 683
 
684
-    $results = $wpdb->get_var(
685
-        $wpdb->prepare(
686
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
687
-            array($post_id)
688
-        )
689
-    );
684
+	$results = $wpdb->get_var(
685
+		$wpdb->prepare(
686
+			"SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
687
+			array($post_id)
688
+		)
689
+	);
690 690
 
691 691
 
692
-    if (!empty($results))
693
-        return $results;
694
-    else
695
-        return false;
692
+	if (!empty($results))
693
+		return $results;
694
+	else
695
+		return false;
696 696
 }
697 697
 
698 698
 /**
@@ -708,19 +708,19 @@  discard block
 block discarded – undo
708 708
  */
709 709
 function geodir_get_commentoverall($comment_id = 0)
710 710
 {
711
-    global $wpdb;
712
-
713
-    $reatings = $wpdb->get_var(
714
-        $wpdb->prepare(
715
-            "SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
716
-            array($comment_id)
717
-        )
718
-    );
719
-
720
-    if ($reatings)
721
-        return $reatings;
722
-    else
723
-        return false;
711
+	global $wpdb;
712
+
713
+	$reatings = $wpdb->get_var(
714
+		$wpdb->prepare(
715
+			"SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
716
+			array($comment_id)
717
+		)
718
+	);
719
+
720
+	if ($reatings)
721
+		return $reatings;
722
+	else
723
+		return false;
724 724
 }
725 725
 
726 726
 /**
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
  */
735 735
 function geodir_get_commentoverall_number($post_id = 0)
736 736
 {
737
-    return geodir_get_post_rating($post_id);
737
+	return geodir_get_post_rating($post_id);
738 738
 }
739 739
 
740 740
 
@@ -752,102 +752,102 @@  discard block
 block discarded – undo
752 752
  */
753 753
 function geodir_comment_template($comment_template)
754 754
 {
755
-    global $post;
755
+	global $post;
756 756
 
757
-    $post_types = geodir_get_posttypes();
757
+	$post_types = geodir_get_posttypes();
758 758
 
759
-    if (!(is_singular() && (have_comments() || (isset($post->comment_status) && 'open' == $post->comment_status)))) {
760
-        return;
761
-    }
762
-    if (in_array($post->post_type, $post_types)) { // assuming there is a post type called business
763
-        if (geodir_cpt_has_rating_disabled($post->post_type)) {
764
-            return $comment_template;
765
-        }
759
+	if (!(is_singular() && (have_comments() || (isset($post->comment_status) && 'open' == $post->comment_status)))) {
760
+		return;
761
+	}
762
+	if (in_array($post->post_type, $post_types)) { // assuming there is a post type called business
763
+		if (geodir_cpt_has_rating_disabled($post->post_type)) {
764
+			return $comment_template;
765
+		}
766 766
         
767
-        $template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available
768
-        if (!$template) {
769
-            $template = dirname(__FILE__) . '/reviews.php';
770
-        }
771
-        return $template;
772
-    }
767
+		$template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available
768
+		if (!$template) {
769
+			$template = dirname(__FILE__) . '/reviews.php';
770
+		}
771
+		return $template;
772
+	}
773 773
 }
774 774
 
775 775
 add_filter("comments_template", "geodir_comment_template");
776 776
 
777 777
 
778 778
 if (!function_exists('geodir_comment')) {
779
-    /**
780
-     * Comment HTML markup.
781
-     *
782
-     * @since 1.0.0
783
-     * @package GeoDirectory
784
-     * @global object $post The current post object.
785
-     * @param object $comment The comment object.
786
-     * @param string|array $args {
787
-     *     Optional. Formatting options.
788
-     *
789
-     *     @type object $walker            Instance of a Walker class to list comments. Default null.
790
-     *     @type int    $max_depth         The maximum comments depth. Default empty.
791
-     *     @type string $style             The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
792
-     *     @type string $callback          Callback function to use. Default null.
793
-     *     @type string $end-callback      Callback function to use at the end. Default null.
794
-     *     @type string $type              Type of comments to list.
795
-     *                                     Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
796
-     *     @type int    $page              Page ID to list comments for. Default empty.
797
-     *     @type int    $per_page          Number of comments to list per page. Default empty.
798
-     *     @type int    $avatar_size       Height and width dimensions of the avatar size. Default 32.
799
-     *     @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
800
-     *     @type bool   $reverse_children  Whether to reverse child comments in the list. Default null.
801
-     *     @type string $format            How to format the comments list.
802
-     *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
803
-     *     @type bool   $short_ping        Whether to output short pings. Default false.
804
-     *     @type bool   $echo              Whether to echo the output or return it. Default true.
805
-     * }
806
-     * @param int $depth Depth of comment.
807
-     */
808
-    function geodir_comment($comment, $args, $depth)
809
-    {
810
-        $GLOBALS['comment'] = $comment;
811
-        switch ($comment->comment_type) :
812
-            case 'pingback' :
813
-            case 'trackback' :
814
-                // Display trackbacks differently than normal comments.
815
-                ?>
779
+	/**
780
+	 * Comment HTML markup.
781
+	 *
782
+	 * @since 1.0.0
783
+	 * @package GeoDirectory
784
+	 * @global object $post The current post object.
785
+	 * @param object $comment The comment object.
786
+	 * @param string|array $args {
787
+	 *     Optional. Formatting options.
788
+	 *
789
+	 *     @type object $walker            Instance of a Walker class to list comments. Default null.
790
+	 *     @type int    $max_depth         The maximum comments depth. Default empty.
791
+	 *     @type string $style             The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
792
+	 *     @type string $callback          Callback function to use. Default null.
793
+	 *     @type string $end-callback      Callback function to use at the end. Default null.
794
+	 *     @type string $type              Type of comments to list.
795
+	 *                                     Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
796
+	 *     @type int    $page              Page ID to list comments for. Default empty.
797
+	 *     @type int    $per_page          Number of comments to list per page. Default empty.
798
+	 *     @type int    $avatar_size       Height and width dimensions of the avatar size. Default 32.
799
+	 *     @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
800
+	 *     @type bool   $reverse_children  Whether to reverse child comments in the list. Default null.
801
+	 *     @type string $format            How to format the comments list.
802
+	 *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
803
+	 *     @type bool   $short_ping        Whether to output short pings. Default false.
804
+	 *     @type bool   $echo              Whether to echo the output or return it. Default true.
805
+	 * }
806
+	 * @param int $depth Depth of comment.
807
+	 */
808
+	function geodir_comment($comment, $args, $depth)
809
+	{
810
+		$GLOBALS['comment'] = $comment;
811
+		switch ($comment->comment_type) :
812
+			case 'pingback' :
813
+			case 'trackback' :
814
+				// Display trackbacks differently than normal comments.
815
+				?>
816 816
                 <li <?php comment_class('geodir-comment'); ?> id="comment-<?php comment_ID(); ?>">
817 817
                 <p><?php _e('Pingback:', 'geodirectory'); ?> <?php comment_author_link(); ?> <?php edit_comment_link(__('(Edit)', 'geodirectory'), '<span class="edit-link">', '</span>'); ?></p>
818 818
                 <?php
819
-                break;
820
-            default :
821
-                // Proceed with normal comments.
822
-                global $post;
823
-                ?>
819
+				break;
820
+			default :
821
+				// Proceed with normal comments.
822
+				global $post;
823
+				?>
824 824
             <li <?php comment_class('geodir-comment'); ?> id="li-comment-<?php comment_ID(); ?>">
825 825
                 <article id="comment-<?php comment_ID(); ?>" class="comment">
826 826
                     <header class="comment-meta comment-author vcard">
827 827
                         <?php
828
-                        /**
829
-                         * Filter to modify comment avatar size
830
-                         *
831
-                         * You can use this filter to change comment avatar size.
832
-                         *
833
-                         * @since 1.0.0
834
-                         * @package GeoDirectory
835
-                         */
836
-                        $avatar_size = apply_filters('geodir_comment_avatar_size', 44);
837
-                        echo get_avatar($comment, $avatar_size);
838
-                        printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>',
839
-                            get_comment_author_link(),
840
-                            // If current post author is also comment author, make it known visually.
841
-                            ($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : ''
842
-                        );
843
-                        echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>";
844
-                        printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>',
845
-                            esc_url(get_comment_link($comment->comment_ID)),
846
-                            get_comment_time('c'),
847
-                            /* translators: 1: date, 2: time */
848
-                            sprintf(__('%1$s at %2$s', 'geodirectory'), get_comment_date(), get_comment_time())
849
-                        );
850
-                        ?>
828
+						/**
829
+						 * Filter to modify comment avatar size
830
+						 *
831
+						 * You can use this filter to change comment avatar size.
832
+						 *
833
+						 * @since 1.0.0
834
+						 * @package GeoDirectory
835
+						 */
836
+						$avatar_size = apply_filters('geodir_comment_avatar_size', 44);
837
+						echo get_avatar($comment, $avatar_size);
838
+						printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>',
839
+							get_comment_author_link(),
840
+							// If current post author is also comment author, make it known visually.
841
+							($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : ''
842
+						);
843
+						echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>";
844
+						printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>',
845
+							esc_url(get_comment_link($comment->comment_ID)),
846
+							get_comment_time('c'),
847
+							/* translators: 1: date, 2: time */
848
+							sprintf(__('%1$s at %2$s', 'geodirectory'), get_comment_date(), get_comment_time())
849
+						);
850
+						?>
851 851
                     </header>
852 852
                     <!-- .comment-meta -->
853 853
 
@@ -871,47 +871,47 @@  discard block
 block discarded – undo
871 871
                 </article>
872 872
                 <!-- #comment-## -->
873 873
                 <?php
874
-                break;
875
-        endswitch; // end comment_type check
876
-    }
874
+				break;
875
+		endswitch; // end comment_type check
876
+	}
877 877
 }
878 878
 
879 879
 
880 880
 add_filter('get_comments_number', 'geodir_fix_comment_count', 10, 2);
881 881
 if (!function_exists('geodir_fix_comment_count')) {
882
-    /**
883
-     * Fix comment count by not listing replies as reviews
884
-     *
885
-     * @since 1.0.0
886
-     * @package GeoDirectory
887
-     * @global object $post The current post object.
888
-     * @param int $count The comment count.
889
-     * @param int $post_id The post ID.
890
-     * @todo $post is unreachable since the function return the count before that variable.
891
-     * @return bool|null|string The comment count.
892
-     */
893
-    function geodir_fix_comment_count($count, $post_id)
894
-    {
895
-        if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) {
896
-            global $post;
897
-            $post_types = geodir_get_posttypes();
898
-
899
-            if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) {
900
-                $review_count = geodir_get_review_count_total($post_id);
901
-                return $review_count;
902
-
903
-                if ($post && isset($post->rating_count)) {
904
-                    return $post->rating_count;
905
-                } else {
906
-                    return geodir_get_comments_number($post_id);
907
-                }
908
-            } else {
909
-                return $count;
910
-            }
911
-        } else {
912
-            return $count;
913
-        }
914
-    }
882
+	/**
883
+	 * Fix comment count by not listing replies as reviews
884
+	 *
885
+	 * @since 1.0.0
886
+	 * @package GeoDirectory
887
+	 * @global object $post The current post object.
888
+	 * @param int $count The comment count.
889
+	 * @param int $post_id The post ID.
890
+	 * @todo $post is unreachable since the function return the count before that variable.
891
+	 * @return bool|null|string The comment count.
892
+	 */
893
+	function geodir_fix_comment_count($count, $post_id)
894
+	{
895
+		if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) {
896
+			global $post;
897
+			$post_types = geodir_get_posttypes();
898
+
899
+			if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) {
900
+				$review_count = geodir_get_review_count_total($post_id);
901
+				return $review_count;
902
+
903
+				if ($post && isset($post->rating_count)) {
904
+					return $post->rating_count;
905
+				} else {
906
+					return geodir_get_comments_number($post_id);
907
+				}
908
+			} else {
909
+				return $count;
910
+			}
911
+		} else {
912
+			return $count;
913
+		}
914
+	}
915 915
 }
916 916
 
917 917
 /**
@@ -929,14 +929,14 @@  discard block
 block discarded – undo
929 929
  */
930 930
 function geodir_get_rating_stars($rating, $post_id, $small = false)
931 931
 {
932
-    if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) {
933
-        return NULL;
934
-    }
935
-    $a_rating = $rating / 5 * 100;
936
-
937
-    if ($small) {
938
-        $r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>';
939
-    } else {
932
+	if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) {
933
+		return NULL;
934
+	}
935
+	$a_rating = $rating / 5 * 100;
936
+
937
+	if ($small) {
938
+		$r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>';
939
+	} else {
940 940
 		if (function_exists('geodir_reviewrating_draw_overall_rating')) {
941 941
 			// Show rating stars from review rating manager
942 942
 			$r_html = geodir_reviewrating_draw_overall_rating($rating);
@@ -953,8 +953,8 @@  discard block
 block discarded – undo
953 953
 			}
954 954
 			$r_html = '<div class="geodir-rating" style="' . $attach_style . '"><div class="gd_rating_show" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingAverage" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star">' . $rating_img . $rating_img . $rating_img . $rating_img . $rating_img . '</div></div></div>';
955 955
 		}
956
-    }
957
-    return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
956
+	}
957
+	return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
958 958
 }
959 959
 
960 960
 /**
@@ -968,23 +968,23 @@  discard block
 block discarded – undo
968 968
 function geodir_is_reviews_show($pageview = '')
969 969
 {
970 970
 
971
-    $active_tabs = get_option('geodir_detail_page_tabs_excluded');
972
-
973
-    $is_display = true;
974
-    if (!empty($active_tabs) && in_array('reviews', $active_tabs))
975
-        $is_display = false;
976
-
977
-    /**
978
-     * Filter to change display value.
979
-     *
980
-     * You can use this filter to change the is_display value.
981
-     *
982
-     * @since 1.0.0
983
-     * @package GeoDirectory
984
-     * @param bool $is_display Display ratings when set to true.
985
-     * @param string $pageview The view template. Ex: listview, gridview etc.
986
-     */
987
-    return apply_filters('geodir_is_reviews_show', $is_display, $pageview);
971
+	$active_tabs = get_option('geodir_detail_page_tabs_excluded');
972
+
973
+	$is_display = true;
974
+	if (!empty($active_tabs) && in_array('reviews', $active_tabs))
975
+		$is_display = false;
976
+
977
+	/**
978
+	 * Filter to change display value.
979
+	 *
980
+	 * You can use this filter to change the is_display value.
981
+	 *
982
+	 * @since 1.0.0
983
+	 * @package GeoDirectory
984
+	 * @param bool $is_display Display ratings when set to true.
985
+	 * @param string $pageview The view template. Ex: listview, gridview etc.
986
+	 */
987
+	return apply_filters('geodir_is_reviews_show', $is_display, $pageview);
988 988
 }
989 989
 
990 990
 
@@ -992,9 +992,9 @@  discard block
 block discarded – undo
992 992
  * If Disqus plugin is active, do some fixes to show on blogs but no on GD post types
993 993
  */
994 994
 if(function_exists('dsq_can_replace')) {
995
-    remove_filter('comments_template', 'dsq_comments_template');
996
-    add_filter('comments_template', 'dsq_comments_template', 100);
997
-    add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
995
+	remove_filter('comments_template', 'dsq_comments_template');
996
+	add_filter('comments_template', 'dsq_comments_template', 100);
997
+	add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
998 998
 }
999 999
 
1000 1000
 
@@ -1008,14 +1008,14 @@  discard block
 block discarded – undo
1008 1008
  * @return string `1` if active `0` if disabled.
1009 1009
  */
1010 1010
 function geodir_option_disqus_active($disqus_active){
1011
-    global $post;
1012
-    $all_postypes = geodir_get_posttypes();
1011
+	global $post;
1012
+	$all_postypes = geodir_get_posttypes();
1013 1013
 
1014
-    if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
1015
-        $disqus_active = '0';
1016
-    }
1014
+	if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
1015
+		$disqus_active = '0';
1016
+	}
1017 1017
 
1018
-    return $disqus_active;
1018
+	return $disqus_active;
1019 1019
 }
1020 1020
 
1021 1021
 /**
@@ -1029,23 +1029,23 @@  discard block
 block discarded – undo
1029 1029
  * @return array Modified tabs array.
1030 1030
  */
1031 1031
 function geodir_detail_reviews_tab_title($tabs_arr) {
1032
-    $post_type = geodir_get_current_posttype();
1032
+	$post_type = geodir_get_current_posttype();
1033 1033
 
1034
-    if (!empty($tabs_arr) && !empty($tabs_arr['reviews']) && isset($tabs_arr['reviews']['heading_text']) && $post_type != '' && geodir_cpt_has_rating_disabled($post_type)) {
1035
-        $label_reviews = __('Comments', 'geodirectory');
1034
+	if (!empty($tabs_arr) && !empty($tabs_arr['reviews']) && isset($tabs_arr['reviews']['heading_text']) && $post_type != '' && geodir_cpt_has_rating_disabled($post_type)) {
1035
+		$label_reviews = __('Comments', 'geodirectory');
1036 1036
         
1037
-        if (defined('GEODIR_CP_VERSION')) {
1038
-            $post_types = geodir_get_posttypes('array');
1037
+		if (defined('GEODIR_CP_VERSION')) {
1038
+			$post_types = geodir_get_posttypes('array');
1039 1039
             
1040
-            if (!empty($post_types[$post_type]['labels']['label_reviews'])) {
1041
-                $label_reviews = stripslashes(__($post_types[$post_type]['labels']['label_reviews'], 'geodirectory'));
1042
-            }
1043
-        }
1040
+			if (!empty($post_types[$post_type]['labels']['label_reviews'])) {
1041
+				$label_reviews = stripslashes(__($post_types[$post_type]['labels']['label_reviews'], 'geodirectory'));
1042
+			}
1043
+		}
1044 1044
         
1045
-        $tabs_arr['reviews']['heading_text'] = $label_reviews;
1046
-    }
1045
+		$tabs_arr['reviews']['heading_text'] = $label_reviews;
1046
+	}
1047 1047
     
1048
-    return $tabs_arr;
1048
+	return $tabs_arr;
1049 1049
 }
1050 1050
 add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_reviews_tab_title', 1000, 1);
1051 1051
 
@@ -1056,13 +1056,13 @@  discard block
 block discarded – undo
1056 1056
  * @since 1.6.21
1057 1057
  */
1058 1058
 function geodir_jetpack_disable_comments(){
1059
-    //only run if jetpack installed
1060
-    if(defined('JETPACK__VERSION')){
1061
-        $post_types = geodir_get_posttypes();
1062
-        foreach($post_types as $post_type){
1063
-            add_filter('jetpack_comment_form_enabled_for_' . $post_type, '__return_false');
1064
-        }
1065
-    }
1059
+	//only run if jetpack installed
1060
+	if(defined('JETPACK__VERSION')){
1061
+		$post_types = geodir_get_posttypes();
1062
+		foreach($post_types as $post_type){
1063
+			add_filter('jetpack_comment_form_enabled_for_' . $post_type, '__return_false');
1064
+		}
1065
+	}
1066 1066
 }
1067 1067
 
1068 1068
 add_action('plugins_loaded','geodir_jetpack_disable_comments');
@@ -1077,13 +1077,13 @@  discard block
 block discarded – undo
1077 1077
  * @return bool True if allowed otherwise False.
1078 1078
  */
1079 1079
 function geodir_check_reviews_open( $open, $post_id ) {
1080
-    if ( $open && $post_id && geodir_is_page( 'detail' ) ) {
1081
-        if ( in_array( get_post_status( $post_id ), array( 'draft', 'pending', 'auto-draft', 'trash' ) ) ) {
1082
-            $open = false;
1083
-        }
1084
-    }
1080
+	if ( $open && $post_id && geodir_is_page( 'detail' ) ) {
1081
+		if ( in_array( get_post_status( $post_id ), array( 'draft', 'pending', 'auto-draft', 'trash' ) ) ) {
1082
+			$open = false;
1083
+		}
1084
+	}
1085 1085
     
1086
-    return $open;
1086
+	return $open;
1087 1087
 }
1088 1088
 add_filter( 'comments_open', 'geodir_check_reviews_open', 10, 2 );
1089 1089
 
@@ -1098,10 +1098,10 @@  discard block
 block discarded – undo
1098 1098
  * @return string Filtered comment content.
1099 1099
  */
1100 1100
 function geodir_remove_img_tags_from_comment( $comment_text, $comment = array(), $args = array() ) {
1101
-    if ( !empty( $comment_text ) && !empty( $comment ) && strpos( $comment_text, '[img' ) !== false && strpos( get_post_type( $comment->comment_post_ID ), 'gd_' ) === 0 ) {
1102
-        $comment_text = preg_replace( '#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_text );
1103
-        $comment_text = trim( $comment_text );
1104
-    }
1105
-    return $comment_text;
1101
+	if ( !empty( $comment_text ) && !empty( $comment ) && strpos( $comment_text, '[img' ) !== false && strpos( get_post_type( $comment->comment_post_ID ), 'gd_' ) === 0 ) {
1102
+		$comment_text = preg_replace( '#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_text );
1103
+		$comment_text = trim( $comment_text );
1104
+	}
1105
+	return $comment_text;
1106 1106
 }
1107 1107
 add_filter( 'comment_text', 'geodir_remove_img_tags_from_comment', 10, 3 );
1108 1108
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/taxonomy_functions.php 1 patch
Indentation   +1269 added lines, -1269 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,162 +1451,162 @@  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, $gd_cache_post;
1458
-    if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
1459
-        if($post_obj->post_status == 'auto-draft' || $post_obj->post_status == 'draft' || $post_obj->post_status == 'pending'){return $post_link;}
1460
-    } elseif (isset($post_obj->post_status) && ($post_obj->post_status == 'auto-draft' || $post_obj->post_status == 'draft' || $post_obj->post_status == 'pending')) {
1461
-        return $post_link;
1462
-    } else {
1463
-        $orig_post = $post;
1464
-        $post = $post_obj;
1465
-    }
1457
+	global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache, $gd_cache_post;
1458
+	if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
1459
+		if($post_obj->post_status == 'auto-draft' || $post_obj->post_status == 'draft' || $post_obj->post_status == 'pending'){return $post_link;}
1460
+	} elseif (isset($post_obj->post_status) && ($post_obj->post_status == 'auto-draft' || $post_obj->post_status == 'draft' || $post_obj->post_status == 'pending')) {
1461
+		return $post_link;
1462
+	} else {
1463
+		$orig_post = $post;
1464
+		$post = $post_obj;
1465
+	}
1466 1466
 
1467 1467
 
1468 1468
 
1469
-    if (in_array($post->post_type, geodir_get_posttypes())) {//print_r($post );exit;
1469
+	if (in_array($post->post_type, geodir_get_posttypes())) {//print_r($post );exit;
1470 1470
 
1471 1471
 
1472
-        // if we dont have a GD post then try to grab it
1473
-        if(!isset($post->default_category)){
1474
-            $gd_post = geodir_get_post_info($post->ID);
1475
-            if(!empty($gd_post)){
1476
-                $post = $gd_post;
1477
-            }
1478
-        }
1472
+		// if we dont have a GD post then try to grab it
1473
+		if(!isset($post->default_category)){
1474
+			$gd_post = geodir_get_post_info($post->ID);
1475
+			if(!empty($gd_post)){
1476
+				$post = $gd_post;
1477
+			}
1478
+		}
1479 1479
 
1480 1480
 
1481
-        $post_types = get_option('geodir_post_types');
1482
-        $slug = $post_types[$post->post_type]['rewrite']['slug'];
1481
+		$post_types = get_option('geodir_post_types');
1482
+		$slug = $post_types[$post->post_type]['rewrite']['slug'];
1483 1483
 
1484
-        // Alter the CPT slug if WPML is set to do so
1485
-        if(geodir_wpml_is_post_type_translated($post->post_type)){
1486
-            if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1484
+		// Alter the CPT slug if WPML is set to do so
1485
+		if(geodir_wpml_is_post_type_translated($post->post_type)){
1486
+			if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1487 1487
 
1488
-                $org_slug = $slug;
1489
-                $slug = apply_filters( 'wpml_translate_single_string',
1490
-                    $slug,
1491
-                    'WordPress',
1492
-                    'URL slug: ' . $slug,
1493
-                    $language_code);
1488
+				$org_slug = $slug;
1489
+				$slug = apply_filters( 'wpml_translate_single_string',
1490
+					$slug,
1491
+					'WordPress',
1492
+					'URL slug: ' . $slug,
1493
+					$language_code);
1494 1494
 
1495
-                if(!$slug){$slug = $org_slug;}
1495
+				if(!$slug){$slug = $org_slug;}
1496 1496
 
1497
-            }
1498
-        }
1497
+			}
1498
+		}
1499 1499
 
1500
-        if (function_exists('geodir_location_geo_home_link')) {
1501
-            remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1502
-        }
1500
+		if (function_exists('geodir_location_geo_home_link')) {
1501
+			remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1502
+		}
1503 1503
         
1504
-        // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz.
1505
-        $site_url = trailingslashit(get_bloginfo('url'));
1504
+		// Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz.
1505
+		$site_url = trailingslashit(get_bloginfo('url'));
1506 1506
         
1507
-        if (function_exists('geodir_location_geo_home_link')) {
1508
-            add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1509
-        }
1510
-
1511
-        $fix_url = strpos($post_link, $site_url) === 0 ? true : false;
1512
-        if ($fix_url) {
1513
-            $post_link = str_replace($site_url, '', $post_link);
1514
-        }
1515
-
1516
-        $post_link = trailingslashit(
1517
-            preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1518
-        );
1519
-
1520
-        if ($fix_url) {
1521
-            $post_link = $site_url . $post_link;
1522
-        }
1523
-
1524
-        if (isset($comment_post_cache[$post->ID])) {
1525
-            $post = $comment_post_cache[$post->ID];
1526
-        }
1527
-        if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
1528
-            $post_id = $post->ID;
1529
-            if (isset($orig_post)) {
1530
-                $post = $orig_post;
1531
-            }
1532
-            return $gd_permalink_cache[$post_id];
1533
-        }
1507
+		if (function_exists('geodir_location_geo_home_link')) {
1508
+			add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1509
+		}
1534 1510
 
1535
-        if (!isset($post->post_locations)) {
1536
-            $post_type = $post->post_type;
1537
-            $ID = $post->ID;
1538
-            $post2 = $wpdb->get_row(
1539
-                $wpdb->prepare(
1540
-                    "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1541
-                    array($post->ID)
1542
-                )
1543
-            );
1511
+		$fix_url = strpos($post_link, $site_url) === 0 ? true : false;
1512
+		if ($fix_url) {
1513
+			$post_link = str_replace($site_url, '', $post_link);
1514
+		}
1544 1515
 
1545
-            $post = (object)array_merge((array)$post, (array)$post2);
1516
+		$post_link = trailingslashit(
1517
+			preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1518
+		);
1546 1519
 
1547
-            $comment_post_cache[$post->ID] = $post;
1548
-        }
1520
+		if ($fix_url) {
1521
+			$post_link = $site_url . $post_link;
1522
+		}
1549 1523
 
1524
+		if (isset($comment_post_cache[$post->ID])) {
1525
+			$post = $comment_post_cache[$post->ID];
1526
+		}
1527
+		if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
1528
+			$post_id = $post->ID;
1529
+			if (isset($orig_post)) {
1530
+				$post = $orig_post;
1531
+			}
1532
+			return $gd_permalink_cache[$post_id];
1533
+		}
1550 1534
 
1535
+		if (!isset($post->post_locations)) {
1536
+			$post_type = $post->post_type;
1537
+			$ID = $post->ID;
1538
+			$post2 = $wpdb->get_row(
1539
+				$wpdb->prepare(
1540
+					"SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1541
+					array($post->ID)
1542
+				)
1543
+			);
1551 1544
 
1552
-        if (false !== strpos($post_link, '%gd_taxonomy%')) {
1545
+			$post = (object)array_merge((array)$post, (array)$post2);
1553 1546
 
1554
-            if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1555
-                $location_request = '';
1547
+			$comment_post_cache[$post->ID] = $post;
1548
+		}
1556 1549
 
1557 1550
 
1558
-                if (!empty($post->post_locations)) {
1559
-                    $geodir_arr_locations = explode(',', $post->post_locations);
1560
-                    if (count($geodir_arr_locations) == 3) {
1561
-                        $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1562
-                        $post->city_slug = str_replace(']', '', $post->city_slug);
1563
-                        $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1564
-                        $post->region_slug = str_replace(']', '', $post->region_slug);
1565
-                        $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1566
-                        $post->country_slug = str_replace(']', '', $post->country_slug);
1567 1551
 
1568
-                        $post_location = (object)array('country_slug' => $post->country_slug,
1569
-                            'region_slug' => $post->region_slug,
1570
-                            'city_slug' => $post->city_slug
1571
-                        );
1552
+		if (false !== strpos($post_link, '%gd_taxonomy%')) {
1572 1553
 
1573
-                    } else
1574
-                        $post_location = geodir_get_location();
1554
+			if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1555
+				$location_request = '';
1575 1556
 
1576 1557
 
1577
-                } else {
1558
+				if (!empty($post->post_locations)) {
1559
+					$geodir_arr_locations = explode(',', $post->post_locations);
1560
+					if (count($geodir_arr_locations) == 3) {
1561
+						$post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1562
+						$post->city_slug = str_replace(']', '', $post->city_slug);
1563
+						$post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1564
+						$post->region_slug = str_replace(']', '', $post->region_slug);
1565
+						$post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1566
+						$post->country_slug = str_replace(']', '', $post->country_slug);
1578 1567
 
1579
-                    $post_location_sql = $wpdb->get_results(
1580
-                        $wpdb->prepare(
1581
-                            "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1582
-                            array($post->ID)
1583
-                        )
1584
-                    );
1585
-
1586
-                    if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
1587
-
1588
-                        $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
1589
-                        if (count($geodir_arr_locations) == 3) {
1590
-                            $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1591
-                            $post->city_slug = str_replace(']', '', $post->city_slug);
1592
-                            $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1593
-                            $post->region_slug = str_replace(']', '', $post->region_slug);
1594
-                            $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1595
-                            $post->country_slug = str_replace(']', '', $post->country_slug);
1596
-
1597
-                            $post_location = (object)array('country_slug' => $post->country_slug,
1598
-                                'region_slug' => $post->region_slug,
1599
-                                'city_slug' => $post->city_slug
1600
-                            );
1568
+						$post_location = (object)array('country_slug' => $post->country_slug,
1569
+							'region_slug' => $post->region_slug,
1570
+							'city_slug' => $post->city_slug
1571
+						);
1601 1572
 
1602
-                        }
1603
-                    } else
1604
-                        $post_location = geodir_get_location();
1605
-                }
1573
+					} else
1574
+						$post_location = geodir_get_location();
1606 1575
 
1607 1576
 
1608
-                if (!empty($post_location)) {
1609
-                    $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : '';
1577
+				} else {
1578
+
1579
+					$post_location_sql = $wpdb->get_results(
1580
+						$wpdb->prepare(
1581
+							"SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1582
+							array($post->ID)
1583
+						)
1584
+					);
1585
+
1586
+					if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
1587
+
1588
+						$geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
1589
+						if (count($geodir_arr_locations) == 3) {
1590
+							$post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1591
+							$post->city_slug = str_replace(']', '', $post->city_slug);
1592
+							$post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1593
+							$post->region_slug = str_replace(']', '', $post->region_slug);
1594
+							$post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1595
+							$post->country_slug = str_replace(']', '', $post->country_slug);
1596
+
1597
+							$post_location = (object)array('country_slug' => $post->country_slug,
1598
+								'region_slug' => $post->region_slug,
1599
+								'city_slug' => $post->city_slug
1600
+							);
1601
+
1602
+						}
1603
+					} else
1604
+						$post_location = geodir_get_location();
1605
+				}
1606
+
1607
+
1608
+				if (!empty($post_location)) {
1609
+					$country_slug = isset($post_location->country_slug) ? $post_location->country_slug : '';
1610 1610
 					$region_slug = isset($post_location->region_slug) ? $post_location->region_slug : '';
1611 1611
 					$city_slug = isset($post_location->city_slug) ? $post_location->city_slug : '';
1612 1612
 					
@@ -1624,89 +1624,89 @@  discard block
 block discarded – undo
1624 1624
 					$location_slug[] = $city_slug;
1625 1625
 					
1626 1626
 					$location_request .= implode('/', $location_slug) . '/';
1627
-                }
1628
-            }
1627
+				}
1628
+			}
1629 1629
 
1630
-            if (get_option('geodir_add_categories_url')) {
1630
+			if (get_option('geodir_add_categories_url')) {
1631 1631
 
1632
-                $term_request = '';
1633
-                $taxonomies = geodir_get_taxonomies($post->post_type);
1634
-                $taxonomies = !empty($taxonomies) && is_array($taxonomies) ? end($taxonomies) : '';
1632
+				$term_request = '';
1633
+				$taxonomies = geodir_get_taxonomies($post->post_type);
1634
+				$taxonomies = !empty($taxonomies) && is_array($taxonomies) ? end($taxonomies) : '';
1635 1635
 
1636
-                if (!empty($post->default_category)) {
1637
-                    $post_terms = $post->default_category;
1638
-                } else {
1639
-                    $post_terms = '';
1640
-
1641
-                    if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1642
-                        $post_terms = absint($_POST['post_default_category']);
1643
-                    }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1644
-                        $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
1645
-                        $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0;
1646
-                    }elseif (isset($post->{$taxonomies})) {
1647
-                        $post_terms = explode(",", trim($post->{$taxonomies}, ","));
1648
-                        $post_terms = $post_terms[0];
1649
-                    }
1636
+				if (!empty($post->default_category)) {
1637
+					$post_terms = $post->default_category;
1638
+				} else {
1639
+					$post_terms = '';
1640
+
1641
+					if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1642
+						$post_terms = absint($_POST['post_default_category']);
1643
+					}elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1644
+						$post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
1645
+						$post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0;
1646
+					}elseif (isset($post->{$taxonomies})) {
1647
+						$post_terms = explode(",", trim($post->{$taxonomies}, ","));
1648
+						$post_terms = $post_terms[0];
1649
+					}
1650 1650
 
1651
-                    if (!$post_terms)
1652
-                        $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1651
+					if (!$post_terms)
1652
+						$post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1653 1653
 
1654
-                    if (!$post_terms) {
1655
-                        $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
1654
+					if (!$post_terms) {
1655
+						$post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
1656 1656
 
1657
-                        if ($post_terms) {
1658
-                            $post_terms = explode(",", trim($post_terms, ","));
1659
-                            $post_terms = $post_terms[0];
1660
-                        }
1661
-                    }
1662
-                }
1657
+						if ($post_terms) {
1658
+							$post_terms = explode(",", trim($post_terms, ","));
1659
+							$post_terms = $post_terms[0];
1660
+						}
1661
+					}
1662
+				}
1663 1663
 
1664
-                $term = get_term_by('id', $post_terms, $taxonomies);
1664
+				$term = get_term_by('id', $post_terms, $taxonomies);
1665 1665
 
1666
-                if (!empty($term))
1667
-                    $term_request = $term->slug;
1668
-                //$term_request = $term->slug.'/';
1669
-            }
1666
+				if (!empty($term))
1667
+					$term_request = $term->slug;
1668
+				//$term_request = $term->slug.'/';
1669
+			}
1670 1670
 
1671
-            $request_term = '';
1672
-            $listingurl_separator = '';
1673
-            //$detailurl_separator = get_option('geodir_detailurl_separator');
1674
-            $detailurl_separator = '';
1675
-            if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
1676
-                $request_term = $location_request;
1677
-                //$listingurl_separator = get_option('geodir_listingurl_separator');
1678
-                //$request_term .= $listingurl_separator.'/'.$term_request;
1679
-                $request_term .= $term_request;
1671
+			$request_term = '';
1672
+			$listingurl_separator = '';
1673
+			//$detailurl_separator = get_option('geodir_detailurl_separator');
1674
+			$detailurl_separator = '';
1675
+			if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
1676
+				$request_term = $location_request;
1677
+				//$listingurl_separator = get_option('geodir_listingurl_separator');
1678
+				//$request_term .= $listingurl_separator.'/'.$term_request;
1679
+				$request_term .= $term_request;
1680 1680
 
1681
-            } else {
1682
-                if (isset($location_request) && $location_request != '') $request_term = $location_request;
1681
+			} else {
1682
+				if (isset($location_request) && $location_request != '') $request_term = $location_request;
1683 1683
 
1684
-                if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1685
-            }
1686
-            $request_term = trim($request_term, '/');
1684
+				if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1685
+			}
1686
+			$request_term = trim($request_term, '/');
1687 1687
             
1688
-            // Fix with WPML the location terms added twice when CPT slug is translated.
1689
-            if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1690
-                $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1691
-            }
1688
+			// Fix with WPML the location terms added twice when CPT slug is translated.
1689
+			if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1690
+				$post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1691
+			}
1692 1692
             
1693
-            if (!empty($request_term))
1694
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1695
-            else
1696
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1697
-            //echo $post_link ;
1698
-        }
1699
-        // temp cache the permalink
1700
-        if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
1701
-            $gd_permalink_cache[$post->ID] = $post_link;
1702
-        }
1703
-    }
1704
-    if (isset($orig_post)) {
1705
-        $post = $orig_post;
1706
-    }
1693
+			if (!empty($request_term))
1694
+				$post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1695
+			else
1696
+				$post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1697
+			//echo $post_link ;
1698
+		}
1699
+		// temp cache the permalink
1700
+		if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
1701
+			$gd_permalink_cache[$post->ID] = $post_link;
1702
+		}
1703
+	}
1704
+	if (isset($orig_post)) {
1705
+		$post = $orig_post;
1706
+	}
1707 1707
 	$gd_cache_post = $post;
1708 1708
 
1709
-    return $post_link;
1709
+	return $post_link;
1710 1710
 }
1711 1711
 
1712 1712
 /**
@@ -1722,73 +1722,73 @@  discard block
 block discarded – undo
1722 1722
  * @return string The term link.
1723 1723
  */
1724 1724
 function geodir_term_link($termlink, $term, $taxonomy) {
1725
-    $geodir_taxonomies = geodir_get_taxonomies('', true);
1725
+	$geodir_taxonomies = geodir_get_taxonomies('', true);
1726 1726
 
1727
-    if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
1728
-        global $geodir_add_location_url, $gd_session;
1729
-        $orig_termlink = $termlink;
1727
+	if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
1728
+		global $geodir_add_location_url, $gd_session;
1729
+		$orig_termlink = $termlink;
1730 1730
 		$include_location = false;
1731
-        $request_term = array();
1732
-        $add_location_url = get_option('geodir_add_location_url');
1733
-        $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
1731
+		$request_term = array();
1732
+		$add_location_url = get_option('geodir_add_location_url');
1733
+		$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
1734 1734
 
1735
-        $listing_slug = geodir_get_listing_slug($taxonomy);
1735
+		$listing_slug = geodir_get_listing_slug($taxonomy);
1736 1736
 
1737
-        if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
1738
-            if ($geodir_add_location_url && $add_location_url) {
1739
-                $include_location = true;
1740
-            }
1741
-        } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
1742
-            $include_location = true;
1743
-        } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
1744
-            $include_location = true;
1745
-        }
1746
-
1747
-        if ($include_location) {
1748
-            global $post;
1749
-            $location_terms = array();
1737
+		if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
1738
+			if ($geodir_add_location_url && $add_location_url) {
1739
+				$include_location = true;
1740
+			}
1741
+		} elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
1742
+			$include_location = true;
1743
+		} elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
1744
+			$include_location = true;
1745
+		}
1746
+
1747
+		if ($include_location) {
1748
+			global $post;
1749
+			$location_terms = array();
1750 1750
             
1751
-            $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
1751
+			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
1752 1752
             
1753
-            if (geodir_is_page('detail')) {
1754
-                if (!isset($post->country_slug) && !empty($post->post_locations)) {
1755
-                    $post_locations = explode(',', $post->post_locations);
1756
-
1757
-                    if (count($post_locations) == 3) {
1758
-                        $post->city_slug = str_replace('[', '', $post_locations[0]);
1759
-                        $post->city_slug = str_replace(']', '', $post->city_slug);
1760
-                        $post->region_slug = str_replace('[', '', $post_locations[1]);
1761
-                        $post->region_slug = str_replace(']', '', $post->region_slug);
1762
-                        $post->country_slug = str_replace('[', '', $post_locations[2]);
1763
-                        $post->country_slug = str_replace(']', '', $post->country_slug);
1764
-                    }
1765
-                }
1753
+			if (geodir_is_page('detail')) {
1754
+				if (!isset($post->country_slug) && !empty($post->post_locations)) {
1755
+					$post_locations = explode(',', $post->post_locations);
1756
+
1757
+					if (count($post_locations) == 3) {
1758
+						$post->city_slug = str_replace('[', '', $post_locations[0]);
1759
+						$post->city_slug = str_replace(']', '', $post->city_slug);
1760
+						$post->region_slug = str_replace('[', '', $post_locations[1]);
1761
+						$post->region_slug = str_replace(']', '', $post->region_slug);
1762
+						$post->country_slug = str_replace('[', '', $post_locations[2]);
1763
+						$post->country_slug = str_replace(']', '', $post->country_slug);
1764
+					}
1765
+				}
1766 1766
 
1767
-                if (isset($post->country_slug)) {
1768
-                    $location_terms = array(
1769
-                        'gd_country' => $post->country_slug,
1770
-                        'gd_region' => $post->region_slug,
1771
-                        'gd_city' => $post->city_slug
1772
-                    );
1767
+				if (isset($post->country_slug)) {
1768
+					$location_terms = array(
1769
+						'gd_country' => $post->country_slug,
1770
+						'gd_region' => $post->region_slug,
1771
+						'gd_city' => $post->city_slug
1772
+					);
1773 1773
 
1774
-                    if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
1775
-                        $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
1776
-                    }
1777
-                }
1778
-            }
1774
+					if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
1775
+						$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
1776
+					}
1777
+				}
1778
+			}
1779 1779
             
1780
-            if (empty($location_terms)) {
1781
-                $location_terms = geodir_get_current_location_terms('query_vars');
1782
-            }
1780
+			if (empty($location_terms)) {
1781
+				$location_terms = geodir_get_current_location_terms('query_vars');
1782
+			}
1783 1783
 
1784
-            $geodir_show_location_url = get_option('geodir_show_location_url');
1785
-            $location_terms = geodir_remove_location_terms($location_terms);
1784
+			$geodir_show_location_url = get_option('geodir_show_location_url');
1785
+			$location_terms = geodir_remove_location_terms($location_terms);
1786 1786
 
1787
-            if (!empty($location_terms)) {
1788
-                $url_separator = '';
1787
+			if (!empty($location_terms)) {
1788
+				$url_separator = '';
1789 1789
 
1790
-                if (get_option('permalink_structure') != '') {
1791
-                    $found = false;
1790
+				if (get_option('permalink_structure') != '') {
1791
+					$found = false;
1792 1792
 					$request_term = implode("/", $location_terms);
1793 1793
 					if (geodir_is_wpml()) {
1794 1794
 						$post_types = get_option('geodir_post_types');
@@ -1824,47 +1824,47 @@  discard block
 block discarded – undo
1824 1824
 
1825 1825
 						$termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1826 1826
 					}
1827
-                } else {
1828
-                    $termlink = geodir_getlink($termlink, $request_term);
1829
-                }
1830
-            }
1831
-        }
1827
+				} else {
1828
+					$termlink = geodir_getlink($termlink, $request_term);
1829
+				}
1830
+			}
1831
+		}
1832 1832
 
1833
-        // Alter the CPT slug is WPML is set to do so
1834
-        /* we can replace this with the below function
1833
+		// Alter the CPT slug is WPML is set to do so
1834
+		/* we can replace this with the below function
1835 1835
         if(geodir_is_wpml()){
1836 1836
             global $sitepress;
1837 1837
             $post_type = str_replace("category","",$taxonomy);
1838 1838
             $termlink = $sitepress->post_type_archive_link_filter( $termlink, $post_type);
1839 1839
         }*/
1840 1840
 
1841
-        // Alter the CPT slug if WPML is set to do so
1842
-        if (geodir_is_wpml()) {
1843
-            $post_types = get_option('geodir_post_types');
1844
-            $post_type = str_replace("category","",$taxonomy);
1845
-            $post_type = str_replace("_tags","",$post_type);
1846
-            $slug = $post_types[$post_type]['rewrite']['slug'];
1847
-            if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) {
1848
-                global $sitepress;
1849
-                $default_lang = $sitepress->get_default_language();
1850
-                $language_code = gd_wpml_get_lang_from_url($orig_termlink);
1851
-                if (!$language_code ) {
1852
-                    $language_code  = $default_lang;
1853
-                }
1841
+		// Alter the CPT slug if WPML is set to do so
1842
+		if (geodir_is_wpml()) {
1843
+			$post_types = get_option('geodir_post_types');
1844
+			$post_type = str_replace("category","",$taxonomy);
1845
+			$post_type = str_replace("_tags","",$post_type);
1846
+			$slug = $post_types[$post_type]['rewrite']['slug'];
1847
+			if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) {
1848
+				global $sitepress;
1849
+				$default_lang = $sitepress->get_default_language();
1850
+				$language_code = gd_wpml_get_lang_from_url($orig_termlink);
1851
+				if (!$language_code ) {
1852
+					$language_code  = $default_lang;
1853
+				}
1854 1854
 
1855
-                $org_slug = $slug;
1856
-                $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1855
+				$org_slug = $slug;
1856
+				$slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1857 1857
 
1858
-                if (!$slug) {
1859
-                    $slug = $org_slug;
1860
-                }
1858
+				if (!$slug) {
1859
+					$slug = $org_slug;
1860
+				}
1861 1861
 
1862
-                $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1863
-            }
1864
-        }
1865
-    }
1862
+				$termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1863
+			}
1864
+		}
1865
+	}
1866 1866
     
1867
-    return $termlink;
1867
+	return $termlink;
1868 1868
 }
1869 1869
 
1870 1870
 /**
@@ -1890,14 +1890,14 @@  discard block
 block discarded – undo
1890 1890
 	if (in_array($post_type, geodir_get_posttypes())) {
1891 1891
 		if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
1892 1892
 			if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
1893
-                $location_terms = array(
1894
-                    'gd_country' => $post->country_slug,
1895
-                    'gd_region' => $post->region_slug,
1896
-                    'gd_city' => $post->city_slug
1897
-                );
1898
-            } else {
1899
-                $location_terms = geodir_get_current_location_terms('query_vars');
1900
-            }
1893
+				$location_terms = array(
1894
+					'gd_country' => $post->country_slug,
1895
+					'gd_region' => $post->region_slug,
1896
+					'gd_city' => $post->city_slug
1897
+				);
1898
+			} else {
1899
+				$location_terms = geodir_get_current_location_terms('query_vars');
1900
+			}
1901 1901
 			
1902 1902
 			$location_terms = geodir_remove_location_terms($location_terms);
1903 1903
 			
@@ -1929,17 +1929,17 @@  discard block
 block discarded – undo
1929 1929
  * @return void|string Label.
1930 1930
  */
1931 1931
 function get_post_type_singular_label($post_type, $echo = false, $translate = false) {
1932
-    $obj_post_type = get_post_type_object($post_type);
1933
-    if (!is_object($obj_post_type)) {
1934
-        return;
1935
-    }
1932
+	$obj_post_type = get_post_type_object($post_type);
1933
+	if (!is_object($obj_post_type)) {
1934
+		return;
1935
+	}
1936 1936
     
1937
-    $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1937
+	$label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1938 1938
     
1939
-    if ($echo)
1940
-        echo $label;
1941
-    else
1942
-        return $label;
1939
+	if ($echo)
1940
+		echo $label;
1941
+	else
1942
+		return $label;
1943 1943
 }
1944 1944
 
1945 1945
 /**
@@ -1954,19 +1954,19 @@  discard block
 block discarded – undo
1954 1954
  * @return void|string Label.
1955 1955
  */
1956 1956
 function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
1957
-    $all_postypes = geodir_get_posttypes();
1957
+	$all_postypes = geodir_get_posttypes();
1958 1958
 
1959
-    if (!in_array($post_type, $all_postypes))
1960
-        return false;
1959
+	if (!in_array($post_type, $all_postypes))
1960
+		return false;
1961 1961
 
1962
-    $obj_post_type = get_post_type_object($post_type);
1962
+	$obj_post_type = get_post_type_object($post_type);
1963 1963
     
1964
-    $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1964
+	$label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1965 1965
     
1966
-    if ($echo)
1967
-        echo $label;
1968
-    else
1969
-        return $label;
1966
+	if ($echo)
1967
+		echo $label;
1968
+	else
1969
+		return $label;
1970 1970
 }
1971 1971
 
1972 1972
 /**
@@ -1984,51 +1984,51 @@  discard block
 block discarded – undo
1984 1984
  */
1985 1985
 function geodir_term_exists($term, $taxonomy = '', $parent = 0)
1986 1986
 {
1987
-    global $wpdb;
1988
-
1989
-    $select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1990
-    $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 ";
1991
-
1992
-    if (is_int($term)) {
1993
-        if (0 == $term)
1994
-            return 0;
1995
-        $where = 't.term_id = %d';
1996
-        if (!empty($taxonomy))
1997
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1998
-        else
1999
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
2000
-    }
1987
+	global $wpdb;
1988
+
1989
+	$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1990
+	$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 ";
1991
+
1992
+	if (is_int($term)) {
1993
+		if (0 == $term)
1994
+			return 0;
1995
+		$where = 't.term_id = %d';
1996
+		if (!empty($taxonomy))
1997
+			return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1998
+		else
1999
+			return $wpdb->get_var($wpdb->prepare($select . $where, $term));
2000
+	}
2001 2001
 
2002
-    $term = trim(wp_unslash($term));
2002
+	$term = trim(wp_unslash($term));
2003 2003
 
2004
-    if ('' === $slug = sanitize_title($term))
2005
-        return 0;
2004
+	if ('' === $slug = sanitize_title($term))
2005
+		return 0;
2006 2006
 
2007
-    $where = 't.slug = %s';
2007
+	$where = 't.slug = %s';
2008 2008
 
2009
-    $where_fields = array($slug);
2010
-    if (!empty($taxonomy)) {
2011
-        $parent = (int)$parent;
2012
-        if ($parent > 0) {
2013
-            $where_fields[] = $parent;
2014
-            $else_where_fields[] = $parent;
2015
-            $where .= ' AND tt.parent = %d';
2009
+	$where_fields = array($slug);
2010
+	if (!empty($taxonomy)) {
2011
+		$parent = (int)$parent;
2012
+		if ($parent > 0) {
2013
+			$where_fields[] = $parent;
2014
+			$else_where_fields[] = $parent;
2015
+			$where .= ' AND tt.parent = %d';
2016 2016
 
2017
-        }
2017
+		}
2018 2018
 
2019
-        $where_fields[] = $taxonomy;
2019
+		$where_fields[] = $taxonomy;
2020 2020
 
2021 2021
 
2022
-        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))
2023
-            return $result;
2022
+		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))
2023
+			return $result;
2024 2024
 
2025
-        return false;
2026
-    }
2025
+		return false;
2026
+	}
2027 2027
 
2028
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
2029
-        return $result;
2028
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
2029
+		return $result;
2030 2030
 
2031
-    return false;
2031
+	return false;
2032 2032
 }
2033 2033
 
2034 2034
 /**
@@ -2040,7 +2040,7 @@  discard block
 block discarded – undo
2040 2040
 function geodir_get_term_icon_rebuild()
2041 2041
 {
2042 2042
 
2043
-    update_option('gd_term_icons', '');
2043
+	update_option('gd_term_icons', '');
2044 2044
 
2045 2045
 }
2046 2046
 
@@ -2058,61 +2058,61 @@  discard block
 block discarded – undo
2058 2058
  */
2059 2059
 function geodir_get_term_icon($term_id = false, $rebuild = false)
2060 2060
 {
2061
-    global $wpdb;
2062
-    if (!$rebuild) {
2063
-        $terms_icons = get_option('gd_term_icons');
2064
-    } else {
2065
-        $terms_icons = array();
2066
-    }
2067
-
2068
-    if (empty($terms_icons)) {
2069
-        $terms_icons = array();
2070
-        $default_icon_url = get_option('geodir_default_marker_icon');
2071
-        $taxonomy = geodir_get_taxonomies();
2072
-        $post_types = geodir_get_posttypes();
2073
-        $tax_arr = array();
2074
-        foreach ($post_types as $post_type) {
2075
-            $tax_arr[] = "'" . $post_type . "category'";
2076
-        }
2077
-        $tax_c = implode(',', $tax_arr);
2078
-        $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2079
-        //$terms = get_terms( $taxonomy );
2080
-
2081
-        if($terms) {
2082
-            foreach ($terms as $term) {
2083
-                $post_type = str_replace("category", "", $term->taxonomy);
2084
-                $a_terms[$post_type][] = $term;
2061
+	global $wpdb;
2062
+	if (!$rebuild) {
2063
+		$terms_icons = get_option('gd_term_icons');
2064
+	} else {
2065
+		$terms_icons = array();
2066
+	}
2085 2067
 
2086
-            }
2087
-        }
2068
+	if (empty($terms_icons)) {
2069
+		$terms_icons = array();
2070
+		$default_icon_url = get_option('geodir_default_marker_icon');
2071
+		$taxonomy = geodir_get_taxonomies();
2072
+		$post_types = geodir_get_posttypes();
2073
+		$tax_arr = array();
2074
+		foreach ($post_types as $post_type) {
2075
+			$tax_arr[] = "'" . $post_type . "category'";
2076
+		}
2077
+		$tax_c = implode(',', $tax_arr);
2078
+		$terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2079
+		//$terms = get_terms( $taxonomy );
2088 2080
 
2089
-        if($a_terms) {
2090
-            foreach ($a_terms as $pt => $t2) {
2081
+		if($terms) {
2082
+			foreach ($terms as $term) {
2083
+				$post_type = str_replace("category", "", $term->taxonomy);
2084
+				$a_terms[$post_type][] = $term;
2091 2085
 
2092
-                foreach ($t2 as $term) {
2093
-                    $term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2094
-                    if ($term_icon) {
2095
-                        $term_icon_url = $term_icon["src"];
2096
-                    } else {
2097
-                        $term_icon_url = $default_icon_url;
2098
-                    }
2099
-                    $terms_icons[$term->term_id] = $term_icon_url;
2100
-                }
2101
-            }
2102
-        }
2086
+			}
2087
+		}
2088
+
2089
+		if($a_terms) {
2090
+			foreach ($a_terms as $pt => $t2) {
2103 2091
 
2104
-        update_option('gd_term_icons', $terms_icons);
2105
-    }
2092
+				foreach ($t2 as $term) {
2093
+					$term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2094
+					if ($term_icon) {
2095
+						$term_icon_url = $term_icon["src"];
2096
+					} else {
2097
+						$term_icon_url = $default_icon_url;
2098
+					}
2099
+					$terms_icons[$term->term_id] = $term_icon_url;
2100
+				}
2101
+			}
2102
+		}
2106 2103
 
2107
-    if ($term_id && isset($terms_icons[$term_id])) {
2108
-        return $terms_icons[$term_id];
2109
-    } elseif ($term_id && !isset($terms_icons[$term_id])) {
2110
-        return get_option('geodir_default_marker_icon');
2111
-    }
2104
+		update_option('gd_term_icons', $terms_icons);
2105
+	}
2106
+
2107
+	if ($term_id && isset($terms_icons[$term_id])) {
2108
+		return $terms_icons[$term_id];
2109
+	} elseif ($term_id && !isset($terms_icons[$term_id])) {
2110
+		return get_option('geodir_default_marker_icon');
2111
+	}
2112 2112
 
2113
-    if (is_ssl()) {
2114
-        $terms_icons = str_replace("http:","https:",$terms_icons );
2115
-    }
2113
+	if (is_ssl()) {
2114
+		$terms_icons = str_replace("http:","https:",$terms_icons );
2115
+	}
2116 2116
 
2117
-    return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2117
+	return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2118 2118
 }
2119 2119
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/shortcode_functions.php 1 patch
Indentation   +427 added lines, -427 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  
10 10
 // If this file is called directly, abort.
11 11
 if (!defined('WPINC')) {
12
-    die;
12
+	die;
13 13
 }
14 14
 
15 15
 /**
@@ -22,22 +22,22 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function gdsc_validate_measurements($value)
24 24
 {
25
-    if ((strlen($value) - 1) == strpos(trim($value), '%')) {
26
-        // $value is entered as a percent, so it can't be less than 0 or more than 100
27
-        $value = preg_replace('/\D/', '', $value);
28
-        if (100 < $value) {
29
-            $value = 100;
30
-        }
31
-        // Re-add the percent symbol
32
-        $value = $value . '%';
33
-    } elseif ((strlen($value) - 2) == strpos(trim($value), 'px')) {
34
-        // Get the absint & re-add the 'px'
35
-        $value = preg_replace('/\D/', '', $value) . 'px';
36
-    } else {
37
-        $value = preg_replace('/\D/', '', $value);
38
-    }
25
+	if ((strlen($value) - 1) == strpos(trim($value), '%')) {
26
+		// $value is entered as a percent, so it can't be less than 0 or more than 100
27
+		$value = preg_replace('/\D/', '', $value);
28
+		if (100 < $value) {
29
+			$value = 100;
30
+		}
31
+		// Re-add the percent symbol
32
+		$value = $value . '%';
33
+	} elseif ((strlen($value) - 2) == strpos(trim($value), 'px')) {
34
+		// Get the absint & re-add the 'px'
35
+		$value = preg_replace('/\D/', '', $value) . 'px';
36
+	} else {
37
+		$value = preg_replace('/\D/', '', $value);
38
+	}
39 39
 
40
-    return $value;
40
+	return $value;
41 41
 }
42 42
 
43 43
 /**
@@ -52,35 +52,35 @@  discard block
 block discarded – undo
52 52
 function gdsc_validate_map_args($params)
53 53
 {
54 54
 
55
-    $params['width'] = gdsc_validate_measurements($params['width']);
56
-    $params['height'] = gdsc_validate_measurements($params['height']);
55
+	$params['width'] = gdsc_validate_measurements($params['width']);
56
+	$params['height'] = gdsc_validate_measurements($params['height']);
57 57
 
58
-    // Only accept our 4 maptypes. Otherwise, revert to the default.
59
-    if (!(in_array(geodir_strtoupper($params['maptype']), array('HYBRID', 'SATELLITE', 'ROADMAP', 'TERRAIN')))) {
60
-        $params['maptype'] = 'ROADMAP';
61
-    } else {
62
-        $params['maptype'] = geodir_strtoupper($params['maptype']);
63
-    }
58
+	// Only accept our 4 maptypes. Otherwise, revert to the default.
59
+	if (!(in_array(geodir_strtoupper($params['maptype']), array('HYBRID', 'SATELLITE', 'ROADMAP', 'TERRAIN')))) {
60
+		$params['maptype'] = 'ROADMAP';
61
+	} else {
62
+		$params['maptype'] = geodir_strtoupper($params['maptype']);
63
+	}
64 64
 
65
-    // Zoom accepts a value between 1 and 19
66
-    $params['zoom'] = absint($params['zoom']);
67
-    if (19 < $params['zoom']) {
68
-        $params['zoom'] = '19';
69
-    }
70
-    if (0 == $params['zoom']) {
71
-        $params['zoom'] = '1';
72
-    }
65
+	// Zoom accepts a value between 1 and 19
66
+	$params['zoom'] = absint($params['zoom']);
67
+	if (19 < $params['zoom']) {
68
+		$params['zoom'] = '19';
69
+	}
70
+	if (0 == $params['zoom']) {
71
+		$params['zoom'] = '1';
72
+	}
73 73
 
74
-    // Child_collapse must be boolean
75
-    $params['child_collapse'] = gdsc_to_bool_val($params['child_collapse']);
74
+	// Child_collapse must be boolean
75
+	$params['child_collapse'] = gdsc_to_bool_val($params['child_collapse']);
76 76
 
77
-    // Scrollwheel must be boolean
78
-    $params['scrollwheel'] = gdsc_to_bool_val($params['scrollwheel']);
77
+	// Scrollwheel must be boolean
78
+	$params['scrollwheel'] = gdsc_to_bool_val($params['scrollwheel']);
79 79
 
80
-    // Scrollwheel must be boolean
81
-    $params['autozoom'] = gdsc_to_bool_val($params['autozoom']);
80
+	// Scrollwheel must be boolean
81
+	$params['autozoom'] = gdsc_to_bool_val($params['autozoom']);
82 82
 
83
-    return $params;
83
+	return $params;
84 84
 }
85 85
 
86 86
 /**
@@ -99,52 +99,52 @@  discard block
 block discarded – undo
99 99
  */
100 100
 function gdsc_to_bool_val($in, $strict = false)
101 101
 {
102
-    $out = null;
103
-
104
-    // if not strict, we only have to check if something is false
105
-    if (in_array($in, array(
106
-        'false',
107
-        'False',
108
-        'FALSE',
109
-        'no',
110
-        'No',
111
-        'n',
112
-        'N',
113
-        '0',
114
-        'off',
115
-        'Off',
116
-        'OFF',
117
-        false,
118
-        0,
119
-        null
120
-    ), true)) {
121
-        $out = false;
122
-    } else if ($strict) {
123
-        // if strict, check the equivalent true values
124
-        if (in_array($in, array(
125
-            'true',
126
-            'True',
127
-            'TRUE',
128
-            'yes',
129
-            'Yes',
130
-            'y',
131
-            'Y',
132
-            '1',
133
-            'on',
134
-            'On',
135
-            'ON',
136
-            true,
137
-            1
138
-        ), true)) {
139
-            $out = true;
140
-        }
141
-    } else {
142
-        // not strict? let the regular php bool check figure it out (will
143
-        //     largely default to true)
144
-        $out = ($in ? true : false);
145
-    }
102
+	$out = null;
103
+
104
+	// if not strict, we only have to check if something is false
105
+	if (in_array($in, array(
106
+		'false',
107
+		'False',
108
+		'FALSE',
109
+		'no',
110
+		'No',
111
+		'n',
112
+		'N',
113
+		'0',
114
+		'off',
115
+		'Off',
116
+		'OFF',
117
+		false,
118
+		0,
119
+		null
120
+	), true)) {
121
+		$out = false;
122
+	} else if ($strict) {
123
+		// if strict, check the equivalent true values
124
+		if (in_array($in, array(
125
+			'true',
126
+			'True',
127
+			'TRUE',
128
+			'yes',
129
+			'Yes',
130
+			'y',
131
+			'Y',
132
+			'1',
133
+			'on',
134
+			'On',
135
+			'ON',
136
+			true,
137
+			1
138
+		), true)) {
139
+			$out = true;
140
+		}
141
+	} else {
142
+		// not strict? let the regular php bool check figure it out (will
143
+		//     largely default to true)
144
+		$out = ($in ? true : false);
145
+	}
146 146
 
147
-    return $out;
147
+	return $out;
148 148
 }
149 149
 
150 150
 /**
@@ -157,16 +157,16 @@  discard block
 block discarded – undo
157 157
  */
158 158
 function gdsc_is_post_type_valid($incoming_post_type)
159 159
 {
160
-    $post_types = geodir_get_posttypes();
161
-    $post_types = array_map('geodir_strtolower', $post_types);
162
-    $post_type_found = false;
163
-    foreach ($post_types as $type) {
164
-        if (geodir_strtolower($incoming_post_type) == geodir_strtolower($type)) {
165
-            $post_type_found = true;
166
-        }
167
-    }
160
+	$post_types = geodir_get_posttypes();
161
+	$post_types = array_map('geodir_strtolower', $post_types);
162
+	$post_type_found = false;
163
+	foreach ($post_types as $type) {
164
+		if (geodir_strtolower($incoming_post_type) == geodir_strtolower($type)) {
165
+			$post_type_found = true;
166
+		}
167
+	}
168 168
 
169
-    return $post_type_found;
169
+	return $post_type_found;
170 170
 }
171 171
 
172 172
 /**
@@ -186,52 +186,52 @@  discard block
 block discarded – undo
186 186
  */
187 187
 function gdsc_listing_loop_filter($query)
188 188
 {
189
-    global $wp_query, $geodir_post_type, $table, $plugin_prefix, $term;
190
-
191
-    $geodir_post_type = geodir_get_current_posttype();
192
-
193
-    if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) {
194
-        $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy');
195
-
196
-        if (isset($wp_query->query[$taxonomies[0]])) {
197
-            $request_term = explode("/", $wp_query->query[$taxonomies[0]]);
198
-            $request_term = end($request_term);
199
-            if (!term_exists($request_term)) {
200
-                $args = array('number' => '1',);
201
-                $terms_arr = get_terms($taxonomies[0], $args);
202
-                foreach ($terms_arr as $location_term) {
203
-                    $term_arr = $location_term;
204
-                    $term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term));
205
-                }
206
-                $wp_query->queried_object_id = 1;
207
-                $wp_query->queried_object = $term_arr;
208
-            }
209
-        }
189
+	global $wp_query, $geodir_post_type, $table, $plugin_prefix, $term;
190
+
191
+	$geodir_post_type = geodir_get_current_posttype();
192
+
193
+	if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) {
194
+		$taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy');
195
+
196
+		if (isset($wp_query->query[$taxonomies[0]])) {
197
+			$request_term = explode("/", $wp_query->query[$taxonomies[0]]);
198
+			$request_term = end($request_term);
199
+			if (!term_exists($request_term)) {
200
+				$args = array('number' => '1',);
201
+				$terms_arr = get_terms($taxonomies[0], $args);
202
+				foreach ($terms_arr as $location_term) {
203
+					$term_arr = $location_term;
204
+					$term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term));
205
+				}
206
+				$wp_query->queried_object_id = 1;
207
+				$wp_query->queried_object = $term_arr;
208
+			}
209
+		}
210 210
 
211
-    }
212
-    if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
211
+	}
212
+	if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
213 213
 
214
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
214
+		$table = $plugin_prefix . $geodir_post_type . '_detail';
215 215
 
216
-        add_filter('posts_fields', 'geodir_posts_fields', 1);
217
-        add_filter('posts_join', 'geodir_posts_join', 1);
218
-        geodir_post_where();
219
-        if (!is_admin()) {
220
-            add_filter('posts_orderby', 'geodir_posts_orderby', 1);
221
-        }
216
+		add_filter('posts_fields', 'geodir_posts_fields', 1);
217
+		add_filter('posts_join', 'geodir_posts_join', 1);
218
+		geodir_post_where();
219
+		if (!is_admin()) {
220
+			add_filter('posts_orderby', 'geodir_posts_orderby', 1);
221
+		}
222 222
 
223
-        // advanced filter for popular post view widget
224
-        global $wp_query;
225
-        if (!is_admin()) {
226
-            if (!empty($wp_query->query['with_pics_only'])) {
227
-                add_filter('posts_join', 'geodir_filter_widget_join', 1000);
228
-            }
229
-            add_filter('posts_where', 'geodir_filter_widget_where', 1000);
230
-        }
223
+		// advanced filter for popular post view widget
224
+		global $wp_query;
225
+		if (!is_admin()) {
226
+			if (!empty($wp_query->query['with_pics_only'])) {
227
+				add_filter('posts_join', 'geodir_filter_widget_join', 1000);
228
+			}
229
+			add_filter('posts_where', 'geodir_filter_widget_where', 1000);
230
+		}
231 231
 
232
-    }
232
+	}
233 233
 
234
-    return $query;
234
+	return $query;
235 235
 }
236 236
 
237 237
 /**
@@ -245,40 +245,40 @@  discard block
 block discarded – undo
245 245
  */
246 246
 function gdsc_manage_category_choice($post_type, $category)
247 247
 {
248
-    if (0 == $category || '' == $category) {
249
-        return '';
250
-    }
248
+	if (0 == $category || '' == $category) {
249
+		return '';
250
+	}
251 251
 
252
-    if (!(gdsc_is_post_type_valid($post_type))) {
253
-        return '';
254
-    }
252
+	if (!(gdsc_is_post_type_valid($post_type))) {
253
+		return '';
254
+	}
255 255
 
256
-    $taxonomies = geodir_get_taxonomies($post_type);
256
+	$taxonomies = geodir_get_taxonomies($post_type);
257 257
 
258
-    $categories = get_terms(array('taxonomy' => $taxonomies[0],'hide_empty' => false));
258
+	$categories = get_terms(array('taxonomy' => $taxonomies[0],'hide_empty' => false));
259 259
 
260
-    $cat_id = 0;
260
+	$cat_id = 0;
261 261
 
262
-    foreach ($categories as $cat) {
263
-        if (is_numeric($category)) {
264
-            if (absint($category) == $cat->term_id) {
265
-                $cat_id = $cat->term_id;
266
-                break;
267
-            }
268
-        } else {
269
-            if ($category == $cat->slug) {
270
-                $cat_id = $cat->term_id;
271
-                break;
272
-            }
262
+	foreach ($categories as $cat) {
263
+		if (is_numeric($category)) {
264
+			if (absint($category) == $cat->term_id) {
265
+				$cat_id = $cat->term_id;
266
+				break;
267
+			}
268
+		} else {
269
+			if ($category == $cat->slug) {
270
+				$cat_id = $cat->term_id;
271
+				break;
272
+			}
273 273
 
274
-            if ($category == $cat->name) {
275
-                $cat_id = $cat->term_id;
276
-                break;
277
-            }
278
-        }
279
-    }
274
+			if ($category == $cat->name) {
275
+				$cat_id = $cat->term_id;
276
+				break;
277
+			}
278
+		}
279
+	}
280 280
 
281
-    return $cat_id;
281
+	return $cat_id;
282 282
 }
283 283
 
284 284
 // @todo: Extract this
@@ -288,11 +288,11 @@  discard block
 block discarded – undo
288 288
 	 * Adds the script in the page footer for the home page google map.
289 289
 	 *
290 290
 	 * @since 1.0.0
291
-     * @return string Print the script in page footer.
291
+	 * @return string Print the script in page footer.
292 292
 	 */
293 293
 	function geodir_home_map_add_script()
294
-    {
295
-        ?>
294
+	{
295
+		?>
296 296
         <script type="text/javascript">
297 297
             jQuery(document).ready(function () {
298 298
                 geoDirMapSlide();
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
             }
366 366
         </script>
367 367
     <?php
368
-    }
368
+	}
369 369
 }
370 370
 
371 371
 /**
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
  */
377 377
 function geodir_popular_category_add_scripts()
378 378
 {
379
-    ?>
379
+	?>
380 380
     <script type="text/javascript">
381 381
         jQuery(function ($) {
382 382
             $('.geodir-showcat').click(function () {
@@ -406,56 +406,56 @@  discard block
 block discarded – undo
406 406
  */
407 407
 function gdsc_validate_layout_choice($layout_choice)
408 408
 {
409
-    switch (geodir_strtolower($layout_choice)) {
410
-        case 'list';
411
-        case 'one';
412
-        case 'one_column';
413
-        case 'onecolumn';
414
-        case '1';
415
-            $layout_choice = 'list';
416
-            break;
417
-        case 'gridview_onehalf';
418
-        case 'two';
419
-        case 'two_column';
420
-        case 'two_columns';
421
-        case 'twocolumn';
422
-        case 'twocolumns';
423
-        case '2';
424
-            $layout_choice = 'gridview_onehalf';
425
-            break;
426
-        case 'gridview_onethird';
427
-        case 'three';
428
-        case 'three_column';
429
-        case 'three_columns';
430
-        case 'threecolumn';
431
-        case 'threecolumns';
432
-        case '3';
433
-            $layout_choice = 'gridview_onethird';
434
-            break;
435
-        case 'gridview_onefourth';
436
-        case 'four';
437
-        case 'four_column';
438
-        case 'four_columns';
439
-        case 'fourcolumn';
440
-        case 'fourcolumns';
441
-        case '4';
442
-            $layout_choice = 'gridview_onefourth';
443
-            break;
444
-        case 'gridview_onefifth';
445
-        case 'five';
446
-        case 'five_column';
447
-        case 'five_columns';
448
-        case 'fivecolumn';
449
-        case 'fivecolumns';
450
-        case '5';
451
-            $layout_choice = 'gridview_onefifth';
452
-            break;
453
-        default:
454
-            $layout_choice = 'gridview_onehalf';
455
-            break;
456
-    }
409
+	switch (geodir_strtolower($layout_choice)) {
410
+		case 'list';
411
+		case 'one';
412
+		case 'one_column';
413
+		case 'onecolumn';
414
+		case '1';
415
+			$layout_choice = 'list';
416
+			break;
417
+		case 'gridview_onehalf';
418
+		case 'two';
419
+		case 'two_column';
420
+		case 'two_columns';
421
+		case 'twocolumn';
422
+		case 'twocolumns';
423
+		case '2';
424
+			$layout_choice = 'gridview_onehalf';
425
+			break;
426
+		case 'gridview_onethird';
427
+		case 'three';
428
+		case 'three_column';
429
+		case 'three_columns';
430
+		case 'threecolumn';
431
+		case 'threecolumns';
432
+		case '3';
433
+			$layout_choice = 'gridview_onethird';
434
+			break;
435
+		case 'gridview_onefourth';
436
+		case 'four';
437
+		case 'four_column';
438
+		case 'four_columns';
439
+		case 'fourcolumn';
440
+		case 'fourcolumns';
441
+		case '4';
442
+			$layout_choice = 'gridview_onefourth';
443
+			break;
444
+		case 'gridview_onefifth';
445
+		case 'five';
446
+		case 'five_column';
447
+		case 'five_columns';
448
+		case 'fivecolumn';
449
+		case 'fivecolumns';
450
+		case '5';
451
+			$layout_choice = 'gridview_onefifth';
452
+			break;
453
+		default:
454
+			$layout_choice = 'gridview_onehalf';
455
+			break;
456
+	}
457 457
 
458
-    return $layout_choice;
458
+	return $layout_choice;
459 459
 }
460 460
 
461 461
 /**
@@ -472,34 +472,34 @@  discard block
 block discarded – undo
472 472
  */
473 473
 function gdsc_validate_sort_choice($sort_choice, $post_type = '')
474 474
 {
475
-    global $plugin_prefix;
476
-
477
-    $sorts = array(
478
-        'az',
479
-        'latest',
480
-        'featured',
481
-        'high_review',
482
-        'high_rating',
483
-        'random',
484
-    );
485
-
486
-    if (in_array($sort_choice, $sorts)) {
487
-        return $sort_choice;
488
-    }
475
+	global $plugin_prefix;
476
+
477
+	$sorts = array(
478
+		'az',
479
+		'latest',
480
+		'featured',
481
+		'high_review',
482
+		'high_rating',
483
+		'random',
484
+	);
485
+
486
+	if (in_array($sort_choice, $sorts)) {
487
+		return $sort_choice;
488
+	}
489 489
 
490
-    if (!empty($post_type)) {
491
-        $table = $plugin_prefix . $post_type . '_detail';
490
+	if (!empty($post_type)) {
491
+		$table = $plugin_prefix . $post_type . '_detail';
492 492
         
493
-        if (!geodir_prepare_custom_sorting($sort_choice, $table)) {
494
-            $sort_choice = '';
495
-        }
496
-    }
493
+		if (!geodir_prepare_custom_sorting($sort_choice, $table)) {
494
+			$sort_choice = '';
495
+		}
496
+	}
497 497
 
498
-    if (empty($post_type) || empty($sort_choice)) {
499
-        $sort_choice = 'latest';
500
-    }
498
+	if (empty($post_type) || empty($sort_choice)) {
499
+		$sort_choice = 'latest';
500
+	}
501 501
 
502
-    return $sort_choice;
502
+	return $sort_choice;
503 503
 }
504 504
 
505 505
 /**
@@ -512,22 +512,22 @@  discard block
 block discarded – undo
512 512
  */
513 513
 function gdsc_validate_listing_width($width_choice)
514 514
 {
515
-    if (!(empty($width_choice))) {
516
-        $width_choice = absint($width_choice);
517
-    } else {
518
-        return '';
519
-    }
515
+	if (!(empty($width_choice))) {
516
+		$width_choice = absint($width_choice);
517
+	} else {
518
+		return '';
519
+	}
520 520
 
521
-    if (100 < $width_choice) {
522
-        $width_choice = 100;
523
-    }
521
+	if (100 < $width_choice) {
522
+		$width_choice = 100;
523
+	}
524 524
 
525
-    // If listing_width is too narrow, it won't work, arbitrarily set to 10% here
526
-    if (10 > $width_choice) {
527
-        $width_choice = 10;
528
-    }
525
+	// If listing_width is too narrow, it won't work, arbitrarily set to 10% here
526
+	if (10 > $width_choice) {
527
+		$width_choice = 10;
528
+	}
529 529
 
530
-    return $width_choice;
530
+	return $width_choice;
531 531
 }
532 532
 
533 533
 /**
@@ -540,18 +540,18 @@  discard block
 block discarded – undo
540 540
  */
541 541
 function gdsc_validate_list_filter_choice($filter_choice)
542 542
 {
543
-    $filters = array(
544
-        'all',
545
-        'today',
546
-        'upcoming',
547
-        'past',
548
-    );
549
-
550
-    if (!(in_array($filter_choice, $filters))) {
551
-        $filter_choice = 'all';
552
-    }
543
+	$filters = array(
544
+		'all',
545
+		'today',
546
+		'upcoming',
547
+		'past',
548
+	);
549
+
550
+	if (!(in_array($filter_choice, $filters))) {
551
+		$filter_choice = 'all';
552
+	}
553 553
 
554
-    return $filter_choice;
554
+	return $filter_choice;
555 555
 }
556 556
 
557 557
 /**
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
  * @return string Listings HTML content.
575 575
  */
576 576
 function geodir_sc_gd_listings_output($args = array()) {
577
-    $title				 = !empty($args['title']) ? __($args['title'], 'geodirectory') : '';
577
+	$title				 = !empty($args['title']) ? __($args['title'], 'geodirectory') : '';
578 578
 	$post_type 			 = !empty($args['post_type']) ? $args['post_type'] : 'gd_place';
579 579
 	$category 			 = !empty($args['category']) ? $args['category'] : '0';
580 580
 	$post_number		 = !empty($args['post_number']) ? $args['post_number'] : 10;
@@ -585,17 +585,17 @@  discard block
 block discarded – undo
585 585
 	$listing_width 		 = !empty($args['listing_width']) ? $args['listing_width'] : '';
586 586
 	$with_pagination 	 = !empty($args['with_pagination']) ? true : false;
587 587
 	$event_type 	 	 = !empty($args['event_type']) ? $args['event_type'] : '';
588
-    $shortcode_content   = !empty($args['shortcode_content']) ? trim($args['shortcode_content']) : '';
589
-    $tags                = !empty($args['tags']) ? $args['tags'] : array();
590
-    /**
591
-     * Filter the content text displayed when no listings found.
592
-     *
593
-     * @since 1.6.0
594
-     *
595
-     * @param string $shortcode_content The shortcode content text.
596
-     * @param array $args Array of arguements to filter listings.
597
-     */
598
-    $shortcode_content = apply_filters('geodir_sc_gd_listings_not_found_content', $shortcode_content, $args);
588
+	$shortcode_content   = !empty($args['shortcode_content']) ? trim($args['shortcode_content']) : '';
589
+	$tags                = !empty($args['tags']) ? $args['tags'] : array();
590
+	/**
591
+	 * Filter the content text displayed when no listings found.
592
+	 *
593
+	 * @since 1.6.0
594
+	 *
595
+	 * @param string $shortcode_content The shortcode content text.
596
+	 * @param array $args Array of arguements to filter listings.
597
+	 */
598
+	$shortcode_content = apply_filters('geodir_sc_gd_listings_not_found_content', $shortcode_content, $args);
599 599
 		
600 600
 	$top_pagination 	 = $with_pagination && !empty($args['top_pagination']) ? true : false;
601 601
 	$bottom_pagination 	 = $with_pagination && !empty($args['bottom_pagination']) ? true : false;
@@ -607,92 +607,92 @@  discard block
 block discarded – undo
607 607
 	$pageno 	 		 = $geodir_ajax && !empty($args['pageno']) ? $args['pageno'] : 1;
608 608
 	
609 609
 	$query_args = array(
610
-        'posts_per_page' => $post_number,
611
-        'is_geodir_loop' => true,
612
-        'gd_location' => $add_location_filter,
613
-        'post_type' => $post_type,
614
-        'order_by' => $list_sort,
610
+		'posts_per_page' => $post_number,
611
+		'is_geodir_loop' => true,
612
+		'gd_location' => $add_location_filter,
613
+		'post_type' => $post_type,
614
+		'order_by' => $list_sort,
615 615
 		'pageno' => $pageno
616
-    );
616
+	);
617 617
 
618
-    if ($character_count >= 0) {
619
-        $query_args['excerpt_length'] = $character_count;
620
-    }
618
+	if ($character_count >= 0) {
619
+		$query_args['excerpt_length'] = $character_count;
620
+	}
621 621
     
622
-    if (!empty($args['post_author'])) {
623
-        $query_args['post_author'] = $args['post_author'];
624
-    }
622
+	if (!empty($args['post_author'])) {
623
+		$query_args['post_author'] = $args['post_author'];
624
+	}
625 625
 
626
-    if (!empty($args['show_featured_only'])) {
627
-        $query_args['show_featured_only'] = 1;
628
-    }
626
+	if (!empty($args['show_featured_only'])) {
627
+		$query_args['show_featured_only'] = 1;
628
+	}
629 629
 
630
-    if (!empty($args['show_special_only'])) {
631
-        $query_args['show_special_only'] = 1;
632
-    }
630
+	if (!empty($args['show_special_only'])) {
631
+		$query_args['show_special_only'] = 1;
632
+	}
633 633
 
634
-    if (!empty($args['with_pics_only'])) {
635
-        $query_args['with_pics_only'] = 0;
636
-        $query_args['featured_image_only'] = 1;
637
-    }
634
+	if (!empty($args['with_pics_only'])) {
635
+		$query_args['with_pics_only'] = 0;
636
+		$query_args['featured_image_only'] = 1;
637
+	}
638 638
 
639
-    if (!empty($args['with_videos_only'])) {
640
-        $query_args['with_videos_only'] = 1;
641
-    }
639
+	if (!empty($args['with_videos_only'])) {
640
+		$query_args['with_videos_only'] = 1;
641
+	}
642 642
     
643
-    if (!empty($args['show_favorites_only'])) {
644
-        $query_args['show_favorites_only'] = 1;
645
-        $query_args['favorites_by_user'] = !empty($args['favorites_by_user']) ? $args['favorites_by_user'] : 0;
646
-    }
647
-    $with_no_results = !empty($args['without_no_results']) ? false : true;
643
+	if (!empty($args['show_favorites_only'])) {
644
+		$query_args['show_favorites_only'] = 1;
645
+		$query_args['favorites_by_user'] = !empty($args['favorites_by_user']) ? $args['favorites_by_user'] : 0;
646
+	}
647
+	$with_no_results = !empty($args['without_no_results']) ? false : true;
648 648
 
649
-    if (!empty($category) && isset($category[0]) && $category[0] != '0') {
650
-        $category_taxonomy = geodir_get_taxonomies($post_type);
649
+	if (!empty($category) && isset($category[0]) && $category[0] != '0') {
650
+		$category_taxonomy = geodir_get_taxonomies($post_type);
651 651
 
652
-        ######### WPML #########
653
-        if (geodir_wpml_is_taxonomy_translated($category_taxonomy[0])) {
654
-            $category = gd_lang_object_ids($category, $category_taxonomy[0]);
655
-        }
656
-        ######### WPML #########
652
+		######### WPML #########
653
+		if (geodir_wpml_is_taxonomy_translated($category_taxonomy[0])) {
654
+			$category = gd_lang_object_ids($category, $category_taxonomy[0]);
655
+		}
656
+		######### WPML #########
657 657
 
658
-        $tax_query = array(
659
-            'taxonomy' => $category_taxonomy[0],
660
-            'field' => 'id',
661
-            'terms' => $category
662
-        );
658
+		$tax_query = array(
659
+			'taxonomy' => $category_taxonomy[0],
660
+			'field' => 'id',
661
+			'terms' => $category
662
+		);
663 663
 
664
-        $query_args['tax_query'] = array($tax_query);
665
-    }
664
+		$query_args['tax_query'] = array($tax_query);
665
+	}
666 666
     
667
-    if (!empty($tags)) {
668
-        // Clean tags
669
-        if (!is_array($tags)) {
670
-            $comma = _x(',', 'tag delimiter');
671
-            if ( ',' !== $comma ) {
672
-                $tags = str_replace($comma, ',', $tags);
673
-            }
674
-            $tags = explode(',', trim($tags, " \n\t\r\0\x0B,"));
675
-            $tags = array_map('trim', $tags);
676
-        }
667
+	if (!empty($tags)) {
668
+		// Clean tags
669
+		if (!is_array($tags)) {
670
+			$comma = _x(',', 'tag delimiter');
671
+			if ( ',' !== $comma ) {
672
+				$tags = str_replace($comma, ',', $tags);
673
+			}
674
+			$tags = explode(',', trim($tags, " \n\t\r\0\x0B,"));
675
+			$tags = array_map('trim', $tags);
676
+		}
677 677
         
678
-        if (!empty($tags)) {
679
-            $tag_query = array(
680
-                'taxonomy' => $post_type . '_tags',
681
-                'field' => 'name',
682
-                'terms' => $tags
683
-            );
684
-
685
-            if (!empty($query_args['tax_query'])) {
686
-                $query_args['tax_query'][] = $tag_query;
687
-            } else {
688
-                $query_args['tax_query'] = array($tag_query);
689
-            }
690
-        }
691
-    }
678
+		if (!empty($tags)) {
679
+			$tag_query = array(
680
+				'taxonomy' => $post_type . '_tags',
681
+				'field' => 'name',
682
+				'terms' => $tags
683
+			);
684
+
685
+			if (!empty($query_args['tax_query'])) {
686
+				$query_args['tax_query'][] = $tag_query;
687
+			} else {
688
+				$query_args['tax_query'] = array($tag_query);
689
+			}
690
+		}
691
+	}
692 692
 
693
-    global $gridview_columns_widget, $geodir_is_widget_listing;
693
+	global $gridview_columns_widget, $geodir_is_widget_listing;
694 694
 
695
-    if ($post_type == 'gd_event' && function_exists('geodir_event_get_widget_events')) {
695
+	if ($post_type == 'gd_event' && function_exists('geodir_event_get_widget_events')) {
696 696
 		global $geodir_event_widget_listview;
697 697
 		$geodir_event_widget_listview = true;
698 698
 		
@@ -707,16 +707,16 @@  discard block
 block discarded – undo
707 707
 		$widget_listings = $total_posts > 0 ? geodir_get_widget_listings($query_args) : array();
708 708
 	}
709 709
 	$current_gridview_columns_widget = $gridview_columns_widget;
710
-    $identifier = ' gd-wgt-pagi-' . mt_rand();
711
-    ob_start();
710
+	$identifier = ' gd-wgt-pagi-' . mt_rand();
711
+	ob_start();
712 712
 	if (!empty($widget_listings) || $with_no_results) {
713 713
 		if (!$geodir_ajax) {
714
-        /**
715
-         * Called before the shortcode [gd_listings] content is output.
716
-         *
717
-         * @since 1.0.0
718
-         */
719
-        do_action('geodir_before_sc_gd_listings');
714
+		/**
715
+		 * Called before the shortcode [gd_listings] content is output.
716
+		 *
717
+		 * @since 1.0.0
718
+		 */
719
+		do_action('geodir_before_sc_gd_listings');
720 720
 		?>
721 721
         <div class="geodir_locations geodir_location_listing geodir-sc-gd-listings <?php echo $identifier;?>">
722 722
             <?php if ($title != '') { ?>
@@ -727,63 +727,63 @@  discard block
 block discarded – undo
727 727
             <div class="gd-sc-loader">
728 728
                 <div class="gd-sc-content">
729 729
             <?php }
730
-            if (!(empty($widget_listings) && !empty($shortcode_content))) {
731
-                if (strstr($layout, 'gridview')) {
732
-                    $listing_view_exp = explode('_', $layout);
733
-                    $gridview_columns_widget = $layout;
734
-                    $layout = $listing_view_exp[0];
735
-                } else {
736
-                    $gridview_columns_widget = '';
737
-                }
738
-
739
-                /**
740
-                 * Filter the widget listing listview template.
741
-                 *
742
-                 * @since 1.0.0
743
-                 *
744
-                 * @param string The template file to display listing.
745
-                 */
746
-                $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
730
+			if (!(empty($widget_listings) && !empty($shortcode_content))) {
731
+				if (strstr($layout, 'gridview')) {
732
+					$listing_view_exp = explode('_', $layout);
733
+					$gridview_columns_widget = $layout;
734
+					$layout = $listing_view_exp[0];
735
+				} else {
736
+					$gridview_columns_widget = '';
737
+				}
738
+
739
+				/**
740
+				 * Filter the widget listing listview template.
741
+				 *
742
+				 * @since 1.0.0
743
+				 *
744
+				 * @param string The template file to display listing.
745
+				 */
746
+				$template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
747 747
                             
748
-                global $post, $map_jason, $map_canvas_arr, $gd_session;
749
-
750
-                $current_post = $post;
751
-                $current_map_jason = $map_jason;
752
-                $current_map_canvas_arr = $map_canvas_arr;
753
-                $geodir_is_widget_listing = true;
754
-                $gd_session->un_set('gd_listing_view');
755
-
756
-                if ($with_pagination && $top_pagination) {				
757
-                    echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno);
758
-                }
759
-
760
-                /**
761
-                 * Includes listing listview template.
762
-                 *
763
-                 * @since 1.0.0
764
-                 */
765
-                include($template);
748
+				global $post, $map_jason, $map_canvas_arr, $gd_session;
749
+
750
+				$current_post = $post;
751
+				$current_map_jason = $map_jason;
752
+				$current_map_canvas_arr = $map_canvas_arr;
753
+				$geodir_is_widget_listing = true;
754
+				$gd_session->un_set('gd_listing_view');
755
+
756
+				if ($with_pagination && $top_pagination) {				
757
+					echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno);
758
+				}
759
+
760
+				/**
761
+				 * Includes listing listview template.
762
+				 *
763
+				 * @since 1.0.0
764
+				 */
765
+				include($template);
766 766
                 
767
-                if ($with_pagination && $bottom_pagination) {				
768
-                    echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno);
769
-                }
770
-
771
-                $geodir_is_widget_listing = false;
772
-
773
-                $GLOBALS['post'] = $current_post;
774
-                if (!empty($current_post)) {
775
-                    setup_postdata($current_post);
776
-                }
777
-                $map_jason = $current_map_jason;
778
-                $map_canvas_arr = $current_map_canvas_arr;
779
-                global $gridview_columns_widget;
780
-                $gridview_columns_widget = $current_gridview_columns_widget;
781
-            } else {
782
-                echo $shortcode_content;
783
-            }
767
+				if ($with_pagination && $bottom_pagination) {				
768
+					echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno);
769
+				}
770
+
771
+				$geodir_is_widget_listing = false;
772
+
773
+				$GLOBALS['post'] = $current_post;
774
+				if (!empty($current_post)) {
775
+					setup_postdata($current_post);
776
+				}
777
+				$map_jason = $current_map_jason;
778
+				$map_canvas_arr = $current_map_canvas_arr;
779
+				global $gridview_columns_widget;
780
+				$gridview_columns_widget = $current_gridview_columns_widget;
781
+			} else {
782
+				echo $shortcode_content;
783
+			}
784 784
 			?>
785 785
 			<?php
786
-            if (!$geodir_ajax) { 
786
+			if (!$geodir_ajax) { 
787 787
 			?>
788 788
             </div><p class="geodir-sclisting-loading" style="display:none;"><i class="fa fa-cog fa-spin"></i></p></div>
789 789
 <script type="text/javascript">
@@ -822,10 +822,10 @@  discard block
 block discarded – undo
822 822
             loading.hide();
823 823
             jQuery(items).html(response);
824 824
             <?php
825
-              /**
826
-               * if lazyload images enabled then refresh them once ajax page changed.
827
-               */
828
-              if (get_option('geodir_lazy_load', 1)) { ?>
825
+			  /**
826
+			   * if lazyload images enabled then refresh them once ajax page changed.
827
+			   */
828
+			  if (get_option('geodir_lazy_load', 1)) { ?>
829 829
               geodir_init_lazy_load();
830 830
               <?php } ?>
831 831
         }
@@ -836,11 +836,11 @@  discard block
 block discarded – undo
836 836
 </div>
837 837
 		<?php } ?>
838 838
     <?php
839
-    }
839
+	}
840 840
 	$output = ob_get_contents();
841
-    ob_end_clean();
841
+	ob_end_clean();
842 842
 
843
-    return trim($output);
843
+	return trim($output);
844 844
 }
845 845
 
846 846
 /**
@@ -867,15 +867,15 @@  discard block
 block discarded – undo
867 867
  * @return string Listings pagination HTML content.
868 868
  */
869 869
 function geodir_sc_listings_pagination($total_posts, $posts_per_page, $pageno, $before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) {
870
-    if (empty($prelabel)) {
871
-        $prelabel = '<strong>&laquo;</strong>';
872
-    }
870
+	if (empty($prelabel)) {
871
+		$prelabel = '<strong>&laquo;</strong>';
872
+	}
873 873
 
874
-    if (empty($nxtlabel)) {
875
-        $nxtlabel = '<strong>&raquo;</strong>';
876
-    }
874
+	if (empty($nxtlabel)) {
875
+		$nxtlabel = '<strong>&raquo;</strong>';
876
+	}
877 877
 
878
-    $half_pages_to_show = round($pages_to_show / 2);
878
+	$half_pages_to_show = round($pages_to_show / 2);
879 879
 
880 880
 	$numposts = $total_posts;
881 881
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 		}
909 909
 		
910 910
 		if (($pageno - 1) > 0) {
911
-            echo '<a class="gd-page-sc-prev gd-wgt-page" data-page="' . (int)($pageno - 1) . '" href="javascript:void(0);">' . $prelabel . '</a>&nbsp;';
911
+			echo '<a class="gd-page-sc-prev gd-wgt-page" data-page="' . (int)($pageno - 1) . '" href="javascript:void(0);">' . $prelabel . '</a>&nbsp;';
912 912
 		}
913 913
 		
914 914
 		for ($i = $pageno - $half_pages_to_show; $i <= $pageno + $half_pages_to_show; $i++) {
@@ -931,9 +931,9 @@  discard block
 block discarded – undo
931 931
 		echo "</div> $after </div>";
932 932
 	}
933 933
 	$output = ob_get_contents();
934
-    ob_end_clean();
934
+	ob_end_clean();
935 935
 
936
-    return trim($output);
936
+	return trim($output);
937 937
 }
938 938
 
939 939
 /**
@@ -944,10 +944,10 @@  discard block
 block discarded – undo
944 944
  * @return string Listings HTML content.
945 945
  */
946 946
 function geodir_sclistings_callback() {
947
-    check_ajax_referer('geodir-sclistings-nonce', 'geodir_sclistings_nonce');
948
-    //set variables
949
-    $scatts = isset($_POST['scatts']) ? $_POST['scatts'] : NULL;
950
-    $pageno = isset($_POST['pageno']) ? absint($_POST['pageno']) : 1;
947
+	check_ajax_referer('geodir-sclistings-nonce', 'geodir_sclistings_nonce');
948
+	//set variables
949
+	$scatts = isset($_POST['scatts']) ? $_POST['scatts'] : NULL;
950
+	$pageno = isset($_POST['pageno']) ? absint($_POST['pageno']) : 1;
951 951
 	
952 952
 	$shortcode_atts = !empty($scatts) ? (array)json_decode(stripslashes_deep($scatts)) : NULL;
953 953
 	
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 	} else {
960 960
 		echo 0;
961 961
 	}
962
-    wp_die();
962
+	wp_die();
963 963
 }
964 964
 add_action('wp_ajax_geodir_sclistings', 'geodir_sclistings_callback');
965 965
 add_action('wp_ajax_nopriv_geodir_sclistings', 'geodir_sclistings_callback');
966 966
\ No newline at end of file
Please login to merge, or discard this patch.