Test Failed
Pull Request — master (#397)
by Kiran
21:46
created
geodirectory-functions/custom_functions.php 1 patch
Spacing   +706 added lines, -706 removed lines patch added patch discarded remove patch
@@ -52,31 +52,31 @@  discard block
 block discarded – undo
52 52
 				jQuery(listSel).children('li').switchClass('gridview_onehalf gridview_onethird gridview_onefourth', 'gridview_onefifth', 600);
53 53
 			}
54 54
 
55
-			jQuery.post("<?php echo geodir_get_ajax_url();?>&gd_listing_view=" + val, function (data) {
55
+			jQuery.post("<?php echo geodir_get_ajax_url(); ?>&gd_listing_view=" + val, function (data) {
56 56
 				//alert(data );
57 57
 			});
58 58
 		}
59 59
 	</script>
60 60
 	<div class="geodir-list-view-select">
61 61
 		<select name="gd_list_view" id="gd_list_view" onchange="geodir_list_view_select(this);">
62
-			<?php $listing_view = (int) $gd_session->get( 'gd_listing_view' ); ?>
63
-			<option value=""><?php _e( 'View:', 'geodirectory' ); ?></option>
62
+			<?php $listing_view = (int) $gd_session->get('gd_listing_view'); ?>
63
+			<option value=""><?php _e('View:', 'geodirectory'); ?></option>
64 64
 			<option
65
-				value="1" <?php selected( 1, $listing_view ); ?>><?php _e( 'View: List', 'geodirectory' ); ?></option>
65
+				value="1" <?php selected(1, $listing_view); ?>><?php _e('View: List', 'geodirectory'); ?></option>
66 66
 			<option
67
-				value="2" <?php selected( 2, $listing_view ); ?>><?php _e( 'View: Grid 2', 'geodirectory' ); ?></option>
67
+				value="2" <?php selected(2, $listing_view); ?>><?php _e('View: Grid 2', 'geodirectory'); ?></option>
68 68
 			<option
69
-				value="3" <?php selected( 3, $listing_view ); ?>><?php _e( 'View: Grid 3', 'geodirectory' ); ?></option>
69
+				value="3" <?php selected(3, $listing_view); ?>><?php _e('View: Grid 3', 'geodirectory'); ?></option>
70 70
 			<option
71
-				value="4" <?php selected( 4, $listing_view ); ?>><?php _e( 'View: Grid 4', 'geodirectory' ); ?></option>
71
+				value="4" <?php selected(4, $listing_view); ?>><?php _e('View: Grid 4', 'geodirectory'); ?></option>
72 72
 			<option
73
-				value="5" <?php selected( 5, $listing_view ); ?>><?php _e( 'View: Grid 5', 'geodirectory' ); ?></option>
73
+				value="5" <?php selected(5, $listing_view); ?>><?php _e('View: Grid 5', 'geodirectory'); ?></option>
74 74
 		</select>
75 75
 	</div>
76 76
 	<?php
77 77
 }
78 78
 
79
-add_action( 'geodir_before_listing', 'geodir_list_view_select', 100 );
79
+add_action('geodir_before_listing', 'geodir_list_view_select', 100);
80 80
 
81 81
 /**
82 82
  * Limit the listing excerpt.
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
  * @global object $post          The current post object.
92 92
  * @return string The modified excerpt.
93 93
  */
94
-function geodir_max_excerpt( $charlength ) {
94
+function geodir_max_excerpt($charlength) {
95 95
 	global $post;
96
-	if ( $charlength == '0' ) {
96
+	if ($charlength == '0') {
97 97
 		return;
98 98
 	}
99 99
 	$out = '';
@@ -101,46 +101,46 @@  discard block
 block discarded – undo
101 101
 	$temp_post = $post;
102 102
 	$excerpt   = get_the_excerpt();
103 103
 
104
-	$charlength ++;
105
-	$excerpt_more = function_exists( 'geodirf_excerpt_more' ) ? geodirf_excerpt_more( '' ) : geodir_excerpt_more( '' );
106
-	if ( geodir_utf8_strlen( $excerpt ) > $charlength ) {
107
-		if ( geodir_utf8_strlen( $excerpt_more ) > 0 && geodir_utf8_strpos( $excerpt, $excerpt_more ) !== false ) {
108
-			$excut = - ( geodir_utf8_strlen( $excerpt_more ) );
109
-			$subex = geodir_utf8_substr( $excerpt, 0, $excut );
110
-			if ( $charlength > 0 && geodir_utf8_strlen( $subex ) > $charlength ) {
111
-				$subex = geodir_utf8_substr( $subex, 0, $charlength );
104
+	$charlength++;
105
+	$excerpt_more = function_exists('geodirf_excerpt_more') ? geodirf_excerpt_more('') : geodir_excerpt_more('');
106
+	if (geodir_utf8_strlen($excerpt) > $charlength) {
107
+		if (geodir_utf8_strlen($excerpt_more) > 0 && geodir_utf8_strpos($excerpt, $excerpt_more) !== false) {
108
+			$excut = - (geodir_utf8_strlen($excerpt_more));
109
+			$subex = geodir_utf8_substr($excerpt, 0, $excut);
110
+			if ($charlength > 0 && geodir_utf8_strlen($subex) > $charlength) {
111
+				$subex = geodir_utf8_substr($subex, 0, $charlength);
112 112
 			}
113 113
 			$out .= $subex;
114 114
 		} else {
115
-			$subex   = geodir_utf8_substr( $excerpt, 0, $charlength - 5 );
116
-			$exwords = explode( ' ', $subex );
117
-			$excut   = - ( geodir_utf8_strlen( $exwords[ count( $exwords ) - 1 ] ) );
118
-			if ( $excut < 0 ) {
119
-				$out .= geodir_utf8_substr( $subex, 0, $excut );
115
+			$subex   = geodir_utf8_substr($excerpt, 0, $charlength - 5);
116
+			$exwords = explode(' ', $subex);
117
+			$excut   = - (geodir_utf8_strlen($exwords[count($exwords) - 1]));
118
+			if ($excut < 0) {
119
+				$out .= geodir_utf8_substr($subex, 0, $excut);
120 120
 			} else {
121 121
 				$out .= $subex;
122 122
 			}
123 123
 		}
124
-		$out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
124
+		$out .= ' <a class="excerpt-read-more" href="'.get_permalink().'" title="'.get_the_title().'">';
125 125
 		/**
126 126
 		 * Filter excerpt read more text.
127 127
 		 *
128 128
 		 * @since 1.0.0
129 129
 		 */
130
-		$out .= apply_filters( 'geodir_max_excerpt_end', __( 'Read more [...]', 'geodirectory' ) );
130
+		$out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
131 131
 		$out .= '</a>';
132 132
 
133 133
 	} else {
134
-		if ( geodir_utf8_strlen( $excerpt_more ) > 0 && geodir_utf8_strpos( $excerpt, $excerpt_more ) !== false ) {
135
-			$excut = - ( geodir_utf8_strlen( $excerpt_more ) );
136
-			$out .= geodir_utf8_substr( $excerpt, 0, $excut );
137
-			$out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
134
+		if (geodir_utf8_strlen($excerpt_more) > 0 && geodir_utf8_strpos($excerpt, $excerpt_more) !== false) {
135
+			$excut = - (geodir_utf8_strlen($excerpt_more));
136
+			$out .= geodir_utf8_substr($excerpt, 0, $excut);
137
+			$out .= ' <a class="excerpt-read-more" href="'.get_permalink().'" title="'.get_the_title().'">';
138 138
 			/**
139 139
 			 * Filter excerpt read more text.
140 140
 			 *
141 141
 			 * @since 1.0.0
142 142
 			 */
143
-			$out .= apply_filters( 'geodir_max_excerpt_end', __( 'Read more [...]', 'geodirectory' ) );
143
+			$out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
144 144
 			$out .= '</a>';
145 145
 		} else {
146 146
 			$out .= $excerpt;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @return object Returns filtered package info as an object.
165 165
  */
166
-function geodir_post_package_info( $package_info, $post = '', $post_type = '' ) {
166
+function geodir_post_package_info($package_info, $post = '', $post_type = '') {
167 167
 	$package_info['pid']              = 0;
168 168
 	$package_info['days']             = 0;
169 169
 	$package_info['amount']           = 0;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @param object|string $post  The post object.
193 193
 	 * @param string $post_type    The post type.
194 194
 	 */
195
-	return (object) apply_filters( 'geodir_post_package_info', $package_info, $post, $post_type );
195
+	return (object) apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
196 196
 
197 197
 }
198 198
 
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
  *
221 221
  * }
222 222
  */
223
-function geodir_send_inquiry( $request ) {
223
+function geodir_send_inquiry($request) {
224 224
 	global $wpdb;
225 225
 
226 226
 	// strip slashes from text
227
-	$request = ! empty( $request ) ? stripslashes_deep( $request ) : $request;
227
+	$request = !empty($request) ? stripslashes_deep($request) : $request;
228 228
 
229 229
 	$yourname      = $request['inq_name'];
230 230
 	$youremail     = $request['inq_email'];
@@ -235,26 +235,26 @@  discard block
 block discarded – undo
235 235
 	$author_id  = '';
236 236
 	$post_title = '';
237 237
 
238
-	if ( $request['pid'] ) {
238
+	if ($request['pid']) {
239 239
 
240 240
 		$productinfosql = $wpdb->prepare(
241 241
 			"select ID,post_author,post_title from $wpdb->posts where ID =%d",
242
-			array( $request['pid'] )
242
+			array($request['pid'])
243 243
 		);
244
-		$productinfo    = $wpdb->get_row( $productinfosql );
244
+		$productinfo = $wpdb->get_row($productinfosql);
245 245
 
246 246
 		$author_id  = $productinfo->post_author;
247 247
 		$post_title = $productinfo->post_title;
248 248
 	}
249 249
 
250
-	$post_title = '<a href="' . get_permalink( $pid ) . '">' . $post_title . '</a>';
250
+	$post_title = '<a href="'.get_permalink($pid).'">'.$post_title.'</a>';
251 251
 
252
-	$user_info = get_userdata( $author_id );
253
-	$to_email  = geodir_get_post_meta( $pid, 'geodir_email', true );
254
-	$to_name   = geodir_get_client_name( $author_id );
252
+	$user_info = get_userdata($author_id);
253
+	$to_email  = geodir_get_post_meta($pid, 'geodir_email', true);
254
+	$to_name   = geodir_get_client_name($author_id);
255 255
 
256
-	if ( $to_email == '' ) {
257
-		$to_email = get_option( 'admin_email' );
256
+	if ($to_email == '') {
257
+		$to_email = get_option('admin_email');
258 258
 	}
259 259
 
260 260
 	/**
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 	 * }
276 276
 	 * @param string $type     The form type, default: `Enquiry`.
277 277
 	 */
278
-	do_action( 'geodir_after_send_enquiry', $request, 'Enquiry' );
278
+	do_action('geodir_after_send_enquiry', $request, 'Enquiry');
279 279
 
280 280
 	$client_message = $frnd_comments;
281
-	$client_message .= '<br>' . __( 'From :', 'geodirectory' ) . ' ' . $yourname . '<br>' . __( 'Phone :', 'geodirectory' ) . ' ' . $inq_phone . '<br>' . __( 'Email :', 'geodirectory' ) . ' ' . $youremail . '<br><br>' . __( 'Sent from', 'geodirectory' ) . ' - <b><a href="' . trailingslashit( home_url() ) . '">' . get_option( 'blogname' ) . '</a></b>.';
281
+	$client_message .= '<br>'.__('From :', 'geodirectory').' '.$yourname.'<br>'.__('Phone :', 'geodirectory').' '.$inq_phone.'<br>'.__('Email :', 'geodirectory').' '.$youremail.'<br><br>'.__('Sent from', 'geodirectory').' - <b><a href="'.trailingslashit(home_url()).'">'.get_option('blogname').'</a></b>.';
282 282
 	/**
283 283
 	 * Filter client message text.
284 284
 	 *
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 *
287 287
 	 * @param string $client_message Client message text.
288 288
 	 */
289
-	$client_message = apply_filters( 'geodir_inquiry_email_msg', $client_message );
289
+	$client_message = apply_filters('geodir_inquiry_email_msg', $client_message);
290 290
 
291 291
 	/**
292 292
 	 * Called before the send enquiry email is sent.
@@ -305,12 +305,12 @@  discard block
 block discarded – undo
305 305
 	 *
306 306
 	 * }
307 307
 	 */
308
-	do_action( 'geodir_before_send_enquiry_email', $request );
309
-	if ( $to_email ) {
308
+	do_action('geodir_before_send_enquiry_email', $request);
309
+	if ($to_email) {
310 310
 		// strip slashes message
311
-		$client_message = stripslashes_deep( $client_message );
311
+		$client_message = stripslashes_deep($client_message);
312 312
 
313
-		geodir_sendEmail( $youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid'] );//To client email
313
+		geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']); //To client email
314 314
 	}
315 315
 
316 316
 	/**
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * }
332 332
 	 */
333
-	do_action( 'geodir_after_send_enquiry_email', $request );
334
-	$url = get_permalink( $pid );
335
-	if ( strstr( $url, '?' ) ) {
336
-		$url = $url . "&send_inquiry=success";
333
+	do_action('geodir_after_send_enquiry_email', $request);
334
+	$url = get_permalink($pid);
335
+	if (strstr($url, '?')) {
336
+		$url = $url."&send_inquiry=success";
337 337
 	} else {
338
-		$url = $url . "?send_inquiry=success";
338
+		$url = $url."?send_inquiry=success";
339 339
 	}
340 340
 	/**
341 341
 	 * Filter redirect url after the send enquiry email is sent.
@@ -344,8 +344,8 @@  discard block
 block discarded – undo
344 344
 	 *
345 345
 	 * @param string $url Redirect url.
346 346
 	 */
347
-	$url = apply_filters( 'geodir_send_enquiry_after_submit_redirect', $url );
348
-	wp_redirect( $url );
347
+	$url = apply_filters('geodir_send_enquiry_after_submit_redirect', $url);
348
+	wp_redirect($url);
349 349
 	gd_die();
350 350
 
351 351
 }
@@ -374,11 +374,11 @@  discard block
 block discarded – undo
374 374
  * }
375 375
  * @global object $wpdb        WordPress Database object.
376 376
  */
377
-function geodir_send_friend( $request ) {
377
+function geodir_send_friend($request) {
378 378
 	global $wpdb;
379 379
 
380 380
 	// strip slashes from text
381
-	$request = ! empty( $request ) ? stripslashes_deep( $request ) : $request;
381
+	$request = !empty($request) ? stripslashes_deep($request) : $request;
382 382
 
383 383
 	$yourname      = $request['yourname'];
384 384
 	$youremail     = $request['youremail'];
@@ -387,13 +387,13 @@  discard block
 block discarded – undo
387 387
 	$pid           = $request['pid'];
388 388
 	$to_email      = $request['to_email'];
389 389
 	$to_name       = $request['to_name'];
390
-	if ( $request['pid'] ) {
390
+	if ($request['pid']) {
391 391
 		$productinfosql = $wpdb->prepare(
392 392
 			"select ID,post_title from $wpdb->posts where ID =%d",
393
-			array( $request['pid'] )
393
+			array($request['pid'])
394 394
 		);
395
-		$productinfo    = $wpdb->get_results( $productinfosql );
396
-		foreach ( $productinfo as $productinfoObj ) {
395
+		$productinfo = $wpdb->get_results($productinfosql);
396
+		foreach ($productinfo as $productinfoObj) {
397 397
 			$post_title = $productinfoObj->post_title;
398 398
 		}
399 399
 	}
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
 	 *
418 418
 	 * }
419 419
 	 */
420
-	do_action( 'geodir_before_send_to_friend_email', $request );
421
-	geodir_sendEmail( $youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid'] );//To client email
420
+	do_action('geodir_before_send_to_friend_email', $request);
421
+	geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']); //To client email
422 422
 
423 423
 	/**
424 424
 	 * Called after the send to friend email is sent.
@@ -439,13 +439,13 @@  discard block
 block discarded – undo
439 439
 	 *
440 440
 	 * }
441 441
 	 */
442
-	do_action( 'geodir_after_send_to_friend_email', $request );
442
+	do_action('geodir_after_send_to_friend_email', $request);
443 443
 
444
-	$url = get_permalink( $pid );
445
-	if ( strstr( $url, '?' ) ) {
446
-		$url = $url . "&sendtofrnd=success";
444
+	$url = get_permalink($pid);
445
+	if (strstr($url, '?')) {
446
+		$url = $url."&sendtofrnd=success";
447 447
 	} else {
448
-		$url = $url . "?sendtofrnd=success";
448
+		$url = $url."?sendtofrnd=success";
449 449
 	}
450 450
 	/**
451 451
 	 * Filter redirect url after the send to friend email is sent.
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	 *
455 455
 	 * @param string $url Redirect url.
456 456
 	 */
457
-	$url = apply_filters( 'geodir_send_to_friend_after_submit_redirect', $url );
458
-	wp_redirect( $url );
457
+	$url = apply_filters('geodir_send_to_friend_after_submit_redirect', $url);
458
+	wp_redirect($url);
459 459
 	gd_die();
460 460
 }
461 461
 
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
  *
470 470
  * @param string $hash_key
471 471
  */
472
-function geodir_before_tab_content( $hash_key ) {
473
-	switch ( $hash_key ) {
472
+function geodir_before_tab_content($hash_key) {
473
+	switch ($hash_key) {
474 474
 		case 'post_info' :
475 475
 			echo '<div class="geodir-company_info field-group">';
476 476
 			break;
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 			 *
481 481
 			 * @since 1.0.0
482 482
 			 */
483
-			echo ' <div id="' . apply_filters( 'geodir_post_gallery_id', 'geodir-post-gallery' ) . '" class="clearfix" >';
483
+			echo ' <div id="'.apply_filters('geodir_post_gallery_id', 'geodir-post-gallery').'" class="clearfix" >';
484 484
 			break;
485 485
 		case 'reviews' :
486 486
 			echo '<div id="reviews-wrap" class="clearfix"> ';
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
  *
505 505
  * @param string $hash_key
506 506
  */
507
-function geodir_after_tab_content( $hash_key ) {
508
-	switch ( $hash_key ) {
507
+function geodir_after_tab_content($hash_key) {
508
+	switch ($hash_key) {
509 509
 		case 'post_info' :
510 510
 			echo '</div>';
511 511
 			break;
@@ -536,25 +536,25 @@  discard block
 block discarded – undo
536 536
  * @global object $wpdb     WordPress Database object.
537 537
  * @return bool|null|string Returns default sort results, when the post type is valid. Otherwise returns false.
538 538
  */
539
-function geodir_get_posts_default_sort( $post_type ) {
539
+function geodir_get_posts_default_sort($post_type) {
540 540
 
541 541
 	global $wpdb;
542 542
 
543
-	if ( $post_type != '' ) {
543
+	if ($post_type != '') {
544 544
 
545 545
 		$all_postypes = geodir_get_posttypes();
546 546
 
547
-		if ( ! in_array( $post_type, $all_postypes ) ) {
547
+		if (!in_array($post_type, $all_postypes)) {
548 548
 			return false;
549 549
 		}
550 550
 
551
-		$sort_field_info = $wpdb->get_var( $wpdb->prepare( "select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where	post_type= %s and is_active=%d and is_default=%d", array(
551
+		$sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." where	post_type= %s and is_active=%d and is_default=%d", array(
552 552
 			$post_type,
553 553
 			1,
554 554
 			1
555
-		) ) );
555
+		)));
556 556
 
557
-		if ( ! empty( $sort_field_info ) ) {
557
+		if (!empty($sort_field_info)) {
558 558
 			return $sort_field_info;
559 559
 		}
560 560
 
@@ -574,20 +574,20 @@  discard block
 block discarded – undo
574 574
  * @global object $wpdb     WordPress Database object.
575 575
  * @return bool|mixed|void Returns sort results, when the post type is valid. Otherwise returns false.
576 576
  */
577
-function geodir_get_sort_options( $post_type ) {
577
+function geodir_get_sort_options($post_type) {
578 578
 	global $wpdb;
579 579
 
580
-	if ( $post_type != '' ) {
580
+	if ($post_type != '') {
581 581
 		$all_postypes = geodir_get_posttypes();
582 582
 
583
-		if ( ! in_array( $post_type, $all_postypes ) ) {
583
+		if (!in_array($post_type, $all_postypes)) {
584 584
 			return false;
585 585
 		}
586 586
 
587
-		$sort_field_info = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array(
587
+		$sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array(
588 588
 			$post_type,
589 589
 			1
590
-		) ) );
590
+		)));
591 591
 
592 592
 		/**
593 593
 		 * Filter post sort options.
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 		 * @param array $sort_field_info Unfiltered sort field array.
598 598
 		 * @param string $post_type      Post type.
599 599
 		 */
600
-		return apply_filters( 'geodir_get_sort_options', $sort_field_info, $post_type );
600
+		return apply_filters('geodir_get_sort_options', $sort_field_info, $post_type);
601 601
 	}
602 602
 
603 603
 }
@@ -618,63 +618,63 @@  discard block
 block discarded – undo
618 618
 	 *
619 619
 	 * @since 1.4.4
620 620
 	 */
621
-	if ( is_search() ) {
621
+	if (is_search()) {
622 622
 		return;
623 623
 	}
624 624
 
625 625
 	$sort_by = '';
626 626
 
627
-	if ( isset( $_REQUEST['sort_by'] ) ) {
627
+	if (isset($_REQUEST['sort_by'])) {
628 628
 		$sort_by = $_REQUEST['sort_by'];
629 629
 	}
630 630
 
631 631
 	$gd_post_type = geodir_get_current_posttype();
632 632
 
633
-	$sort_options = geodir_get_sort_options( $gd_post_type );
633
+	$sort_options = geodir_get_sort_options($gd_post_type);
634 634
 
635 635
 
636 636
 	$sort_field_options = '';
637 637
 
638
-	if ( ! empty( $sort_options ) ) {
639
-		foreach ( $sort_options as $sort ) {
640
-			$sort = stripslashes_deep( $sort ); // strip slashes
638
+	if (!empty($sort_options)) {
639
+		foreach ($sort_options as $sort) {
640
+			$sort = stripslashes_deep($sort); // strip slashes
641 641
 
642
-			$label = __( $sort->site_title, 'geodirectory' );
642
+			$label = __($sort->site_title, 'geodirectory');
643 643
 
644
-			if ( $sort->field_type == 'random' ) {
644
+			if ($sort->field_type == 'random') {
645 645
 				$key = $sort->field_type;
646
-				( $sort_by == $key || ( $sort->is_default == '1' && ! isset( $_REQUEST['sort_by'] ) ) ) ? $selected = 'selected="selected"' : $selected = '';
647
-				$sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg( 'sort_by', $key ) ) . '">' . __( $label, 'geodirectory' ) . '</option>';
646
+				($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
647
+				$sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
648 648
 			}
649 649
 
650
-			if ( $sort->htmlvar_name == 'comment_count' ) {
650
+			if ($sort->htmlvar_name == 'comment_count') {
651 651
 				$sort->htmlvar_name = 'rating_count';
652 652
 			}
653 653
 
654
-			if ( $sort->sort_asc ) {
655
-				$key   = $sort->htmlvar_name . '_asc';
654
+			if ($sort->sort_asc) {
655
+				$key   = $sort->htmlvar_name.'_asc';
656 656
 				$label = $sort->site_title;
657
-				if ( $sort->asc_title ) {
657
+				if ($sort->asc_title) {
658 658
 					$label = $sort->asc_title;
659 659
 				}
660
-				( $sort_by == $key || ( $sort->is_default == '1' && $sort->default_order == $key && ! isset( $_REQUEST['sort_by'] ) ) ) ? $selected = 'selected="selected"' : $selected = '';
661
-				$sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg( 'sort_by', $key ) ) . '">' . __( $label, 'geodirectory' ) . '</option>';
660
+				($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
661
+				$sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
662 662
 			}
663 663
 
664
-			if ( $sort->sort_desc ) {
665
-				$key   = $sort->htmlvar_name . '_desc';
664
+			if ($sort->sort_desc) {
665
+				$key   = $sort->htmlvar_name.'_desc';
666 666
 				$label = $sort->site_title;
667
-				if ( $sort->desc_title ) {
667
+				if ($sort->desc_title) {
668 668
 					$label = $sort->desc_title;
669 669
 				}
670
-				( $sort_by == $key || ( $sort->is_default == '1' && $sort->default_order == $key && ! isset( $_REQUEST['sort_by'] ) ) ) ? $selected = 'selected="selected"' : $selected = '';
671
-				$sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg( 'sort_by', $key ) ) . '">' . __( $label, 'geodirectory' ) . '</option>';
670
+				($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
671
+				$sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
672 672
 			}
673 673
 
674 674
 		}
675 675
 	}
676 676
 
677
-	if ( $sort_field_options != '' ) {
677
+	if ($sort_field_options != '') {
678 678
 
679 679
 		?>
680 680
 
@@ -683,9 +683,9 @@  discard block
 block discarded – undo
683 683
 			<select name="sort_by" id="sort_by" onchange="javascript:window.location=this.value;">
684 684
 
685 685
 				<option
686
-					value="<?php echo esc_url( add_query_arg( 'sort_by', '' ) ); ?>" <?php if ( $sort_by == '' ) {
686
+					value="<?php echo esc_url(add_query_arg('sort_by', '')); ?>" <?php if ($sort_by == '') {
687 687
 					echo 'selected="selected"';
688
-				} ?>><?php _e( 'Sort By', 'geodirectory' ); ?></option><?php
688
+				} ?>><?php _e('Sort By', 'geodirectory'); ?></option><?php
689 689
 
690 690
 				echo $sort_field_options; ?>
691 691
 
@@ -713,9 +713,9 @@  discard block
 block discarded – undo
713 713
  *
714 714
  * @return string Returns the section title.
715 715
  */
716
-function geodir_advance_customfields_heading( $title, $field_type ) {
716
+function geodir_advance_customfields_heading($title, $field_type) {
717 717
 
718
-	if ( in_array( $field_type, array( 'multiselect', 'textarea', 'taxonomy' ) ) ) {
718
+	if (in_array($field_type, array('multiselect', 'textarea', 'taxonomy'))) {
719 719
 		$title = '';
720 720
 	}
721 721
 
@@ -737,19 +737,19 @@  discard block
 block discarded – undo
737 737
  * @global object $gd_session       GeoDirectory Session object.
738 738
  * @return string Returns related posts html.
739 739
  */
740
-function geodir_related_posts_display( $request ) {
741
-	if ( ! empty( $request ) ) {
742
-		$before_title = ( isset( $request['before_title'] ) && ! empty( $request['before_title'] ) ) ? $request['before_title'] : '';
743
-		$after_title  = ( isset( $request['after_title'] ) && ! empty( $request['after_title'] ) ) ? $request['after_title'] : '';
744
-
745
-		$title               = ( isset( $request['title'] ) && ! empty( $request['title'] ) ) ? $request['title'] : __( 'Related Listings', 'geodirectory' );
746
-		$post_number         = ( isset( $request['post_number'] ) && ! empty( $request['post_number'] ) ) ? $request['post_number'] : '5';
747
-		$relate_to           = ( isset( $request['relate_to'] ) && ! empty( $request['relate_to'] ) ) ? $request['relate_to'] : 'category';
748
-		$layout              = ( isset( $request['layout'] ) && ! empty( $request['layout'] ) ) ? $request['layout'] : 'gridview_onehalf';
749
-		$add_location_filter = ( isset( $request['add_location_filter'] ) && ! empty( $request['add_location_filter'] ) ) ? $request['add_location_filter'] : '0';
750
-		$listing_width       = ( isset( $request['listing_width'] ) && ! empty( $request['listing_width'] ) ) ? $request['listing_width'] : '';
751
-		$list_sort           = ( isset( $request['list_sort'] ) && ! empty( $request['list_sort'] ) ) ? $request['list_sort'] : 'latest';
752
-		$character_count     = ( isset( $request['character_count'] ) && ! empty( $request['character_count'] ) ) ? $request['character_count'] : '';
740
+function geodir_related_posts_display($request) {
741
+	if (!empty($request)) {
742
+		$before_title = (isset($request['before_title']) && !empty($request['before_title'])) ? $request['before_title'] : '';
743
+		$after_title  = (isset($request['after_title']) && !empty($request['after_title'])) ? $request['after_title'] : '';
744
+
745
+		$title               = (isset($request['title']) && !empty($request['title'])) ? $request['title'] : __('Related Listings', 'geodirectory');
746
+		$post_number         = (isset($request['post_number']) && !empty($request['post_number'])) ? $request['post_number'] : '5';
747
+		$relate_to           = (isset($request['relate_to']) && !empty($request['relate_to'])) ? $request['relate_to'] : 'category';
748
+		$layout              = (isset($request['layout']) && !empty($request['layout'])) ? $request['layout'] : 'gridview_onehalf';
749
+		$add_location_filter = (isset($request['add_location_filter']) && !empty($request['add_location_filter'])) ? $request['add_location_filter'] : '0';
750
+		$listing_width       = (isset($request['listing_width']) && !empty($request['listing_width'])) ? $request['listing_width'] : '';
751
+		$list_sort           = (isset($request['list_sort']) && !empty($request['list_sort'])) ? $request['list_sort'] : 'latest';
752
+		$character_count     = (isset($request['character_count']) && !empty($request['character_count'])) ? $request['character_count'] : '';
753 753
 
754 754
 		global $wpdb, $post, $gd_session, $related_nearest, $related_parent_lat, $related_parent_lon;
755 755
 		$related_parent_lat   = !empty($post->post_latitude) ? $post->post_latitude : '';
@@ -757,10 +757,10 @@  discard block
 block discarded – undo
757 757
 		$arr_detail_page_tabs = geodir_detail_page_tabs_list();
758 758
 
759 759
 		$related_listing_array = array();
760
-		if ( get_option( 'geodir_add_related_listing_posttypes' ) ) {
761
-			$related_listing_array = get_option( 'geodir_add_related_listing_posttypes' );
760
+		if (get_option('geodir_add_related_listing_posttypes')) {
761
+			$related_listing_array = get_option('geodir_add_related_listing_posttypes');
762 762
 		}
763
-		if ( isset($post->post_type) && in_array( $post->post_type, $related_listing_array ) ) {
763
+		if (isset($post->post_type) && in_array($post->post_type, $related_listing_array)) {
764 764
 			$arr_detail_page_tabs['related_listing']['is_display'] = true;
765 765
 		}
766 766
 
@@ -772,90 +772,90 @@  discard block
 block discarded – undo
772 772
 		$tax_field         = 'id';
773 773
 		$category          = array();
774 774
 
775
-		if ( isset( $_REQUEST['backandedit'] ) ) {
776
-			$post      = (object) $gd_session->get( 'listing' );
775
+		if (isset($_REQUEST['backandedit'])) {
776
+			$post      = (object) $gd_session->get('listing');
777 777
 			$post_type = $post->listing_type;
778
-			if ( isset( $_REQUEST['pid'] ) && $_REQUEST['pid'] != '' ) {
778
+			if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
779 779
 				$post_id = $_REQUEST['pid'];
780 780
 			}
781
-		} elseif ( isset( $_REQUEST['pid'] ) && $_REQUEST['pid'] != '' ) {
782
-			$post      = geodir_get_post_info( $_REQUEST['pid'] );
781
+		} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
782
+			$post      = geodir_get_post_info($_REQUEST['pid']);
783 783
 			$post_type = $post->post_type;
784 784
 			$post_id   = $_REQUEST['pid'];
785
-		} elseif ( isset( $post->post_type ) && $post->post_type != '' ) {
785
+		} elseif (isset($post->post_type) && $post->post_type != '') {
786 786
 			$post_type = $post->post_type;
787 787
 			$post_id   = $post->ID;
788 788
 		}
789 789
 
790
-		if ( $relate_to == 'category' ) {
790
+		if ($relate_to == 'category') {
791 791
 
792
-			$category_taxonomy = $post_type . $relate_to;
793
-			if ( isset( $post->{$category_taxonomy} ) && $post->{$category_taxonomy} != '' ) {
794
-				$category = explode( ',', trim( $post->{$category_taxonomy}, ',' ) );
792
+			$category_taxonomy = $post_type.$relate_to;
793
+			if (isset($post->{$category_taxonomy} ) && $post->{$category_taxonomy} != '') {
794
+				$category = explode(',', trim($post->{$category_taxonomy}, ','));
795 795
 			}
796 796
 
797
-		} elseif ( $relate_to == 'tags' ) {
797
+		} elseif ($relate_to == 'tags') {
798 798
 
799
-			$category_taxonomy = $post_type . '_' . $relate_to;
800
-			if ( $post->post_tags != '' ) {
801
-				$category = explode( ',', trim( $post->post_tags, ',' ) );
799
+			$category_taxonomy = $post_type.'_'.$relate_to;
800
+			if ($post->post_tags != '') {
801
+				$category = explode(',', trim($post->post_tags, ','));
802 802
 			}
803 803
 			$tax_field = 'name';
804 804
 		}
805 805
 
806 806
 		/* --- return false in invalid request --- */
807
-		if ( empty( $category ) ) {
807
+		if (empty($category)) {
808 808
 			return false;
809 809
 		}
810 810
 
811 811
 		$all_postypes = geodir_get_posttypes();
812 812
 
813
-		if ( ! in_array( $post_type, $all_postypes ) ) {
813
+		if (!in_array($post_type, $all_postypes)) {
814 814
 			return false;
815 815
 		}
816 816
 
817 817
 		/* --- return false in invalid request --- */
818 818
 
819 819
 		$location_url = '';
820
-		if ( $add_location_filter != '0' ) {
820
+		if ($add_location_filter != '0') {
821 821
 			$location_url             = array();
822
-			$geodir_show_location_url = get_option( 'geodir_show_location_url' );
822
+			$geodir_show_location_url = get_option('geodir_show_location_url');
823 823
 
824
-			$gd_city = get_query_var( 'gd_city' );
824
+			$gd_city = get_query_var('gd_city');
825 825
 
826
-			if ( $gd_city ) {
827
-				$gd_country = get_query_var( 'gd_country' );
828
-				$gd_region  = get_query_var( 'gd_region' );
826
+			if ($gd_city) {
827
+				$gd_country = get_query_var('gd_country');
828
+				$gd_region  = get_query_var('gd_region');
829 829
 			} else {
830 830
 				$location = geodir_get_default_location();
831 831
 
832
-				$gd_country = isset( $location->country_slug ) ? $location->country_slug : '';
833
-				$gd_region  = isset( $location->region_slug ) ? $location->region_slug : '';
834
-				$gd_city    = isset( $location->city_slug ) ? $location->city_slug : '';
832
+				$gd_country = isset($location->country_slug) ? $location->country_slug : '';
833
+				$gd_region  = isset($location->region_slug) ? $location->region_slug : '';
834
+				$gd_city    = isset($location->city_slug) ? $location->city_slug : '';
835 835
 			}
836 836
 
837
-			if ( $geodir_show_location_url == 'all' ) {
837
+			if ($geodir_show_location_url == 'all') {
838 838
 				$location_url[] = $gd_country;
839 839
 				$location_url[] = $gd_region;
840
-			} else if ( $geodir_show_location_url == 'country_city' ) {
840
+			} else if ($geodir_show_location_url == 'country_city') {
841 841
 				$location_url[] = $gd_country;
842
-			} else if ( $geodir_show_location_url == 'region_city' ) {
842
+			} else if ($geodir_show_location_url == 'region_city') {
843 843
 				$location_url[] = $gd_region;
844 844
 			}
845 845
 
846 846
 			$location_url[] = $gd_city;
847 847
 
848
-			$location_url = implode( '/', $location_url );
848
+			$location_url = implode('/', $location_url);
849 849
 		}
850 850
 
851 851
 
852
-		if ( ! empty( $category ) ) {
852
+		if (!empty($category)) {
853 853
 			global $geodir_add_location_url;
854 854
 			$geodir_add_location_url = '0';
855
-			if ( $add_location_filter != '0' ) {
855
+			if ($add_location_filter != '0') {
856 856
 				$geodir_add_location_url = '1';
857 857
 			}
858
-			$viewall_url             = get_term_link( (int) $category[0], $post_type . $category_taxonomy );
858
+			$viewall_url             = get_term_link((int) $category[0], $post_type.$category_taxonomy);
859 859
 			$geodir_add_location_url = null;
860 860
 		}
861 861
 		ob_start();
@@ -865,24 +865,24 @@  discard block
 block discarded – undo
865 865
 		<div class="geodir_locations geodir_location_listing">
866 866
 
867 867
 			<?php
868
-			if ( isset( $request['is_widget'] ) && $request['is_widget'] == '1' ) {
868
+			if (isset($request['is_widget']) && $request['is_widget'] == '1') {
869 869
 				/** geodir_before_title filter Documented in geodirectory_widgets.php */
870
-				$before_title = isset( $before_title ) ? $before_title : apply_filters( 'geodir_before_title', '<h3 class="widget-title">' );
870
+				$before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
871 871
 				/** geodir_after_title filter Documented in geodirectory_widgets.php */
872
-				$after_title = isset( $after_title ) ? $after_title : apply_filters( 'geodir_after_title', '</h3>' );
872
+				$after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
873 873
 				?>
874 874
 				<div class="location_list_heading clearfix">
875
-					<?php echo $before_title . $title . $after_title; ?>
875
+					<?php echo $before_title.$title.$after_title; ?>
876 876
 				</div>
877 877
 				<?php
878 878
 			}
879 879
 			$query_args = array(
880 880
 				'posts_per_page'   => $post_number,
881 881
 				'is_geodir_loop'   => true,
882
-				'gd_location'      => ( $add_location_filter ) ? true : false,
882
+				'gd_location'      => ($add_location_filter) ? true : false,
883 883
 				'post_type'        => $post_type,
884 884
 				'order_by'         => $list_sort,
885
-				'post__not_in'     => array( $post_id ),
885
+				'post__not_in'     => array($post_id),
886 886
 				'excerpt_length'   => $character_count,
887 887
 				'related_listings' => $is_display
888 888
 			);
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 				'terms'    => $category
894 894
 			);
895 895
 
896
-			$query_args['tax_query'] = array( $tax_query );
896
+			$query_args['tax_query'] = array($tax_query);
897 897
 
898 898
 			global $gridview_columns, $post;
899 899
 
@@ -905,21 +905,21 @@  discard block
 block discarded – undo
905 905
 			 * @param array $query_args The query array.
906 906
 			 * @param array $request Related posts request array.
907 907
 			 */
908
-			$query_args = apply_filters( 'geodir_related_posts_widget_query_args', $query_args, $request );
908
+			$query_args = apply_filters('geodir_related_posts_widget_query_args', $query_args, $request);
909 909
 
910
-			query_posts( $query_args );
910
+			query_posts($query_args);
911 911
 
912
-			if ( strstr( $layout, 'gridview' ) ) {
913
-				$listing_view_exp = explode( '_', $layout );
912
+			if (strstr($layout, 'gridview')) {
913
+				$listing_view_exp = explode('_', $layout);
914 914
 				$gridview_columns = $layout;
915 915
 				$layout           = $listing_view_exp[0];
916
-			} else if ( $layout == 'list' ) {
916
+			} else if ($layout == 'list') {
917 917
 				$gridview_columns = '';
918 918
 			}
919 919
 			$related_posts = true;
920 920
 
921 921
 			$related_nearest = false;
922
-			if ( $list_sort == 'nearest' ) {
922
+			if ($list_sort == 'nearest') {
923 923
 				$related_nearest = true;
924 924
 			}
925 925
 
@@ -929,14 +929,14 @@  discard block
 block discarded – undo
929 929
 			 *
930 930
 			 * @since 1.0.0
931 931
 			 */
932
-			$template = apply_filters( "geodir_template_part-related-listing-listview", geodir_locate_template( 'listing-listview' ) );
932
+			$template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
933 933
 
934 934
 			/**
935 935
 			 * Includes related listing listview template.
936 936
 			 *
937 937
 			 * @since 1.0.0
938 938
 			 */
939
-			include( $template );
939
+			include($template);
940 940
 
941 941
 			wp_reset_query();
942 942
 			$post            = $origi_post;
@@ -964,12 +964,12 @@  discard block
 block discarded – undo
964 964
 function geodir_category_count_script() {
965 965
 	global $geodir_post_category_str;
966 966
 
967
-	if ( ! empty( $geodir_post_category_str ) ) {
968
-		$geodir_post_category_str = serialize( $geodir_post_category_str );
967
+	if (!empty($geodir_post_category_str)) {
968
+		$geodir_post_category_str = serialize($geodir_post_category_str);
969 969
 	}
970 970
 
971
-	$all_var['post_category_array'] = html_entity_decode( (string) $geodir_post_category_str, ENT_QUOTES, 'UTF-8' );
972
-	$script                         = "var post_category_array = " . json_encode( $all_var ) . ';';
971
+	$all_var['post_category_array'] = html_entity_decode((string) $geodir_post_category_str, ENT_QUOTES, 'UTF-8');
972
+	$script                         = "var post_category_array = ".json_encode($all_var).';';
973 973
 	echo '<script>';
974 974
 	echo $script;
975 975
 	echo '</script>';
@@ -984,8 +984,8 @@  discard block
 block discarded – undo
984 984
  * @return string Returns the default language.
985 985
  */
986 986
 function geodir_get_map_default_language() {
987
-	$geodir_default_map_language = get_option( 'geodir_default_map_language' );
988
-	if ( empty( $geodir_default_map_language ) ) {
987
+	$geodir_default_map_language = get_option('geodir_default_map_language');
988
+	if (empty($geodir_default_map_language)) {
989 989
 		$geodir_default_map_language = 'en';
990 990
 	}
991 991
 
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 	 *
997 997
 	 * @param string $geodir_default_map_language Default map language.
998 998
 	 */
999
-	return apply_filters( 'geodir_default_map_language', $geodir_default_map_language );
999
+	return apply_filters('geodir_default_map_language', $geodir_default_map_language);
1000 1000
 }
1001 1001
 
1002 1002
 /**
@@ -1007,7 +1007,7 @@  discard block
 block discarded – undo
1007 1007
  * @return string Returns the api key.
1008 1008
  */
1009 1009
 function geodir_get_map_api_key() {
1010
-	$key = get_option( 'geodir_google_api_key' );
1010
+	$key = get_option('geodir_google_api_key');
1011 1011
 
1012 1012
 	/**
1013 1013
 	 * Filter Google maps api key.
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
 	 *
1017 1017
 	 * @param string $key Google maps api key.
1018 1018
 	 */
1019
-	return apply_filters( 'geodir_google_api_key', $key );
1019
+	return apply_filters('geodir_google_api_key', $key);
1020 1020
 }
1021 1021
 
1022 1022
 
@@ -1036,20 +1036,20 @@  discard block
 block discarded – undo
1036 1036
 	global $wp, $post, $wp_query, $wpdb, $geodir_addon_list;
1037 1037
 
1038 1038
 	$is_geodir_page = geodir_is_geodir_page();
1039
-	if ( ! $is_geodir_page ) {
1039
+	if (!$is_geodir_page) {
1040 1040
 		return;
1041 1041
 	}// if non GD page, bail
1042 1042
 
1043 1043
 	$use_gd_meta = true;
1044
-	if ( ( class_exists( 'WPSEO_Frontend' ) || class_exists( 'All_in_One_SEO_Pack' ) ) && !geodir_disable_yoast_seo_metas() ) {
1044
+	if ((class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) && !geodir_disable_yoast_seo_metas()) {
1045 1045
 		$use_gd_meta = false;
1046 1046
 
1047
-		if ( geodir_is_page( 'search' ) ) {
1047
+		if (geodir_is_page('search')) {
1048 1048
 			$use_gd_meta = true;
1049 1049
 		}
1050 1050
 	}
1051 1051
 
1052
-	if ( ! $use_gd_meta ) {
1052
+	if (!$use_gd_meta) {
1053 1053
 		return;
1054 1054
 	}// bail if Yoast Wordpress SEO or All_in_One_SEO_Pack active.
1055 1055
 
@@ -1057,170 +1057,170 @@  discard block
 block discarded – undo
1057 1057
 
1058 1058
 	$all_postypes = geodir_get_posttypes();
1059 1059
 
1060
-	$geodir_taxonomies = geodir_get_taxonomies( '', true );
1060
+	$geodir_taxonomies = geodir_get_taxonomies('', true);
1061 1061
 
1062 1062
 	$meta_desc = '';
1063 1063
 	$meta_key  = '';
1064
-	if ( isset( $current_term->ID ) && $current_term->ID == geodir_location_page_id() ) {
1064
+	if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
1065 1065
 		/**
1066 1066
 		 * Filter SEO meta location description.
1067 1067
 		 *
1068 1068
 		 * @since 1.0.0
1069 1069
 		 */
1070
-		$meta_desc = apply_filters( 'geodir_seo_meta_location_description', '' );
1070
+		$meta_desc = apply_filters('geodir_seo_meta_location_description', '');
1071 1071
 		$meta_desc .= '';
1072 1072
 	}
1073
-	if ( have_posts() && is_single() OR is_page() ) {
1074
-		while ( have_posts() ) {
1073
+	if (have_posts() && is_single() OR is_page()) {
1074
+		while (have_posts()) {
1075 1075
 			the_post();
1076 1076
 
1077
-			if ( has_excerpt() ) {
1078
-				$out_excerpt = strip_tags( strip_shortcodes( get_the_excerpt() ) );
1079
-				if ( empty( $out_excerpt ) ) {
1080
-					$out_excerpt = strip_tags( do_shortcode( get_the_excerpt() ) );
1077
+			if (has_excerpt()) {
1078
+				$out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt()));
1079
+				if (empty($out_excerpt)) {
1080
+					$out_excerpt = strip_tags(do_shortcode(get_the_excerpt()));
1081 1081
 				}
1082
-				$out_excerpt = str_replace( array( "\r\n", "\r", "\n" ), "", $out_excerpt );
1082
+				$out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
1083 1083
 			} else {
1084
-				$out_excerpt = str_replace( array( "\r\n", "\r", "\n" ), "", $post->post_content );
1085
-				$out_excerpt = strip_tags( strip_shortcodes( $out_excerpt ) );
1086
-				if ( empty( $out_excerpt ) ) {
1087
-					$out_excerpt = strip_tags( do_shortcode( $out_excerpt ) ); // parse short code from content
1084
+				$out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
1085
+				$out_excerpt = strip_tags(strip_shortcodes($out_excerpt));
1086
+				if (empty($out_excerpt)) {
1087
+					$out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content
1088 1088
 				}
1089
-				$out_excerpt = trim( wp_trim_words( $out_excerpt, 35, '' ), '.!?,;:-' );
1089
+				$out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-');
1090 1090
 			}
1091 1091
 
1092 1092
 			$meta_desc .= $out_excerpt;
1093 1093
 		}
1094
-	} elseif ( ( is_category() || is_tag() ) && isset( $current_term->taxonomy ) && in_array( $current_term->taxonomy, $geodir_taxonomies ) ) {
1095
-		if ( is_category() ) {
1096
-			$meta_desc .= __( "Posts related to Category:", 'geodirectory' ) . " " . geodir_utf8_ucfirst( single_cat_title( "", false ) );
1097
-		} elseif ( is_tag() ) {
1098
-			$meta_desc .= __( "Posts related to Tag:", 'geodirectory' ) . " " . geodir_utf8_ucfirst( single_tag_title( "", false ) );
1094
+	} elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1095
+		if (is_category()) {
1096
+			$meta_desc .= __("Posts related to Category:", 'geodirectory')." ".geodir_utf8_ucfirst(single_cat_title("", false));
1097
+		} elseif (is_tag()) {
1098
+			$meta_desc .= __("Posts related to Tag:", 'geodirectory')." ".geodir_utf8_ucfirst(single_tag_title("", false));
1099 1099
 		}
1100
-	} elseif ( isset( $current_term->taxonomy ) && in_array( $current_term->taxonomy, $geodir_taxonomies ) ) {
1101
-		$meta_desc .= isset( $current_term->description ) ? $current_term->description : '';
1100
+	} elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1101
+		$meta_desc .= isset($current_term->description) ? $current_term->description : '';
1102 1102
 	}
1103 1103
 
1104 1104
 
1105 1105
 	$geodir_post_type       = geodir_get_current_posttype();
1106
-	$geodir_post_type_info  = get_post_type_object( $geodir_post_type );
1107
-	$geodir_is_page_listing = geodir_is_page( 'listing' ) ? true : false;
1108
-
1109
-	$category_taxonomy = geodir_get_taxonomies( $geodir_post_type );
1110
-	$tag_taxonomy      = geodir_get_taxonomies( $geodir_post_type, true );
1111
-
1112
-	$geodir_is_category = isset( $category_taxonomy[0] ) && get_query_var( $category_taxonomy[0] ) ? get_query_var( $category_taxonomy[0] ) : false;
1113
-	$geodir_is_tag      = isset( $tag_taxonomy[0] ) && get_query_var( $tag_taxonomy[0] ) ? true : false;
1114
-
1115
-	$geodir_is_search        = geodir_is_page( 'search' ) ? true : false;
1116
-	$geodir_is_location      = geodir_is_page( 'location' ) ? true : false;
1117
-	$geodir_location_manager = isset( $geodir_addon_list['geodir_location_manager'] ) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false;
1118
-	$godir_location_terms    = geodir_get_current_location_terms( 'query_vars' );
1119
-	$gd_city                 = $geodir_location_manager && isset( $godir_location_terms['gd_city'] ) ? $godir_location_terms['gd_city'] : null;
1120
-	$gd_region               = $geodir_location_manager && isset( $godir_location_terms['gd_region'] ) ? $godir_location_terms['gd_region'] : null;
1121
-	$gd_country              = $geodir_location_manager && isset( $godir_location_terms['gd_country'] ) ? $godir_location_terms['gd_country'] : null;
1122
-	$replace_location        = __( 'Everywhere', 'geodirectory' );
1106
+	$geodir_post_type_info  = get_post_type_object($geodir_post_type);
1107
+	$geodir_is_page_listing = geodir_is_page('listing') ? true : false;
1108
+
1109
+	$category_taxonomy = geodir_get_taxonomies($geodir_post_type);
1110
+	$tag_taxonomy      = geodir_get_taxonomies($geodir_post_type, true);
1111
+
1112
+	$geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false;
1113
+	$geodir_is_tag      = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false;
1114
+
1115
+	$geodir_is_search        = geodir_is_page('search') ? true : false;
1116
+	$geodir_is_location      = geodir_is_page('location') ? true : false;
1117
+	$geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false;
1118
+	$godir_location_terms    = geodir_get_current_location_terms('query_vars');
1119
+	$gd_city                 = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : null;
1120
+	$gd_region               = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : null;
1121
+	$gd_country              = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : null;
1122
+	$replace_location        = __('Everywhere', 'geodirectory');
1123 1123
 	$location_id             = null;
1124
-	if ( $geodir_location_manager ) {
1125
-		$sql           = $wpdb->prepare( "SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array( $gd_city ) );
1126
-		$location_id   = (int) $wpdb->get_var( $sql );
1124
+	if ($geodir_location_manager) {
1125
+		$sql           = $wpdb->prepare("SELECT location_id FROM ".POST_LOCATION_TABLE." WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1126
+		$location_id   = (int) $wpdb->get_var($sql);
1127 1127
 		$location_type = geodir_what_is_current_location();
1128
-		if ( $location_type == 'city' ) {
1129
-			$replace_location = geodir_get_current_location( array( 'what' => 'city', 'echo' => false ) );
1130
-		} elseif ( $location_type == 'region' ) {
1131
-			$replace_location = geodir_get_current_location( array( 'what' => 'region', 'echo' => false ) );
1132
-		} elseif ( $location_type == 'country' ) {
1133
-			$replace_location = geodir_get_current_location( array( 'what' => 'country', 'echo' => false ) );
1134
-			$replace_location = __( $replace_location, 'geodirectory' );
1128
+		if ($location_type == 'city') {
1129
+			$replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
1130
+		} elseif ($location_type == 'region') {
1131
+			$replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
1132
+		} elseif ($location_type == 'country') {
1133
+			$replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
1134
+			$replace_location = __($replace_location, 'geodirectory');
1135 1135
 		}
1136
-		$country          = get_query_var( 'gd_country' );
1137
-		$region           = get_query_var( 'gd_region' );
1138
-		$city             = get_query_var( 'gd_city' );
1136
+		$country          = get_query_var('gd_country');
1137
+		$region           = get_query_var('gd_region');
1138
+		$city             = get_query_var('gd_city');
1139 1139
 		$current_location = '';
1140
-		if ( $country != '' ) {
1141
-			$current_location = get_actual_location_name( 'country', $country, true );
1140
+		if ($country != '') {
1141
+			$current_location = get_actual_location_name('country', $country, true);
1142 1142
 		}
1143
-		if ( $region != '' ) {
1144
-			$current_location = get_actual_location_name( 'region', $region );
1143
+		if ($region != '') {
1144
+			$current_location = get_actual_location_name('region', $region);
1145 1145
 		}
1146
-		if ( $city != '' ) {
1147
-			$current_location = get_actual_location_name( 'city', $city );
1146
+		if ($city != '') {
1147
+			$current_location = get_actual_location_name('city', $city);
1148 1148
 		}
1149 1149
 		$replace_location = $current_location != '' ? $current_location : $replace_location;
1150 1150
 	}
1151 1151
 
1152 1152
 	$geodir_meta_keys = '';
1153 1153
 	$geodir_meta_desc = '';
1154
-	if ( $is_geodir_page && ! empty( $geodir_post_type_info ) ) {
1155
-		if ( $geodir_is_page_listing || $geodir_is_search || geodir_is_page( 'add-listing' ) ) {
1156
-			$geodir_meta_keys = isset( $geodir_post_type_info->seo['meta_keyword'] ) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys;
1154
+	if ($is_geodir_page && !empty($geodir_post_type_info)) {
1155
+		if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
1156
+			$geodir_meta_keys = isset($geodir_post_type_info->seo['meta_keyword']) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys;
1157 1157
 
1158
-			$geodir_meta_desc = isset( $geodir_post_type_info->description ) ? $geodir_post_type_info->description : $geodir_meta_desc;
1159
-			$geodir_meta_desc = isset( $geodir_post_type_info->seo['meta_description'] ) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc;
1158
+			$geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc;
1159
+			$geodir_meta_desc = isset($geodir_post_type_info->seo['meta_description']) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc;
1160 1160
 
1161
-			if ( $geodir_is_category ) {
1162
-				$category = $geodir_is_category ? get_term_by( 'slug', $geodir_is_category, $category_taxonomy[0] ) : null;
1163
-				if ( isset( $category->term_id ) && ! empty( $category->term_id ) ) {
1161
+			if ($geodir_is_category) {
1162
+				$category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : null;
1163
+				if (isset($category->term_id) && !empty($category->term_id)) {
1164 1164
 					$category_id   = $category->term_id;
1165
-					$category_desc = trim( $category->description ) != '' ? trim( $category->description ) : geodir_get_tax_meta( $category_id, 'ct_cat_top_desc', false, $geodir_post_type );
1166
-					if ( $location_id ) {
1167
-						$option_name    = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id;
1168
-						$cat_loc_option = get_option( $option_name );
1169
-
1170
-						$gd_cat_loc_default = ! empty( $cat_loc_option ) && isset( $cat_loc_option['gd_cat_loc_default'] ) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false;
1171
-						if ( ! $gd_cat_loc_default ) {
1172
-							$option_name   = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id;
1173
-							$option        = get_option( $option_name );
1174
-							$category_desc = isset( $option['gd_cat_loc_desc'] ) && trim( $option['gd_cat_loc_desc'] ) != '' ? trim( $option['gd_cat_loc_desc'] ) : $category_desc;
1165
+					$category_desc = trim($category->description) != '' ? trim($category->description) : geodir_get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type);
1166
+					if ($location_id) {
1167
+						$option_name    = 'geodir_cat_loc_'.$geodir_post_type.'_'.$category_id;
1168
+						$cat_loc_option = get_option($option_name);
1169
+
1170
+						$gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false;
1171
+						if (!$gd_cat_loc_default) {
1172
+							$option_name   = 'geodir_cat_loc_'.$geodir_post_type.'_'.$category_id.'_'.$location_id;
1173
+							$option        = get_option($option_name);
1174
+							$category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc;
1175 1175
 						}
1176 1176
 					}
1177
-					$geodir_meta_desc = __( "Posts related to Category:", 'geodirectory' ) . " " . geodir_utf8_ucfirst( single_cat_title( "", false ) ) . '. ' . $category_desc;
1177
+					$geodir_meta_desc = __("Posts related to Category:", 'geodirectory')." ".geodir_utf8_ucfirst(single_cat_title("", false)).'. '.$category_desc;
1178 1178
 				}
1179
-			} else if ( $geodir_is_tag ) {
1180
-				$geodir_meta_desc = __( "Posts related to Tag:", 'geodirectory' ) . " " . geodir_utf8_ucfirst( single_tag_title( "", false ) ) . '. ' . $geodir_meta_desc;
1179
+			} else if ($geodir_is_tag) {
1180
+				$geodir_meta_desc = __("Posts related to Tag:", 'geodirectory')." ".geodir_utf8_ucfirst(single_tag_title("", false)).'. '.$geodir_meta_desc;
1181 1181
 			}
1182 1182
 		}
1183 1183
 	}
1184 1184
 
1185 1185
 
1186 1186
 	$gd_page = '';
1187
-	if ( geodir_is_page( 'home' ) ) {
1187
+	if (geodir_is_page('home')) {
1188 1188
 		$gd_page   = 'home';
1189
-		$meta_desc = ( get_option( 'geodir_meta_desc_homepage' ) ) ? get_option( 'geodir_meta_desc_homepage' ) : $meta_desc;
1190
-	} elseif ( geodir_is_page( 'detail' ) ) {
1189
+		$meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1190
+	} elseif (geodir_is_page('detail')) {
1191 1191
 		$gd_page   = 'detail';
1192
-		$meta_desc = ( get_option( 'geodir_meta_desc_detail' ) ) ? get_option( 'geodir_meta_desc_detail' ) : $meta_desc;
1193
-	} elseif ( geodir_is_page( 'pt' ) ) {
1192
+		$meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1193
+	} elseif (geodir_is_page('pt')) {
1194 1194
 		$gd_page   = 'pt';
1195
-		$meta_desc = ( get_option( 'geodir_meta_desc_pt' ) ) ? get_option( 'geodir_meta_desc_pt' ) : $meta_desc;
1196
-	} elseif ( geodir_is_page( 'listing' ) ) {
1195
+		$meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1196
+	} elseif (geodir_is_page('listing')) {
1197 1197
 		$gd_page   = 'listing';
1198
-		$meta_desc = ( get_option( 'geodir_meta_desc_listing' ) ) ? get_option( 'geodir_meta_desc_listing' ) : $meta_desc;
1199
-	} elseif ( geodir_is_page( 'location' ) ) {
1198
+		$meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1199
+	} elseif (geodir_is_page('location')) {
1200 1200
 		$gd_page   = 'location';
1201
-		$meta_desc = ( get_option( 'geodir_meta_desc_location' ) ) ? get_option( 'geodir_meta_desc_location' ) : $meta_desc;
1202
-		$meta_desc = apply_filters( 'geodir_seo_meta_location_description', $meta_desc );
1201
+		$meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1202
+		$meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1203 1203
 
1204
-	} elseif ( geodir_is_page( 'search' ) ) {
1204
+	} elseif (geodir_is_page('search')) {
1205 1205
 		$gd_page   = 'search';
1206
-		$meta_desc = ( get_option( 'geodir_meta_desc_search' ) ) ? get_option( 'geodir_meta_desc_search' ) : $meta_desc;
1207
-	} elseif ( geodir_is_page( 'add-listing' ) ) {
1206
+		$meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1207
+	} elseif (geodir_is_page('add-listing')) {
1208 1208
 		$gd_page   = 'add-listing';
1209
-		$meta_desc = ( get_option( 'geodir_meta_desc_add-listing' ) ) ? get_option( 'geodir_meta_desc_add-listing' ) : $meta_desc;
1210
-	} elseif ( geodir_is_page( 'author' ) ) {
1209
+		$meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1210
+	} elseif (geodir_is_page('author')) {
1211 1211
 		$gd_page   = 'author';
1212
-		$meta_desc = ( get_option( 'geodir_meta_desc_author' ) ) ? get_option( 'geodir_meta_desc_author' ) : $meta_desc;
1213
-	} elseif ( geodir_is_page( 'login' ) ) {
1212
+		$meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1213
+	} elseif (geodir_is_page('login')) {
1214 1214
 		$gd_page   = 'login';
1215
-		$meta_desc = ( get_option( 'geodir_meta_desc_login' ) ) ? get_option( 'geodir_meta_desc_login' ) : $meta_desc;
1216
-	} elseif ( geodir_is_page( 'listing-success' ) ) {
1215
+		$meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1216
+	} elseif (geodir_is_page('listing-success')) {
1217 1217
 		$gd_page   = 'listing-success';
1218
-		$meta_desc = ( get_option( 'geodir_meta_desc_listing-success' ) ) ? get_option( 'geodir_meta_desc_listing-success' ) : $meta_desc;
1218
+		$meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1219 1219
 	}
1220 1220
 
1221 1221
 
1222
-	if ( $meta_desc ) {
1223
-		$meta_desc = stripslashes_deep( $meta_desc );
1222
+	if ($meta_desc) {
1223
+		$meta_desc = stripslashes_deep($meta_desc);
1224 1224
 		/**
1225 1225
 		 * Filter page description to replace variables.
1226 1226
 		 *
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
 		 * @param string $title   The page description including variables.
1230 1230
 		 * @param string $gd_page The GeoDirectory page type if any.
1231 1231
 		 */
1232
-		$meta_desc = apply_filters( 'geodir_seo_meta_description_pre', __( $meta_desc, 'geodirectory' ), $gd_page, '' );
1232
+		$meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'), $gd_page, '');
1233 1233
 
1234 1234
 		/**
1235 1235
 		 * Filter SEO meta description.
@@ -1238,49 +1238,49 @@  discard block
 block discarded – undo
1238 1238
 		 *
1239 1239
 		 * @param string $meta_desc Meta description content.
1240 1240
 		 */
1241
-		echo apply_filters( 'geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc );
1241
+		echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="'.$meta_desc.'" />', $meta_desc);
1242 1242
 	}
1243 1243
 
1244 1244
 	// meta keywords
1245
-	if ( isset( $post->post_type ) && in_array( $post->post_type, $all_postypes ) ) {
1246
-		$place_tags = wp_get_post_terms( $post->ID, $post->post_type . '_tags', array( "fields" => "names" ) );
1247
-		$place_cats = wp_get_post_terms( $post->ID, $post->post_type . 'category', array( "fields" => "names" ) );
1245
+	if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
1246
+		$place_tags = wp_get_post_terms($post->ID, $post->post_type.'_tags', array("fields" => "names"));
1247
+		$place_cats = wp_get_post_terms($post->ID, $post->post_type.'category', array("fields" => "names"));
1248 1248
 
1249
-		$meta_key .= implode( ", ", array_merge( (array) $place_cats, (array) $place_tags ) );
1249
+		$meta_key .= implode(", ", array_merge((array) $place_cats, (array) $place_tags));
1250 1250
 	} else {
1251 1251
 		$posttags = get_the_tags();
1252
-		if ( $posttags ) {
1253
-			foreach ( $posttags as $tag ) {
1254
-				$meta_key .= $tag->name . ' ';
1252
+		if ($posttags) {
1253
+			foreach ($posttags as $tag) {
1254
+				$meta_key .= $tag->name.' ';
1255 1255
 			}
1256 1256
 		} else {
1257
-			$tags = get_tags( array( 'orderby' => 'count', 'order' => 'DESC' ) );
1257
+			$tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
1258 1258
 			$xt   = 1;
1259 1259
 
1260
-			foreach ( $tags as $tag ) {
1261
-				if ( $xt <= 20 ) {
1262
-					$meta_key .= $tag->name . ", ";
1260
+			foreach ($tags as $tag) {
1261
+				if ($xt <= 20) {
1262
+					$meta_key .= $tag->name.", ";
1263 1263
 				}
1264 1264
 
1265
-				$xt ++;
1265
+				$xt++;
1266 1266
 			}
1267 1267
 		}
1268 1268
 	}
1269 1269
 
1270
-	$meta_key         = $meta_key != '' ? rtrim( trim( $meta_key ), "," ) : $meta_key;
1271
-	$geodir_meta_keys = $geodir_meta_keys != '' ? ( $meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys ) : $meta_key;
1272
-	if ( $geodir_meta_keys != '' ) {
1273
-		$geodir_meta_keys = strip_tags( $geodir_meta_keys );
1274
-		$geodir_meta_keys = esc_html( $geodir_meta_keys );
1275
-		$geodir_meta_keys = geodir_strtolower( $geodir_meta_keys );
1276
-		$geodir_meta_keys = wp_html_excerpt( $geodir_meta_keys, 1000, '' );
1277
-		$geodir_meta_keys = str_replace( '%location%', $replace_location, $geodir_meta_keys );
1270
+	$meta_key         = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key;
1271
+	$geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key.', '.$geodir_meta_keys : $geodir_meta_keys) : $meta_key;
1272
+	if ($geodir_meta_keys != '') {
1273
+		$geodir_meta_keys = strip_tags($geodir_meta_keys);
1274
+		$geodir_meta_keys = esc_html($geodir_meta_keys);
1275
+		$geodir_meta_keys = geodir_strtolower($geodir_meta_keys);
1276
+		$geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, '');
1277
+		$geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
1278 1278
 
1279
-		$meta_key = rtrim( trim( $geodir_meta_keys ), "," );
1279
+		$meta_key = rtrim(trim($geodir_meta_keys), ",");
1280 1280
 	}
1281 1281
 
1282
-	if ( $meta_key ) {
1283
-		$meta_key = stripslashes_deep( $meta_key );
1282
+	if ($meta_key) {
1283
+		$meta_key = stripslashes_deep($meta_key);
1284 1284
 		/**
1285 1285
 		 * Filter SEO meta keywords.
1286 1286
 		 *
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
 		 *
1289 1289
 		 * @param string $meta_desc Meta keywords.
1290 1290
 		 */
1291
-		echo apply_filters( 'geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key );
1291
+		echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="'.$meta_key.'" />', $meta_key);
1292 1292
 	}
1293 1293
 
1294 1294
 }
@@ -1308,8 +1308,8 @@  discard block
 block discarded – undo
1308 1308
 
1309 1309
 	$geodir_detail_page_tabs_array = geodir_detail_page_tabs_array();
1310 1310
 
1311
-	foreach ( $geodir_detail_page_tabs_array as $key => $tabs_obj ) {
1312
-		$geodir_detail_page_tabs_key_value_array[ $key ] = $tabs_obj['heading_text'];
1311
+	foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
1312
+		$geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text'];
1313 1313
 	}
1314 1314
 
1315 1315
 	return $geodir_detail_page_tabs_key_value_array;
@@ -1331,57 +1331,57 @@  discard block
 block discarded – undo
1331 1331
 	 * @since 1.0.0
1332 1332
 	 */
1333 1333
 	$arr_tabs['post_profile'] = array(
1334
-		'heading_text'  => __( 'Profile', 'geodirectory' ),
1334
+		'heading_text'  => __('Profile', 'geodirectory'),
1335 1335
 		'is_active_tab' => true,
1336
-		'is_display'    => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_profile' ),
1336
+		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
1337 1337
 		'tab_content'   => ''
1338 1338
 	);
1339
-	$arr_tabs['post_info']    = array(
1340
-		'heading_text'  => __( 'More Info', 'geodirectory' ),
1339
+	$arr_tabs['post_info'] = array(
1340
+		'heading_text'  => __('More Info', 'geodirectory'),
1341 1341
 		'is_active_tab' => false,
1342
-		'is_display'    => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_info' ),
1342
+		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
1343 1343
 		'tab_content'   => ''
1344 1344
 	);
1345 1345
 
1346 1346
 	$arr_tabs['post_images'] = array(
1347
-		'heading_text'  => __( 'Photos', 'geodirectory' ),
1347
+		'heading_text'  => __('Photos', 'geodirectory'),
1348 1348
 		'is_active_tab' => false,
1349
-		'is_display'    => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_images' ),
1349
+		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
1350 1350
 		'tab_content'   => ''
1351 1351
 	);
1352 1352
 
1353 1353
 	$arr_tabs['post_video'] = array(
1354
-		'heading_text'  => __( 'Video', 'geodirectory' ),
1354
+		'heading_text'  => __('Video', 'geodirectory'),
1355 1355
 		'is_active_tab' => false,
1356
-		'is_display'    => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_video' ),
1356
+		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
1357 1357
 		'tab_content'   => ''
1358 1358
 	);
1359 1359
 
1360 1360
 	$arr_tabs['special_offers'] = array(
1361
-		'heading_text'  => __( 'Special Offers', 'geodirectory' ),
1361
+		'heading_text'  => __('Special Offers', 'geodirectory'),
1362 1362
 		'is_active_tab' => false,
1363
-		'is_display'    => apply_filters( 'geodir_detail_page_tab_is_display', true, 'special_offers' ),
1363
+		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
1364 1364
 		'tab_content'   => ''
1365 1365
 	);
1366 1366
 
1367 1367
 	$arr_tabs['post_map'] = array(
1368
-		'heading_text'  => __( 'Map', 'geodirectory' ),
1368
+		'heading_text'  => __('Map', 'geodirectory'),
1369 1369
 		'is_active_tab' => false,
1370
-		'is_display'    => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_map' ),
1370
+		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
1371 1371
 		'tab_content'   => ''
1372 1372
 	);
1373 1373
 
1374 1374
 	$arr_tabs['reviews'] = array(
1375
-		'heading_text'  => __( 'Reviews', 'geodirectory' ),
1375
+		'heading_text'  => __('Reviews', 'geodirectory'),
1376 1376
 		'is_active_tab' => false,
1377
-		'is_display'    => apply_filters( 'geodir_detail_page_tab_is_display', true, 'reviews' ),
1377
+		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
1378 1378
 		'tab_content'   => 'review display'
1379 1379
 	);
1380 1380
 
1381 1381
 	$arr_tabs['related_listing'] = array(
1382
-		'heading_text'  => __( 'Related Listing', 'geodirectory' ),
1382
+		'heading_text'  => __('Related Listing', 'geodirectory'),
1383 1383
 		'is_active_tab' => false,
1384
-		'is_display'    => apply_filters( 'geodir_detail_page_tab_is_display', true, 'related_listing' ),
1384
+		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
1385 1385
 		'tab_content'   => ''
1386 1386
 	);
1387 1387
 
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
 	 *
1391 1391
 	 * @since 1.0.0
1392 1392
 	 */
1393
-	return apply_filters( 'geodir_detail_page_tab_list_extend', $arr_tabs );
1393
+	return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
1394 1394
 
1395 1395
 
1396 1396
 }
@@ -1404,13 +1404,13 @@  discard block
 block discarded – undo
1404 1404
  * @return mixed|array Tabs array.
1405 1405
  */
1406 1406
 function geodir_detail_page_tabs_list() {
1407
-	$tabs_excluded = get_option( 'geodir_detail_page_tabs_excluded' );
1407
+	$tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
1408 1408
 	$tabs_array    = geodir_detail_page_tabs_array();
1409 1409
 
1410
-	if ( ! empty( $tabs_excluded ) ) {
1411
-		foreach ( $tabs_excluded as $tab ) {
1412
-			if ( array_key_exists( $tab, $tabs_array ) ) {
1413
-				unset( $tabs_array[ $tab ] );
1410
+	if (!empty($tabs_excluded)) {
1411
+		foreach ($tabs_excluded as $tab) {
1412
+			if (array_key_exists($tab, $tabs_array)) {
1413
+				unset($tabs_array[$tab]);
1414 1414
 			}
1415 1415
 		}
1416 1416
 	}
@@ -1434,58 +1434,58 @@  discard block
 block discarded – undo
1434 1434
 function geodir_show_detail_page_tabs() {
1435 1435
 	global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields, $preview;
1436 1436
 
1437
-	$post_id            = ! empty( $post ) && isset( $post->ID ) ? (int) $post->ID : 0;
1438
-	$request_post_id    = ! empty( $_REQUEST['p'] ) ? (int) $_REQUEST['p'] : 0;
1439
-	$is_backend_preview = ( is_single() && ! empty( $_REQUEST['post_type'] ) && ! empty( $_REQUEST['preview'] ) && ! empty( $_REQUEST['p'] ) ) && is_super_admin() ? true : false; // skip if preview from backend
1437
+	$post_id            = !empty($post) && isset($post->ID) ? (int) $post->ID : 0;
1438
+	$request_post_id    = !empty($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
1439
+	$is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
1440 1440
 
1441
-	if ( $is_backend_preview && ! $post_id > 0 && $request_post_id > 0 ) {
1442
-		$post = geodir_get_post_info( $request_post_id );
1443
-		setup_postdata( $post );
1441
+	if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
1442
+		$post = geodir_get_post_info($request_post_id);
1443
+		setup_postdata($post);
1444 1444
 	}
1445 1445
 
1446
-	$geodir_post_detail_fields = geodir_show_listing_info( 'moreinfo' );
1446
+	$geodir_post_detail_fields = geodir_show_listing_info('moreinfo');
1447 1447
 
1448 1448
 
1449
-	if ( geodir_is_page( 'detail' ) ) {
1450
-		$video                 = geodir_get_video( $post->ID );
1451
-		$special_offers        = geodir_get_special_offers( $post->ID );
1449
+	if (geodir_is_page('detail')) {
1450
+		$video                 = geodir_get_video($post->ID);
1451
+		$special_offers        = geodir_get_special_offers($post->ID);
1452 1452
 		$related_listing_array = array();
1453
-		if ( get_option( 'geodir_add_related_listing_posttypes' ) ) {
1454
-			$related_listing_array = get_option( 'geodir_add_related_listing_posttypes' );
1453
+		if (get_option('geodir_add_related_listing_posttypes')) {
1454
+			$related_listing_array = get_option('geodir_add_related_listing_posttypes');
1455 1455
 		}
1456 1456
 
1457 1457
 
1458
-		$excluded_tabs = get_option( 'geodir_detail_page_tabs_excluded' );
1459
-		if ( ! $excluded_tabs ) {
1458
+		$excluded_tabs = get_option('geodir_detail_page_tabs_excluded');
1459
+		if (!$excluded_tabs) {
1460 1460
 			$excluded_tabs = array();
1461 1461
 		}
1462 1462
 
1463 1463
 		$related_listing = '';
1464
-		if ( in_array( $post->post_type, $related_listing_array ) && ! in_array( 'related_listing', $excluded_tabs ) ) {
1464
+		if (in_array($post->post_type, $related_listing_array) && !in_array('related_listing', $excluded_tabs)) {
1465 1465
 			$request = array(
1466
-				'post_number'         => get_option( 'geodir_related_post_count' ),
1467
-				'relate_to'           => get_option( 'geodir_related_post_relate_to' ),
1468
-				'layout'              => get_option( 'geodir_related_post_listing_view' ),
1469
-				'add_location_filter' => get_option( 'geodir_related_post_location_filter' ),
1470
-				'list_sort'           => get_option( 'geodir_related_post_sortby' ),
1471
-				'character_count'     => get_option( 'geodir_related_post_excerpt' )
1466
+				'post_number'         => get_option('geodir_related_post_count'),
1467
+				'relate_to'           => get_option('geodir_related_post_relate_to'),
1468
+				'layout'              => get_option('geodir_related_post_listing_view'),
1469
+				'add_location_filter' => get_option('geodir_related_post_location_filter'),
1470
+				'list_sort'           => get_option('geodir_related_post_sortby'),
1471
+				'character_count'     => get_option('geodir_related_post_excerpt')
1472 1472
 			);
1473 1473
 
1474
-			if ( $post->post_type == 'gd_event' && defined( 'GDEVENTS_VERSION' ) ) {
1475
-				$related_listing = geodir_get_detail_page_related_events( $request );
1474
+			if ($post->post_type == 'gd_event' && defined('GDEVENTS_VERSION')) {
1475
+				$related_listing = geodir_get_detail_page_related_events($request);
1476 1476
 			} else {
1477
-				$related_listing = geodir_related_posts_display( $request );
1477
+				$related_listing = geodir_related_posts_display($request);
1478 1478
 			}
1479 1479
 
1480 1480
 		}
1481 1481
 
1482
-		$post_images = geodir_get_images( $post->ID, 'thumbnail' );
1482
+		$post_images = geodir_get_images($post->ID, 'thumbnail');
1483 1483
 		$thumb_image = '';
1484
-		if ( ! empty( $post_images ) ) {
1485
-			foreach ( $post_images as $image ) {
1486
-				$caption = ( ! empty( $image->caption ) ) ? $image->caption : '';
1487
-				$thumb_image .= '<a href="' . $image->src . '" title="' . $caption . '">';
1488
-				$thumb_image .= geodir_show_image( $image, 'thumbnail', true, false );
1484
+		if (!empty($post_images)) {
1485
+			foreach ($post_images as $image) {
1486
+				$caption = (!empty($image->caption)) ? $image->caption : '';
1487
+				$thumb_image .= '<a href="'.$image->src.'" title="'.$caption.'">';
1488
+				$thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1489 1489
 				$thumb_image .= '</a>';
1490 1490
 			}
1491 1491
 		}
@@ -1494,11 +1494,11 @@  discard block
 block discarded – undo
1494 1494
 		$map_args['map_canvas_name'] = 'detail_page_map_canvas';
1495 1495
 		$map_args['width']           = '600';
1496 1496
 		$map_args['height']          = '300';
1497
-		if ( $post->post_mapzoom ) {
1498
-			$map_args['zoom'] = '' . $post->post_mapzoom . '';
1497
+		if ($post->post_mapzoom) {
1498
+			$map_args['zoom'] = ''.$post->post_mapzoom.'';
1499 1499
 		}
1500 1500
 		$map_args['autozoom']                 = false;
1501
-		$map_args['scrollwheel']              = ( get_option( 'geodir_add_listing_mouse_scroll' ) ) ? 0 : 1;
1501
+		$map_args['scrollwheel']              = (get_option('geodir_add_listing_mouse_scroll')) ? 0 : 1;
1502 1502
 		$map_args['child_collapse']           = '0';
1503 1503
 		$map_args['enable_cat_filters']       = false;
1504 1504
 		$map_args['enable_text_search']       = false;
@@ -1507,43 +1507,43 @@  discard block
 block discarded – undo
1507 1507
 		$map_args['enable_jason_on_load']     = true;
1508 1508
 		$map_args['enable_map_direction']     = true;
1509 1509
 		$map_args['map_class_name']           = 'geodir-map-detail-page';
1510
-		$map_args['maptype']                  = ( ! empty( $post->post_mapview ) ) ? $post->post_mapview : 'ROADMAP';
1511
-	} else if ( geodir_is_page( 'preview' ) ) {
1512
-		$video          = isset( $post->geodir_video ) ? $post->geodir_video : '';
1513
-		$special_offers = isset( $post->geodir_special_offers ) ? $post->geodir_special_offers : '';
1510
+		$map_args['maptype']                  = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP';
1511
+	} else if (geodir_is_page('preview')) {
1512
+		$video          = isset($post->geodir_video) ? $post->geodir_video : '';
1513
+		$special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1514 1514
 
1515
-		if ( isset( $post->post_images ) ) {
1516
-			$post->post_images = trim( $post->post_images, "," );
1515
+		if (isset($post->post_images)) {
1516
+			$post->post_images = trim($post->post_images, ",");
1517 1517
 		}
1518 1518
 
1519
-		if ( isset( $post->post_images ) && ! empty( $post->post_images ) ) {
1520
-			$post_images = explode( ",", $post->post_images );
1519
+		if (isset($post->post_images) && !empty($post->post_images)) {
1520
+			$post_images = explode(",", $post->post_images);
1521 1521
 		}
1522 1522
 
1523 1523
 		$thumb_image = '';
1524
-		if ( ! empty( $post_images ) ) {
1525
-			foreach ( $post_images as $image ) {
1526
-				if ( $image != '' ) {
1527
-					$thumb_image .= '<a href="' . $image . '">';
1528
-					$thumb_image .= geodir_show_image( array( 'src' => $image ), 'thumbnail', true, false );
1524
+		if (!empty($post_images)) {
1525
+			foreach ($post_images as $image) {
1526
+				if ($image != '') {
1527
+					$thumb_image .= '<a href="'.$image.'">';
1528
+					$thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
1529 1529
 					$thumb_image .= '</a>';
1530 1530
 				}
1531 1531
 			}
1532 1532
 		}
1533 1533
 
1534 1534
 		global $map_jason;
1535
-		$marker_json      = $post->marker_json != '' ? json_decode( $post->marker_json, true ) : array();
1536
-		$marker_icon      = ( ! empty( $marker_json ) && ! empty( $marker_json['i'] ) ) ? $marker_json['i'] : '';
1537
-		$icon_size        = geodir_get_marker_size( $marker_icon );
1535
+		$marker_json      = $post->marker_json != '' ? json_decode($post->marker_json, true) : array();
1536
+		$marker_icon      = (!empty($marker_json) && !empty($marker_json['i'])) ? $marker_json['i'] : '';
1537
+		$icon_size        = geodir_get_marker_size($marker_icon);
1538 1538
 		$marker_json['w'] = $icon_size['w'];
1539 1539
 		$marker_json['h'] = $icon_size['h'];
1540
-		$map_jason[]      = json_encode( $marker_json );
1540
+		$map_jason[]      = json_encode($marker_json);
1541 1541
 
1542
-		$address_latitude  = isset( $post->post_latitude ) ? $post->post_latitude : '';
1543
-		$address_longitude = isset( $post->post_longitude ) ? $post->post_longitude : '';
1544
-		$mapview           = isset( $post->post_mapview ) ? $post->post_mapview : '';
1545
-		$mapzoom           = isset( $post->post_mapzoom ) ? $post->post_mapzoom : '';
1546
-		if ( ! $mapzoom ) {
1542
+		$address_latitude  = isset($post->post_latitude) ? $post->post_latitude : '';
1543
+		$address_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
1544
+		$mapview           = isset($post->post_mapview) ? $post->post_mapview : '';
1545
+		$mapzoom           = isset($post->post_mapzoom) ? $post->post_mapzoom : '';
1546
+		if (!$mapzoom) {
1547 1547
 			$mapzoom = 12;
1548 1548
 		}
1549 1549
 
@@ -1566,37 +1566,37 @@  discard block
 block discarded – undo
1566 1566
 		$map_args['map_class_name']           = 'geodir-map-preview-page';
1567 1567
 	}
1568 1568
 
1569
-	$arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user
1569
+	$arr_detail_page_tabs = geodir_detail_page_tabs_list(); // get this sooner so we can get the active tab for the user
1570 1570
 
1571 1571
 	$active_tab       = '';
1572 1572
 	$active_tab_name  = '';
1573 1573
 	$default_tab      = '';
1574 1574
 	$default_tab_name = '';
1575
-	foreach ( $arr_detail_page_tabs as $tab_index => $tabs ) {
1576
-		if ( isset( $tabs['is_active_tab'] ) && $tabs['is_active_tab'] && ! empty( $tabs['is_display'] ) && isset( $tabs['heading_text'] ) && $tabs['heading_text'] ) {
1575
+	foreach ($arr_detail_page_tabs as $tab_index => $tabs) {
1576
+		if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1577 1577
 			$active_tab      = $tab_index;
1578
-			$active_tab_name = __( $tabs['heading_text'], 'geodirectory' );
1578
+			$active_tab_name = __($tabs['heading_text'], 'geodirectory');
1579 1579
 		}
1580 1580
 
1581
-		if ( $default_tab === '' && ! empty( $tabs['is_display'] ) && ! empty( $tabs['heading_text'] ) ) {
1581
+		if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
1582 1582
 			$default_tab      = $tab_index;
1583
-			$default_tab_name = __( $tabs['heading_text'], 'geodirectory' );
1583
+			$default_tab_name = __($tabs['heading_text'], 'geodirectory');
1584 1584
 		}
1585 1585
 	}
1586 1586
 
1587
-	if ( $active_tab === '' && $default_tab !== '' ) { // Make first tab as a active tab if not any tab is active.
1588
-		if ( isset( $arr_detail_page_tabs[ $active_tab ] ) && isset( $arr_detail_page_tabs[ $active_tab ]['is_active_tab'] ) ) {
1589
-			$arr_detail_page_tabs[ $active_tab ]['is_active_tab'] = false;
1587
+	if ($active_tab === '' && $default_tab !== '') { // Make first tab as a active tab if not any tab is active.
1588
+		if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
1589
+			$arr_detail_page_tabs[$active_tab]['is_active_tab'] = false;
1590 1590
 		}
1591 1591
 
1592
-		$arr_detail_page_tabs[ $default_tab ]['is_active_tab'] = true;
1592
+		$arr_detail_page_tabs[$default_tab]['is_active_tab'] = true;
1593 1593
 		$active_tab                                            = $default_tab;
1594 1594
 		$active_tab_name                                       = $default_tab_name;
1595 1595
 	}
1596
-	$tab_list = ( get_option( 'geodir_disable_tabs', false ) ) ? true : false;
1596
+	$tab_list = (get_option('geodir_disable_tabs', false)) ? true : false;
1597 1597
 	?>
1598 1598
 	<div class="geodir-tabs" id="gd-tabs" style="position:relative;">
1599
-		<?php if ( ! $tab_list ){ ?>
1599
+		<?php if (!$tab_list) { ?>
1600 1600
 		<div id="geodir-tab-mobile-menu">
1601 1601
 			<i class="fa fa-bars"></i>
1602 1602
 			<span class="geodir-mobile-active-tab"><?php echo $active_tab_name; ?></span>
@@ -1611,26 +1611,26 @@  discard block
 block discarded – undo
1611 1611
 			 * @since 1.0.0
1612 1612
 			 * @see   'geodir_after_tab_list'
1613 1613
 			 */
1614
-			do_action( 'geodir_before_tab_list' ); ?>
1614
+			do_action('geodir_before_tab_list'); ?>
1615 1615
 			<?php
1616 1616
 
1617
-			foreach ( $arr_detail_page_tabs as $tab_index => $detail_page_tab ) {
1618
-				if ( $detail_page_tab['is_display'] ) {
1617
+			foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
1618
+				if ($detail_page_tab['is_display']) {
1619 1619
 
1620
-					if ( ! $tab_list ) {
1620
+					if (!$tab_list) {
1621 1621
 						?>
1622 1622
 						<dt></dt> <!-- added to comply with validation -->
1623
-						<dd <?php if ( $detail_page_tab['is_active_tab'] ){ ?>class="geodir-tab-active"<?php } ?> ><a
1623
+						<dd <?php if ($detail_page_tab['is_active_tab']) { ?>class="geodir-tab-active"<?php } ?> ><a
1624 1624
 								data-tab="#<?php echo $tab_index; ?>"
1625
-								data-status="enable"><?php _e( $detail_page_tab['heading_text'], 'geodirectory' ); ?></a>
1625
+								data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?></a>
1626 1626
 						</dd>
1627 1627
 						<?php
1628 1628
 					}
1629 1629
 					ob_start() // start tab content buffering
1630 1630
 					?>
1631 1631
 					<li id="<?php echo $tab_index; ?>Tab">
1632
-						<?php if ( $tab_list ) {
1633
-							$tab_title = '<span class="gd-tab-list-title" ><a href="#' . $tab_index . '">' . __( $detail_page_tab['heading_text'], 'geodirectory' ) . '</a></span><hr />';
1632
+						<?php if ($tab_list) {
1633
+							$tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'], 'geodirectory').'</a></span><hr />';
1634 1634
 							/**
1635 1635
 							 * Filter the tab list title html.
1636 1636
 							 *
@@ -1640,7 +1640,7 @@  discard block
 block discarded – undo
1640 1640
 							 * @param string $tab_index      The tab index type.
1641 1641
 							 * @param array $detail_page_tab The array of values including title text.
1642 1642
 							 */
1643
-							echo apply_filters( 'geodir_tab_list_title', $tab_title, $tab_index, $detail_page_tab );
1643
+							echo apply_filters('geodir_tab_list_title', $tab_title, $tab_index, $detail_page_tab);
1644 1644
 						} ?>
1645 1645
 						<div id="<?php echo $tab_index; ?>" class="hash-offset"></div>
1646 1646
 						<?php
@@ -1651,7 +1651,7 @@  discard block
 block discarded – undo
1651 1651
 						 *
1652 1652
 						 * @param string $tab_index The tab name ID.
1653 1653
 						 */
1654
-						do_action( 'geodir_before_tab_content', $tab_index );
1654
+						do_action('geodir_before_tab_content', $tab_index);
1655 1655
 
1656 1656
 						/**
1657 1657
 						 * Called before the details tab content is output per tab.
@@ -1661,21 +1661,21 @@  discard block
 block discarded – undo
1661 1661
 						 * @since 1.0.0
1662 1662
 						 * @todo  do we need this if we have the hook above? 'geodir_before_tab_content'
1663 1663
 						 */
1664
-						do_action( 'geodir_before_' . $tab_index . '_tab_content' );
1664
+						do_action('geodir_before_'.$tab_index.'_tab_content');
1665 1665
 						/// write a code to generate content of each tab
1666
-						switch ( $tab_index ) {
1666
+						switch ($tab_index) {
1667 1667
 							case 'post_profile':
1668 1668
 								/**
1669 1669
 								 * Called before the listing description content on the details page tab.
1670 1670
 								 *
1671 1671
 								 * @since 1.0.0
1672 1672
 								 */
1673
-								do_action( 'geodir_before_description_on_listing_detail' );
1674
-								if ( geodir_is_page( 'detail' ) ) {
1673
+								do_action('geodir_before_description_on_listing_detail');
1674
+								if (geodir_is_page('detail')) {
1675 1675
 									the_content();
1676 1676
 								} else {
1677 1677
 									/** This action is documented in geodirectory_template_actions.php */
1678
-									echo apply_filters( 'the_content', stripslashes( $post->post_desc ) );
1678
+									echo apply_filters('the_content', stripslashes($post->post_desc));
1679 1679
 								}
1680 1680
 
1681 1681
 								/**
@@ -1683,7 +1683,7 @@  discard block
 block discarded – undo
1683 1683
 								 *
1684 1684
 								 * @since 1.0.0
1685 1685
 								 */
1686
-								do_action( 'geodir_after_description_on_listing_detail' );
1686
+								do_action('geodir_after_description_on_listing_detail');
1687 1687
 								break;
1688 1688
 							case 'post_info':
1689 1689
 								echo $geodir_post_detail_fields;
@@ -1693,32 +1693,32 @@  discard block
 block discarded – undo
1693 1693
 								break;
1694 1694
 							case 'post_video':
1695 1695
 								// some browsers hide $_POST data if used for embeds so we replace with a placeholder
1696
-								if ( $preview ) {
1697
-									if ( $video ) {
1698
-										echo "<span class='gd-video-embed-preview' ><p class='gd-video-preview-text'><i class=\"fa fa-video-camera\" aria-hidden=\"true\"></i><br />" . __( 'Video Preview Placeholder', 'geodirectory' ) . "</p></span>";
1696
+								if ($preview) {
1697
+									if ($video) {
1698
+										echo "<span class='gd-video-embed-preview' ><p class='gd-video-preview-text'><i class=\"fa fa-video-camera\" aria-hidden=\"true\"></i><br />".__('Video Preview Placeholder', 'geodirectory')."</p></span>";
1699 1699
 									}
1700 1700
 								} else {
1701 1701
 
1702 1702
 									// stop payment manager filtering content length
1703
-									$filter_priority = has_filter( 'the_content', 'geodir_payments_the_content' );
1704
-									if ( false !== $filter_priority ) {
1705
-										remove_filter( 'the_content', 'geodir_payments_the_content', $filter_priority );
1703
+									$filter_priority = has_filter('the_content', 'geodir_payments_the_content');
1704
+									if (false !== $filter_priority) {
1705
+										remove_filter('the_content', 'geodir_payments_the_content', $filter_priority);
1706 1706
 									}
1707 1707
 
1708 1708
 									/** This action is documented in geodirectory_template_actions.php */
1709
-									echo apply_filters( 'the_content', stripslashes( $video ) );// we apply the_content filter so oembed works also;
1709
+									echo apply_filters('the_content', stripslashes($video)); // we apply the_content filter so oembed works also;
1710 1710
 
1711
-									if ( false !== $filter_priority ) {
1712
-										add_filter( 'the_content', 'geodir_payments_the_content', $filter_priority );
1711
+									if (false !== $filter_priority) {
1712
+										add_filter('the_content', 'geodir_payments_the_content', $filter_priority);
1713 1713
 									}
1714 1714
 								}
1715 1715
 								break;
1716 1716
 							case 'special_offers':
1717
-								echo apply_filters( 'gd_special_offers_content', wpautop( stripslashes( $special_offers ) ) );
1717
+								echo apply_filters('gd_special_offers_content', wpautop(stripslashes($special_offers)));
1718 1718
 
1719 1719
 								break;
1720 1720
 							case 'post_map':
1721
-								geodir_draw_map( $map_args );
1721
+								geodir_draw_map($map_args);
1722 1722
 								break;
1723 1723
 							case 'reviews':
1724 1724
 								comments_template();
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
 								echo $related_listing;
1728 1728
 								break;
1729 1729
 							default: {
1730
-								if ( ( isset( $post->{$tab_index} ) || ( ! isset( $post->{$tab_index} ) && ( strpos( $tab_index, 'gd_tab_' ) !== false || $tab_index == 'link_business' ) ) ) && ! empty( $detail_page_tab['tab_content'] ) ) {
1730
+								if ((isset($post->{$tab_index} ) || (!isset($post->{$tab_index} ) && (strpos($tab_index, 'gd_tab_') !== false || $tab_index == 'link_business'))) && !empty($detail_page_tab['tab_content'])) {
1731 1731
 									echo $detail_page_tab['tab_content'];
1732 1732
 								}
1733 1733
 							}
@@ -1739,7 +1739,7 @@  discard block
 block discarded – undo
1739 1739
 						 *
1740 1740
 						 * @since 1.0.0
1741 1741
 						 */
1742
-						do_action( 'geodir_after_tab_content', $tab_index );
1742
+						do_action('geodir_after_tab_content', $tab_index);
1743 1743
 
1744 1744
 						/**
1745 1745
 						 * Called after the details tab content is output per tab.
@@ -1749,7 +1749,7 @@  discard block
 block discarded – undo
1749 1749
 						 * @since 1.0.0
1750 1750
 						 * @todo  do we need this if we have the hook above? 'geodir_after_tab_content'
1751 1751
 						 */
1752
-						do_action( 'geodir_after_' . $tab_index . '_tab_content' );
1752
+						do_action('geodir_after_'.$tab_index.'_tab_content');
1753 1753
 						?> </li>
1754 1754
 					<?php
1755 1755
 					/**
@@ -1757,7 +1757,7 @@  discard block
 block discarded – undo
1757 1757
 					 *
1758 1758
 					 * @since 1.0.0
1759 1759
 					 */
1760
-					$arr_detail_page_tabs[ $tab_index ]['tab_content'] = apply_filters( "geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean() );
1760
+					$arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_".$detail_page_tab['tab_content']."_tab_content", ob_get_clean());
1761 1761
 				} // end of if for is_display
1762 1762
 			}// end of foreach
1763 1763
 
@@ -1767,14 +1767,14 @@  discard block
 block discarded – undo
1767 1767
 			 * @since 1.0.0
1768 1768
 			 * @see   'geodir_before_tab_list'
1769 1769
 			 */
1770
-			do_action( 'geodir_after_tab_list' );
1770
+			do_action('geodir_after_tab_list');
1771 1771
 			?>
1772
-			<?php if ( ! $tab_list ){ ?></dl><?php } ?>
1773
-		<ul class="geodir-tabs-content entry-content <?php if ( $tab_list ) { ?>geodir-tabs-list<?php } ?>"
1772
+			<?php if (!$tab_list) { ?></dl><?php } ?>
1773
+		<ul class="geodir-tabs-content entry-content <?php if ($tab_list) { ?>geodir-tabs-list<?php } ?>"
1774 1774
 		    style="position:relative;">
1775 1775
 			<?php
1776
-			foreach ( $arr_detail_page_tabs as $detail_page_tab ) {
1777
-				if ( $detail_page_tab['is_display'] && ! empty( $detail_page_tab['tab_content'] ) ) {
1776
+			foreach ($arr_detail_page_tabs as $detail_page_tab) {
1777
+				if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
1778 1778
 					echo $detail_page_tab['tab_content'];
1779 1779
 				}// end of if
1780 1780
 			}// end of foreach
@@ -1784,11 +1784,11 @@  discard block
 block discarded – undo
1784 1784
 			 *
1785 1785
 			 * @since 1.0.0
1786 1786
 			 */
1787
-			do_action( 'geodir_add_tab_content' ); ?>
1787
+			do_action('geodir_add_tab_content'); ?>
1788 1788
 		</ul>
1789 1789
 		<!--gd-tabs-content ul end-->
1790 1790
 	</div>
1791
-	<?php if ( ! $tab_list ) { ?>
1791
+	<?php if (!$tab_list) { ?>
1792 1792
 		<script>
1793 1793
 			if (window.location.hash && window.location.hash.indexOf('&') === -1 && jQuery(window.location.hash + 'Tab').length) {
1794 1794
 				hashVal = window.location.hash;
@@ -1820,31 +1820,31 @@  discard block
 block discarded – undo
1820 1820
  *
1821 1821
  * @return mixed Image file.
1822 1822
  */
1823
-function geodir_exif( $file ) {
1824
-	if ( empty( $file ) || ! is_array( $file ) ) {
1823
+function geodir_exif($file) {
1824
+	if (empty($file) || !is_array($file)) {
1825 1825
 		return $file;
1826 1826
 	}
1827 1827
 
1828
-	$file_path = ! empty( $file['tmp_name'] ) ? sanitize_text_field( $file['tmp_name'] ) : '';
1829
-	if ( ! ( $file_path && file_exists( $file_path ) ) ) {
1828
+	$file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : '';
1829
+	if (!($file_path && file_exists($file_path))) {
1830 1830
 		return $file;
1831 1831
 	}
1832 1832
 	$file['file'] = $file_path;
1833 1833
 
1834
-	if ( ! file_is_valid_image( $file_path ) ) {
1834
+	if (!file_is_valid_image($file_path)) {
1835 1835
 		return $file; // Bail if file is not an image.
1836 1836
 	}
1837 1837
 
1838
-	if ( ! function_exists( 'wp_get_image_editor' ) ) {
1838
+	if (!function_exists('wp_get_image_editor')) {
1839 1839
 		return $file;
1840 1840
 	}
1841 1841
 
1842 1842
 	$mime_type = $file['type'];
1843 1843
 	$exif      = array();
1844
-	if ( $mime_type == 'image/jpeg' && function_exists( 'exif_read_data' ) ) {
1844
+	if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1845 1845
 		try {
1846
-			$exif = exif_read_data( $file_path );
1847
-		} catch ( Exception $e ) {
1846
+			$exif = exif_read_data($file_path);
1847
+		} catch (Exception $e) {
1848 1848
 			$exif = array();
1849 1849
 		}
1850 1850
 	}
@@ -1853,13 +1853,13 @@  discard block
 block discarded – undo
1853 1853
 	$flip        = false;
1854 1854
 	$modify      = false;
1855 1855
 	$orientation = 0;
1856
-	if ( ! empty( $exif ) && isset( $exif['Orientation'] ) ) {
1857
-		switch ( (int) $exif['Orientation'] ) {
1856
+	if (!empty($exif) && isset($exif['Orientation'])) {
1857
+		switch ((int) $exif['Orientation']) {
1858 1858
 			case 1:
1859 1859
 				// do nothing
1860 1860
 				break;
1861 1861
 			case 2:
1862
-				$flip   = array( false, true );
1862
+				$flip   = array(false, true);
1863 1863
 				$modify = true;
1864 1864
 				break;
1865 1865
 			case 3:
@@ -1868,13 +1868,13 @@  discard block
 block discarded – undo
1868 1868
 				$modify      = true;
1869 1869
 				break;
1870 1870
 			case 4:
1871
-				$flip   = array( true, false );
1871
+				$flip   = array(true, false);
1872 1872
 				$modify = true;
1873 1873
 				break;
1874 1874
 			case 5:
1875 1875
 				$orientation = - 90;
1876 1876
 				$rotate      = true;
1877
-				$flip        = array( false, true );
1877
+				$flip        = array(false, true);
1878 1878
 				$modify      = true;
1879 1879
 				break;
1880 1880
 			case 6:
@@ -1885,7 +1885,7 @@  discard block
 block discarded – undo
1885 1885
 			case 7:
1886 1886
 				$orientation = - 270;
1887 1887
 				$rotate      = true;
1888
-				$flip        = array( false, true );
1888
+				$flip        = array(false, true);
1889 1889
 				$modify      = true;
1890 1890
 				break;
1891 1891
 			case 8:
@@ -1911,31 +1911,31 @@  discard block
 block discarded – undo
1911 1911
 	 * @param int|null $quality Image Compression quality between 1-100% scale. Default null.
1912 1912
 	 * @param string $quality   Image mime type.
1913 1913
 	 */
1914
-	$quality = apply_filters( 'geodir_image_upload_set_quality', $quality, $mime_type );
1915
-	if ( $quality !== null ) {
1914
+	$quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
1915
+	if ($quality !== null) {
1916 1916
 		$modify = true;
1917 1917
 	}
1918 1918
 
1919
-	if ( ! $modify ) {
1919
+	if (!$modify) {
1920 1920
 		return $file; // no change
1921 1921
 	}
1922 1922
 
1923
-	$image = wp_get_image_editor( $file_path );
1924
-	if ( ! is_wp_error( $image ) ) {
1925
-		if ( $rotate ) {
1926
-			$image->rotate( $orientation );
1923
+	$image = wp_get_image_editor($file_path);
1924
+	if (!is_wp_error($image)) {
1925
+		if ($rotate) {
1926
+			$image->rotate($orientation);
1927 1927
 		}
1928 1928
 
1929
-		if ( ! empty( $flip ) ) {
1930
-			$image->flip( $flip[0], $flip[1] );
1929
+		if (!empty($flip)) {
1930
+			$image->flip($flip[0], $flip[1]);
1931 1931
 		}
1932 1932
 
1933
-		if ( $quality !== null ) {
1934
-			$image->set_quality( (int) $quality );
1933
+		if ($quality !== null) {
1934
+			$image->set_quality((int) $quality);
1935 1935
 		}
1936 1936
 
1937
-		$result = $image->save( $file_path );
1938
-		if ( ! is_wp_error( $result ) ) {
1937
+		$result = $image->save($file_path);
1938
+		if (!is_wp_error($result)) {
1939 1939
 			$file['file']     = $result['path'];
1940 1940
 			$file['tmp_name'] = $result['path'];
1941 1941
 		}
@@ -1962,7 +1962,7 @@  discard block
 block discarded – undo
1962 1962
  *
1963 1963
  * @return string Returns the recent reviews html.
1964 1964
  */
1965
-function geodir_get_recent_reviews( $g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false ) {
1965
+function geodir_get_recent_reviews($g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false) {
1966 1966
 	global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session;
1967 1967
 	$tablecomments = $wpdb->comments;
1968 1968
 	$tableposts    = $wpdb->posts;
@@ -1972,28 +1972,28 @@  discard block
 block discarded – undo
1972 1972
 	$region_filter  = '';
1973 1973
 	$country_filter = '';
1974 1974
 
1975
-	if ( $gd_session->get( 'gd_multi_location' ) ) {
1976
-		if ( $gd_ses_country = $gd_session->get( 'gd_country' ) ) {
1977
-			$country_filter = $wpdb->prepare( " AND r.post_country=%s ", str_replace( "-", " ", $gd_ses_country ) );
1975
+	if ($gd_session->get('gd_multi_location')) {
1976
+		if ($gd_ses_country = $gd_session->get('gd_country')) {
1977
+			$country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
1978 1978
 		}
1979 1979
 
1980
-		if ( $gd_ses_region = $gd_session->get( 'gd_region' ) ) {
1981
-			$region_filter = $wpdb->prepare( " AND r.post_region=%s ", str_replace( "-", " ", $gd_ses_region ) );
1980
+		if ($gd_ses_region = $gd_session->get('gd_region')) {
1981
+			$region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
1982 1982
 		}
1983 1983
 
1984
-		if ( $gd_ses_city = $gd_session->get( 'gd_city' ) ) {
1985
-			$city_filter = $wpdb->prepare( " AND r.post_city=%s ", str_replace( "-", " ", $gd_ses_city ) );
1984
+		if ($gd_ses_city = $gd_session->get('gd_city')) {
1985
+			$city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
1986 1986
 		}
1987 1987
 	}
1988 1988
 
1989 1989
 	$review_table = GEODIR_REVIEW_TABLE;
1990 1990
 	$request      = "SELECT r.id as ID, r.post_type, r.comment_id as comment_ID, r.post_date as comment_date,r.overall_rating, r.user_id, r.post_id FROM $review_table as r WHERE r.post_status = 1 AND r.status =1 AND r.overall_rating>=1 $country_filter $region_filter $city_filter ORDER BY r.post_date DESC, r.id DESC LIMIT $no_comments";
1991 1991
 
1992
-	$comments = $wpdb->get_results( $request );
1992
+	$comments = $wpdb->get_results($request);
1993 1993
 
1994
-	foreach ( $comments as $comment ) {
1994
+	foreach ($comments as $comment) {
1995 1995
 		// Set the extra comment info needed.
1996
-		$comment_extra = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID" );
1996
+		$comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
1997 1997
 		//echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID";
1998 1998
 		$comment->comment_content      = $comment_extra->comment_content;
1999 1999
 		$comment->comment_author       = $comment_extra->comment_author;
@@ -2001,75 +2001,75 @@  discard block
 block discarded – undo
2001 2001
 
2002 2002
 		$comment_id      = '';
2003 2003
 		$comment_id      = $comment->comment_ID;
2004
-		$comment_content = strip_tags( $comment->comment_content );
2004
+		$comment_content = strip_tags($comment->comment_content);
2005 2005
 
2006
-		$comment_content = preg_replace( '#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content );
2006
+		$comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
2007 2007
 
2008
-		$permalink            = get_permalink( $comment->ID ) . "#comment-" . $comment->comment_ID;
2008
+		$permalink            = get_permalink($comment->ID)."#comment-".$comment->comment_ID;
2009 2009
 		$comment_author_email = $comment->comment_author_email;
2010 2010
 		$comment_post_ID      = $comment->post_id;
2011 2011
 
2012 2012
 		$na = true;
2013
-		if ( function_exists( 'icl_object_id' ) && icl_object_id( $comment_post_ID, $comment->post_type, true ) ) {
2014
-			$comment_post_ID2 = icl_object_id( $comment_post_ID, $comment->post_type, false );
2015
-			if ( $comment_post_ID == $comment_post_ID2 ) {
2013
+		if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
2014
+			$comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false);
2015
+			if ($comment_post_ID == $comment_post_ID2) {
2016 2016
 			} else {
2017 2017
 				$na = false;
2018 2018
 			}
2019 2019
 		}
2020 2020
 
2021
-		$post_title        = get_the_title( $comment_post_ID );
2022
-		$permalink         = get_permalink( $comment_post_ID );
2023
-		$comment_permalink = $permalink . "#comment-" . $comment->comment_ID;
2024
-		$read_more         = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __( 'Read more', 'geodirectory' ) . '</a>';
2021
+		$post_title        = get_the_title($comment_post_ID);
2022
+		$permalink         = get_permalink($comment_post_ID);
2023
+		$comment_permalink = $permalink."#comment-".$comment->comment_ID;
2024
+		$read_more         = '<a class="comment_excerpt" href="'.$comment_permalink.'">'.__('Read more', 'geodirectory').'</a>';
2025 2025
 
2026
-		$comment_content_length = strlen( $comment_content );
2027
-		if ( $comment_content_length > $comment_lenth ) {
2028
-			$comment_excerpt = geodir_utf8_substr( $comment_content, 0, $comment_lenth ) . '... ' . $read_more;
2026
+		$comment_content_length = strlen($comment_content);
2027
+		if ($comment_content_length > $comment_lenth) {
2028
+			$comment_excerpt = geodir_utf8_substr($comment_content, 0, $comment_lenth).'... '.$read_more;
2029 2029
 		} else {
2030 2030
 			$comment_excerpt = $comment_content;
2031 2031
 		}
2032 2032
 
2033
-		if ( $comment->user_id ) {
2034
-			$user_profile_url = get_author_posts_url( $comment->user_id );
2033
+		if ($comment->user_id) {
2034
+			$user_profile_url = get_author_posts_url($comment->user_id);
2035 2035
 		} else {
2036 2036
 			$user_profile_url = '';
2037 2037
 		}
2038 2038
 
2039
-		if ( $comment_id && $na ) {
2039
+		if ($comment_id && $na) {
2040 2040
 			$comments_echo .= '<li class="clearfix">';
2041
-			$comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">";
2042
-			if ( function_exists( 'get_avatar' ) ) {
2043
-				if ( ! isset( $comment->comment_type ) ) {
2044
-					if ( $user_profile_url ) {
2045
-						$comments_echo .= '<a href="' . $user_profile_url . '">';
2041
+			$comments_echo .= "<span class=\"li".$comment_id." geodir_reviewer_image\">";
2042
+			if (function_exists('get_avatar')) {
2043
+				if (!isset($comment->comment_type)) {
2044
+					if ($user_profile_url) {
2045
+						$comments_echo .= '<a href="'.$user_profile_url.'">';
2046 2046
 					}
2047
-					$comments_echo .= get_avatar( $comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' );
2048
-					if ( $user_profile_url ) {
2047
+					$comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png');
2048
+					if ($user_profile_url) {
2049 2049
 						$comments_echo .= '</a>';
2050 2050
 					}
2051
-				} elseif ( ( isset( $comment->comment_type ) && $comment->comment_type == 'trackback' ) || ( isset( $comment->comment_type ) && $comment->comment_type == 'pingback' ) ) {
2052
-					if ( $user_profile_url ) {
2053
-						$comments_echo .= '<a href="' . $user_profile_url . '">';
2051
+				} elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
2052
+					if ($user_profile_url) {
2053
+						$comments_echo .= '<a href="'.$user_profile_url.'">';
2054 2054
 					}
2055
-					$comments_echo .= get_avatar( $comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' );
2055
+					$comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png');
2056 2056
 				}
2057
-			} elseif ( function_exists( 'gravatar' ) ) {
2058
-				if ( $user_profile_url ) {
2059
-					$comments_echo .= '<a href="' . $user_profile_url . '">';
2057
+			} elseif (function_exists('gravatar')) {
2058
+				if ($user_profile_url) {
2059
+					$comments_echo .= '<a href="'.$user_profile_url.'">';
2060 2060
 				}
2061 2061
 				$comments_echo .= "<img src=\"";
2062
-				if ( '' == $comment->comment_type ) {
2063
-					$comments_echo .= gravatar( $comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' );
2064
-					if ( $user_profile_url ) {
2062
+				if ('' == $comment->comment_type) {
2063
+					$comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png');
2064
+					if ($user_profile_url) {
2065 2065
 						$comments_echo .= '</a>';
2066 2066
 					}
2067
-				} elseif ( ( 'trackback' == $comment->comment_type ) || ( 'pingback' == $comment->comment_type ) ) {
2068
-					if ( $user_profile_url ) {
2069
-						$comments_echo .= '<a href="' . $user_profile_url . '">';
2067
+				} elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
2068
+					if ($user_profile_url) {
2069
+						$comments_echo .= '<a href="'.$user_profile_url.'">';
2070 2070
 					}
2071
-					$comments_echo .= gravatar( $comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' );
2072
-					if ( $user_profile_url ) {
2071
+					$comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png');
2072
+					if ($user_profile_url) {
2073 2073
 						$comments_echo .= '</a>';
2074 2074
 					}
2075 2075
 				}
@@ -2079,17 +2079,17 @@  discard block
 block discarded – undo
2079 2079
 			$comments_echo .= "</span>\n";
2080 2080
 
2081 2081
 			$comments_echo .= '<span class="geodir_reviewer_content">';
2082
-			if ( $comment->user_id ) {
2083
-				$comments_echo .= '<a href="' . get_author_posts_url( $comment->user_id ) . '">';
2082
+			if ($comment->user_id) {
2083
+				$comments_echo .= '<a href="'.get_author_posts_url($comment->user_id).'">';
2084 2084
 			}
2085
-			$comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> ';
2086
-			if ( $comment->user_id ) {
2085
+			$comments_echo .= '<span class="geodir_reviewer_author">'.$comment->comment_author.'</span> ';
2086
+			if ($comment->user_id) {
2087 2087
 				$comments_echo .= '</a>';
2088 2088
 			}
2089
-			$comments_echo .= '<span class="geodir_reviewer_reviewed">' . __( 'reviewed', 'geodirectory' ) . '</span> ';
2090
-			$comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>';
2091
-			$comments_echo .= geodir_get_rating_stars( $comment->overall_rating, $comment_post_ID );
2092
-			$comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . '';
2089
+			$comments_echo .= '<span class="geodir_reviewer_reviewed">'.__('reviewed', 'geodirectory').'</span> ';
2090
+			$comments_echo .= '<a href="'.$permalink.'" class="geodir_reviewer_title">'.$post_title.'</a>';
2091
+			$comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
2092
+			$comments_echo .= '<p class="geodir_reviewer_text">'.$comment_excerpt.'';
2093 2093
 			//echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
2094 2094
 			$comments_echo .= '</p>';
2095 2095
 
@@ -2109,25 +2109,25 @@  discard block
 block discarded – undo
2109 2109
  * @return array Returns post categories as an array.
2110 2110
  */
2111 2111
 function geodir_home_map_cats_key_value_array() {
2112
-	$post_types = geodir_get_posttypes( 'object' );
2112
+	$post_types = geodir_get_posttypes('object');
2113 2113
 
2114 2114
 	$return = array();
2115
-	if ( ! empty( $post_types ) ) {
2116
-		foreach ( $post_types as $key => $post_type ) {
2117
-			$cpt_name       = __( $post_type->labels->singular_name, 'geodirectory' );
2118
-			$post_type_name = sprintf( __( '%s Categories', 'geodirectory' ), $cpt_name );
2119
-			$taxonomies     = geodir_get_taxonomies( $key );
2120
-			$cat_taxonomy   = ! empty( $taxonomies[0] ) ? $taxonomies[0] : null;
2121
-			$cat_terms      = $cat_taxonomy ? get_terms( $cat_taxonomy ) : null;
2122
-
2123
-			if ( ! empty( $cat_terms ) ) {
2124
-				$return[ 'optgroup_start-' . $key ] = $post_type_name;
2125
-
2126
-				foreach ( $cat_terms as $cat_term ) {
2127
-					$return[ $key . '_' . $cat_term->term_id ] = $cat_term->name;
2115
+	if (!empty($post_types)) {
2116
+		foreach ($post_types as $key => $post_type) {
2117
+			$cpt_name       = __($post_type->labels->singular_name, 'geodirectory');
2118
+			$post_type_name = sprintf(__('%s Categories', 'geodirectory'), $cpt_name);
2119
+			$taxonomies     = geodir_get_taxonomies($key);
2120
+			$cat_taxonomy   = !empty($taxonomies[0]) ? $taxonomies[0] : null;
2121
+			$cat_terms      = $cat_taxonomy ? get_terms($cat_taxonomy) : null;
2122
+
2123
+			if (!empty($cat_terms)) {
2124
+				$return['optgroup_start-'.$key] = $post_type_name;
2125
+
2126
+				foreach ($cat_terms as $cat_term) {
2127
+					$return[$key.'_'.$cat_term->term_id] = $cat_term->name;
2128 2128
 				}
2129 2129
 
2130
-				$return[ 'optgroup_end-' . $key ] = $post_type_name;
2130
+				$return['optgroup_end-'.$key] = $post_type_name;
2131 2131
 			}
2132 2132
 		}
2133 2133
 	}
@@ -2143,14 +2143,14 @@  discard block
 block discarded – undo
2143 2143
  * @package GeoDirectory
2144 2144
  */
2145 2145
 function geodir_twitter_tweet_button() {
2146
-	if ( isset( $_GET['gde'] ) ) {
2147
-		$link = '?url=' . urlencode( geodir_curPageURL() );
2146
+	if (isset($_GET['gde'])) {
2147
+		$link = '?url='.urlencode(geodir_curPageURL());
2148 2148
 	} else {
2149 2149
 		$link = '';
2150 2150
 	}
2151 2151
 	?>
2152 2152
 	<a href="http://twitter.com/share<?php echo $link; ?>"
2153
-	   class="twitter-share-button"><?php _e( 'Tweet', 'geodirectory' ); ?></a>
2153
+	   class="twitter-share-button"><?php _e('Tweet', 'geodirectory'); ?></a>
2154 2154
 	<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
2155 2155
 	<?php
2156 2156
 }
@@ -2167,10 +2167,10 @@  discard block
 block discarded – undo
2167 2167
 function geodir_fb_like_button() {
2168 2168
 	global $post;
2169 2169
 	?>
2170
-	<iframe <?php if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) ) {
2170
+	<iframe <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
2171 2171
 		echo 'allowtransparency="true"';
2172 2172
 	} ?> class="facebook"
2173
-	     src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode( get_permalink( $post->ID ) ); ?>&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light"
2173
+	     src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light"
2174 2174
 	     style="border:none; overflow:hidden; width:100px; height:20px"></iframe>
2175 2175
 	<?php
2176 2176
 }
@@ -2201,7 +2201,7 @@  discard block
 block discarded – undo
2201 2201
 
2202 2202
 
2203 2203
 function geodir_listing_bounce_map_pin_on_hover() {
2204
-	if ( get_option( 'geodir_listing_hover_bounce_map_pin', true ) ) {
2204
+	if (get_option('geodir_listing_hover_bounce_map_pin', true)) {
2205 2205
 		?>
2206 2206
 		<script>
2207 2207
 			jQuery(function ($) {
@@ -2224,44 +2224,44 @@  discard block
 block discarded – undo
2224 2224
 	}
2225 2225
 }
2226 2226
 
2227
-add_action( 'geodir_after_listing_listview', 'geodir_listing_bounce_map_pin_on_hover', 10 );
2227
+add_action('geodir_after_listing_listview', 'geodir_listing_bounce_map_pin_on_hover', 10);
2228 2228
 
2229
-add_action( 'geodir_after_favorite_html', 'geodir_output_favourite_html_listings', 1, 1 );
2230
-function geodir_output_favourite_html_listings( $post_id ) {
2231
-	geodir_favourite_html( '', $post_id );
2229
+add_action('geodir_after_favorite_html', 'geodir_output_favourite_html_listings', 1, 1);
2230
+function geodir_output_favourite_html_listings($post_id) {
2231
+	geodir_favourite_html('', $post_id);
2232 2232
 }
2233 2233
 
2234
-add_action( 'geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2 );
2235
-function geodir_output_pinpoint_html_listings( $post_id, $post = array() ) {
2234
+add_action('geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2);
2235
+function geodir_output_pinpoint_html_listings($post_id, $post = array()) {
2236 2236
 	global $wp_query;
2237 2237
 
2238 2238
 	$show_pin_point = $wp_query->is_main_query();
2239 2239
 
2240
-	if ( ! empty( $post ) && ! empty( $show_pin_point ) && is_active_widget( false, "", "geodir_map_v3_listing_map" ) ) {
2241
-		$term_icon_url = geodir_get_tax_meta( $post->default_category, 'ct_cat_icon', false, $post->post_type );
2242
-		$marker_icon   = isset( $term_icon_url['src'] ) ? $term_icon_url['src'] : get_option( 'geodir_default_marker_icon' );
2240
+	if (!empty($post) && !empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
2241
+		$term_icon_url = geodir_get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type);
2242
+		$marker_icon   = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
2243 2243
 		?>
2244 2244
 		<span class="geodir-pinpoint"
2245
-		      style="background:url('<?php echo $marker_icon; ?>') no-repeat scroll left top transparent;background-size:auto 100%; -webkit-background-size:auto 100%;-moz-background-size:auto 100%;height:9px;width:14px;"><?php echo apply_filters( 'geodir_listing_listview_pinpoint_inner_content', '', 'listing' ); ?></span>
2245
+		      style="background:url('<?php echo $marker_icon; ?>') no-repeat scroll left top transparent;background-size:auto 100%; -webkit-background-size:auto 100%;-moz-background-size:auto 100%;height:9px;width:14px;"><?php echo apply_filters('geodir_listing_listview_pinpoint_inner_content', '', 'listing'); ?></span>
2246 2246
 		<a class="geodir-pinpoint-link" href="javascript:void(0)"
2247 2247
 		   onclick="if(typeof openMarker=='function'){openMarker('listing_map_canvas' ,'<?php echo $post->ID; ?>')}"
2248 2248
 		   onmouseover="if(typeof animate_marker=='function'){animate_marker('listing_map_canvas' ,'<?php echo $post->ID; ?>')}"
2249
-		   onmouseout="if(typeof stop_marker_animation=='function'){stop_marker_animation('listing_map_canvas' ,'<?php echo $post->ID; ?>')}"><?php _e( 'Pinpoint', 'geodirectory' ); ?></a>
2249
+		   onmouseout="if(typeof stop_marker_animation=='function'){stop_marker_animation('listing_map_canvas' ,'<?php echo $post->ID; ?>')}"><?php _e('Pinpoint', 'geodirectory'); ?></a>
2250 2250
 		<?php
2251 2251
 	}
2252 2252
 }
2253 2253
 
2254 2254
 function geodir_search_form_submit_button() {
2255 2255
 
2256
-	$new_style = get_option( 'geodir_show_search_old_search_from' ) ? false : true;
2256
+	$new_style = get_option('geodir_show_search_old_search_from') ? false : true;
2257 2257
 
2258
-	if ( $new_style ) {
2258
+	if ($new_style) {
2259 2259
 		$default_search_button_label = '<i class="fa fa-search" aria-hidden="true"></i>';
2260
-	}else{
2260
+	} else {
2261 2261
 		$default_search_button_label = 'Search';
2262 2262
 	}
2263
-	if ( get_option( 'geodir_search_button_label' ) && get_option( 'geodir_search_button_label' ) != 'Search' ) {
2264
-		$default_search_button_label = __( get_option( 'geodir_search_button_label' ), 'geodirectory' );
2263
+	if (get_option('geodir_search_button_label') && get_option('geodir_search_button_label') != 'Search') {
2264
+		$default_search_button_label = __(get_option('geodir_search_button_label'), 'geodirectory');
2265 2265
 	}
2266 2266
 
2267 2267
 	/**
@@ -2273,78 +2273,78 @@  discard block
 block discarded – undo
2273 2273
 	 *
2274 2274
 	 * @param string $default_search_button_label The current search button text.
2275 2275
 	 */
2276
-	$default_search_button_label = apply_filters( 'geodir_search_default_search_button_text', $default_search_button_label );
2276
+	$default_search_button_label = apply_filters('geodir_search_default_search_button_text', $default_search_button_label);
2277 2277
 
2278 2278
 	$fa_class = '';
2279
-	if ( strpos( $default_search_button_label, '&#' ) !== false ) {
2279
+	if (strpos($default_search_button_label, '&#') !== false) {
2280 2280
 		$fa_class = 'fa';
2281 2281
 	}
2282 2282
 
2283 2283
 
2284
-	if ( $new_style ) {
2284
+	if ($new_style) {
2285 2285
 	?>
2286
-		<button class="geodir_submit_search <?php echo $fa_class; ?>"><?php _e( $default_search_button_label ,'geodirectory'); ?></button>
2287
-<?php }else{?>
2288
-		<input type="button" value="<?php esc_attr_e( $default_search_button_label ); ?>"
2286
+		<button class="geodir_submit_search <?php echo $fa_class; ?>"><?php _e($default_search_button_label, 'geodirectory'); ?></button>
2287
+<?php } else {?>
2288
+		<input type="button" value="<?php esc_attr_e($default_search_button_label); ?>"
2289 2289
 	       class="geodir_submit_search <?php echo $fa_class; ?>"/>
2290 2290
 	<?php }
2291 2291
 }
2292 2292
 
2293
-add_action( 'geodir_before_search_button', 'geodir_search_form_submit_button', 5000 );
2293
+add_action('geodir_before_search_button', 'geodir_search_form_submit_button', 5000);
2294 2294
 
2295 2295
 function geodir_search_form_post_type_input() {
2296 2296
 	global $geodir_search_post_type;
2297
-	$post_types     = apply_filters( 'geodir_search_form_post_types', geodir_get_posttypes( 'object' ) );
2297
+	$post_types     = apply_filters('geodir_search_form_post_types', geodir_get_posttypes('object'));
2298 2298
 	$curr_post_type = $geodir_search_post_type;
2299 2299
 
2300
-	if ( ! empty( $post_types ) && count( (array) $post_types ) > 1 ) {
2300
+	if (!empty($post_types) && count((array) $post_types) > 1) {
2301 2301
 
2302
-		foreach ( $post_types as $post_type => $info ){
2302
+		foreach ($post_types as $post_type => $info) {
2303 2303
 			global $wpdb;
2304
-			$has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
2305
-			if ( ! $has_posts ) {
2304
+			$has_posts = $wpdb->get_row($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type));
2305
+			if (!$has_posts) {
2306 2306
 				unset($post_types->{$post_type});
2307 2307
 			}
2308 2308
 		}
2309 2309
 
2310
-		if ( ! empty( $post_types ) && count( (array) $post_types ) > 1 ) {
2310
+		if (!empty($post_types) && count((array) $post_types) > 1) {
2311 2311
 
2312
-			$new_style = get_option( 'geodir_show_search_old_search_from' ) ? false : true;
2313
-			if ( $new_style ) {
2312
+			$new_style = get_option('geodir_show_search_old_search_from') ? false : true;
2313
+			if ($new_style) {
2314 2314
 				echo "<div class='gd-search-input-wrapper gd-search-field-cpt'>";
2315 2315
 			}
2316 2316
 			?>
2317 2317
 			<select name="stype" class="search_by_post">
2318
-				<?php foreach ( $post_types as $post_type => $info ):
2318
+				<?php foreach ($post_types as $post_type => $info):
2319 2319
 					global $wpdb;
2320 2320
 					?>
2321 2321
 
2322
-					<option data-label="<?php echo get_post_type_archive_link( $post_type ); ?>"
2323
-					        value="<?php echo $post_type; ?>" <?php if ( isset( $_REQUEST['stype'] ) ) {
2324
-						if ( $post_type == $_REQUEST['stype'] ) {
2322
+					<option data-label="<?php echo get_post_type_archive_link($post_type); ?>"
2323
+					        value="<?php echo $post_type; ?>" <?php if (isset($_REQUEST['stype'])) {
2324
+						if ($post_type == $_REQUEST['stype']) {
2325 2325
 							echo 'selected="selected"';
2326 2326
 						}
2327
-					} elseif ( $curr_post_type == $post_type ) {
2327
+					} elseif ($curr_post_type == $post_type) {
2328 2328
 						echo 'selected="selected"';
2329
-					} ?>><?php _e( geodir_utf8_ucfirst( $info->labels->name ), 'geodirectory' ); ?></option>
2329
+					} ?>><?php _e(geodir_utf8_ucfirst($info->labels->name), 'geodirectory'); ?></option>
2330 2330
 
2331 2331
 				<?php endforeach; ?>
2332 2332
 			</select>
2333 2333
 			<?php
2334
-			if ( $new_style ) {
2334
+			if ($new_style) {
2335 2335
 				echo "</div>";
2336 2336
 			}
2337
-		}else{
2338
-			if(! empty( $post_types )){
2339
-				$pt_arr = (array)$post_types;
2340
-				echo '<input type="hidden" name="stype" value="' . key( $pt_arr  ) . '"  />';
2341
-			}else{
2337
+		} else {
2338
+			if (!empty($post_types)) {
2339
+				$pt_arr = (array) $post_types;
2340
+				echo '<input type="hidden" name="stype" value="'.key($pt_arr).'"  />';
2341
+			} else {
2342 2342
 				echo '<input type="hidden" name="stype" value="gd_place"  />';
2343 2343
 			}
2344 2344
 
2345 2345
 		}
2346 2346
 
2347
-	}elseif ( ! empty( $post_types ) ) {
2347
+	}elseif (!empty($post_types)) {
2348 2348
 		echo '<input type="hidden" name="stype" value="gd_place"  />';
2349 2349
 	}
2350 2350
 }
@@ -2352,26 +2352,26 @@  discard block
 block discarded – undo
2352 2352
 function geodir_search_form_search_input() {
2353 2353
 
2354 2354
 	$default_search_for_text = SEARCH_FOR_TEXT;
2355
-	if ( get_option( 'geodir_search_field_default_text' ) ) {
2356
-		$default_search_for_text = __( get_option( 'geodir_search_field_default_text' ), 'geodirectory' );
2355
+	if (get_option('geodir_search_field_default_text')) {
2356
+		$default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
2357 2357
 	}
2358 2358
 
2359 2359
 	$new_style = get_option('geodir_show_search_old_search_from') ? false : true;
2360
-	if($new_style){
2360
+	if ($new_style) {
2361 2361
 		echo "<div class='gd-search-input-wrapper gd-search-field-search'>";
2362 2362
 	}
2363 2363
 	?>
2364 2364
 	<input class="search_text" name="s"
2365
-	       value="<?php if ( isset( $_REQUEST['s'] ) && trim( $_REQUEST['s'] ) != '' ) {
2366
-		       echo esc_attr( stripslashes_deep( $_REQUEST['s'] ) );
2365
+	       value="<?php if (isset($_REQUEST['s']) && trim($_REQUEST['s']) != '') {
2366
+		       echo esc_attr(stripslashes_deep($_REQUEST['s']));
2367 2367
 	       } else {
2368 2368
 		       echo $default_search_for_text;
2369 2369
 	       } ?>" type="text"
2370
-	       onblur="if (this.value.trim() == '') {this.value = '<?php echo esc_sql( $default_search_for_text ); ?>';}"
2371
-	       onfocus="if (this.value == '<?php echo esc_sql( $default_search_for_text ); ?>') {this.value = '';}"
2370
+	       onblur="if (this.value.trim() == '') {this.value = '<?php echo esc_sql($default_search_for_text); ?>';}"
2371
+	       onfocus="if (this.value == '<?php echo esc_sql($default_search_for_text); ?>') {this.value = '';}"
2372 2372
 	       onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);">
2373 2373
 	<?php
2374
-	if($new_style){
2374
+	if ($new_style) {
2375 2375
 		echo "</div>";
2376 2376
 	}
2377 2377
 }
@@ -2379,12 +2379,12 @@  discard block
 block discarded – undo
2379 2379
 function geodir_search_form_near_input() {
2380 2380
 
2381 2381
 	$default_near_text = NEAR_TEXT;
2382
-	if ( get_option( 'geodir_near_field_default_text' ) ) {
2383
-		$default_near_text = __( get_option( 'geodir_near_field_default_text' ), 'geodirectory' );
2382
+	if (get_option('geodir_near_field_default_text')) {
2383
+		$default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
2384 2384
 	}
2385 2385
 
2386
-	if ( isset( $_REQUEST['snear'] ) && $_REQUEST['snear'] != '' ) {
2387
-		$near = esc_attr( stripslashes_deep( $_REQUEST['snear'] ) );
2386
+	if (isset($_REQUEST['snear']) && $_REQUEST['snear'] != '') {
2387
+		$near = esc_attr(stripslashes_deep($_REQUEST['snear']));
2388 2388
 	} else {
2389 2389
 		$near = $default_near_text;
2390 2390
 	}
@@ -2398,7 +2398,7 @@  discard block
 block discarded – undo
2398 2398
 	 * @since 1.6.9
2399 2399
 	 * @param string $curr_post_type The current post type.
2400 2400
 	 */
2401
-	$near_input_extra = apply_filters('geodir_near_input_extra','',$curr_post_type);
2401
+	$near_input_extra = apply_filters('geodir_near_input_extra', '', $curr_post_type);
2402 2402
 
2403 2403
 
2404 2404
 	/**
@@ -2411,7 +2411,7 @@  discard block
 block discarded – undo
2411 2411
 	 * @param string $near              The current near value.
2412 2412
 	 * @param string $default_near_text The default near value.
2413 2413
 	 */
2414
-	$near = apply_filters( 'geodir_search_near_text', $near, $default_near_text );
2414
+	$near = apply_filters('geodir_search_near_text', $near, $default_near_text);
2415 2415
 	/**
2416 2416
 	 * Filter the default "Near" text value for the search form.
2417 2417
 	 *
@@ -2422,7 +2422,7 @@  discard block
 block discarded – undo
2422 2422
 	 * @param string $near              The current near value.
2423 2423
 	 * @param string $default_near_text The default near value.
2424 2424
 	 */
2425
-	$default_near_text = apply_filters( 'geodir_search_default_near_text', $default_near_text, $near );
2425
+	$default_near_text = apply_filters('geodir_search_default_near_text', $default_near_text, $near);
2426 2426
 	/**
2427 2427
 	 * Filter the class for the near search input.
2428 2428
 	 *
@@ -2430,10 +2430,10 @@  discard block
 block discarded – undo
2430 2430
 	 *
2431 2431
 	 * @param string $class The class for the HTML near input, default is blank.
2432 2432
 	 */
2433
-	$near_class = apply_filters( 'geodir_search_near_class', '' );
2433
+	$near_class = apply_filters('geodir_search_near_class', '');
2434 2434
 
2435 2435
 	$new_style = get_option('geodir_show_search_old_search_from') ? false : true;
2436
-	if($new_style){
2436
+	if ($new_style) {
2437 2437
 		echo "<div class='gd-search-input-wrapper gd-search-field-near' $near_input_extra>";
2438 2438
 		
2439 2439
 		do_action('geodir_before_near_input');
@@ -2441,30 +2441,30 @@  discard block
 block discarded – undo
2441 2441
 
2442 2442
 	?>
2443 2443
 	<input name="snear" class="snear <?php echo $near_class; ?>" type="text" value="<?php echo $near; ?>"
2444
-	       onblur="if (this.value.trim() == '') {this.value = ('<?php echo esc_sql( $near ); ?>' != '' ? '<?php echo esc_sql( $near ); ?>' : '<?php echo $default_near_text; ?>');}"
2445
-	       onfocus="if (this.value == '<?php echo $default_near_text; ?>' || this.value =='<?php echo esc_sql( $near ); ?>') {this.value = '';}"
2446
-	       onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);" <?php echo $near_input_extra;?>/>
2444
+	       onblur="if (this.value.trim() == '') {this.value = ('<?php echo esc_sql($near); ?>' != '' ? '<?php echo esc_sql($near); ?>' : '<?php echo $default_near_text; ?>');}"
2445
+	       onfocus="if (this.value == '<?php echo $default_near_text; ?>' || this.value =='<?php echo esc_sql($near); ?>') {this.value = '';}"
2446
+	       onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);" <?php echo $near_input_extra; ?>/>
2447 2447
 	<?php
2448
-	if($new_style){
2448
+	if ($new_style) {
2449 2449
 		do_action('geodir_after_near_input');
2450 2450
 
2451 2451
 		echo "</div>";
2452 2452
 	}
2453 2453
 }
2454 2454
 
2455
-add_action( 'geodir_search_form_inputs', 'geodir_search_form_post_type_input', 10 );
2456
-add_action( 'geodir_search_form_inputs', 'geodir_search_form_search_input', 20 );
2457
-add_action( 'geodir_search_form_inputs', 'geodir_search_form_near_input', 30 );
2455
+add_action('geodir_search_form_inputs', 'geodir_search_form_post_type_input', 10);
2456
+add_action('geodir_search_form_inputs', 'geodir_search_form_search_input', 20);
2457
+add_action('geodir_search_form_inputs', 'geodir_search_form_near_input', 30);
2458 2458
 
2459
-function geodir_get_search_post_type($pt=''){
2459
+function geodir_get_search_post_type($pt = '') {
2460 2460
 	global $geodir_search_post_type;
2461 2461
 
2462
-	if($pt!=''){return $geodir_search_post_type = $pt;}
2463
-	if(!empty($geodir_search_post_type)){ return $geodir_search_post_type;}
2462
+	if ($pt != '') {return $geodir_search_post_type = $pt; }
2463
+	if (!empty($geodir_search_post_type)) { return $geodir_search_post_type; }
2464 2464
 
2465 2465
 	$geodir_search_post_type = geodir_get_current_posttype();
2466 2466
 
2467
-	if(!$geodir_search_post_type) {
2467
+	if (!$geodir_search_post_type) {
2468 2468
 		$geodir_search_post_type = geodir_get_default_posttype();
2469 2469
 	}
2470 2470
 
@@ -2472,7 +2472,7 @@  discard block
 block discarded – undo
2472 2472
 	return $geodir_search_post_type;
2473 2473
 }
2474 2474
 
2475
-function geodir_search_form(){
2475
+function geodir_search_form() {
2476 2476
 
2477 2477
 	geodir_get_search_post_type();
2478 2478
 
@@ -2482,8 +2482,8 @@  discard block
 block discarded – undo
2482 2482
 	die();
2483 2483
 }
2484 2484
 
2485
-add_action( 'wp_ajax_geodir_search_form', 'geodir_search_form' );
2486
-add_action( 'wp_ajax_nopriv_geodir_search_form', 'geodir_search_form' );
2485
+add_action('wp_ajax_geodir_search_form', 'geodir_search_form');
2486
+add_action('wp_ajax_nopriv_geodir_search_form', 'geodir_search_form');
2487 2487
 
2488 2488
 /**
2489 2489
  * Check wpml active or not.
@@ -2557,7 +2557,7 @@  discard block
 block discarded – undo
2557 2557
         }
2558 2558
     }
2559 2559
 }
2560
-add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 );
2560
+add_filter('icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4);
2561 2561
 
2562 2562
 /**
2563 2563
  * Duplicate post listing manually after listing saved.
@@ -2598,7 +2598,7 @@  discard block
 block discarded – undo
2598 2598
 function geodir_wpml_duplicate_post_reviews($master_post_id, $tr_post_id, $lang) {
2599 2599
     global $wpdb;
2600 2600
 
2601
-    $reviews = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id=%d ORDER BY id ASC", $master_post_id), ARRAY_A);
2601
+    $reviews = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM ".GEODIR_REVIEW_TABLE." WHERE post_id=%d ORDER BY id ASC", $master_post_id), ARRAY_A);
2602 2602
 
2603 2603
     if (!empty($reviews)) {
2604 2604
         foreach ($reviews as $review) {
@@ -2626,14 +2626,14 @@  discard block
 block discarded – undo
2626 2626
     global $wpdb, $plugin_prefix;
2627 2627
 
2628 2628
     $post_type = get_post_type($master_post_id);
2629
-    $post_table = $plugin_prefix . $post_type . '_detail';
2629
+    $post_table = $plugin_prefix.$post_type.'_detail';
2630 2630
 
2631
-    $query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
2632
-    $data = (array)$wpdb->get_row($query);
2631
+    $query = $wpdb->prepare("SELECT * FROM ".$post_table." WHERE post_id = %d", array($master_post_id));
2632
+    $data = (array) $wpdb->get_row($query);
2633 2633
 
2634
-    if ( !empty( $data ) ) {
2634
+    if (!empty($data)) {
2635 2635
         $data['post_id'] = $tr_post_id;
2636
-        unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category']);
2636
+        unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type.'category']);
2637 2637
         $wpdb->update($post_table, $data, array('post_id' => $tr_post_id));
2638 2638
         return true;
2639 2639
     }
@@ -2658,7 +2658,7 @@  discard block
 block discarded – undo
2658 2658
     global $sitepress, $wpdb;
2659 2659
     $post_type = get_post_type($master_post_id);
2660 2660
 
2661
-    remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
2661
+    remove_filter('get_term', array($sitepress, 'get_term_adjust_id')); // AVOID filtering to current language
2662 2662
 
2663 2663
     $taxonomies = get_object_taxonomies($post_type);
2664 2664
     foreach ($taxonomies as $taxonomy) {
@@ -2667,9 +2667,9 @@  discard block
 block discarded – undo
2667 2667
         
2668 2668
         if ($terms) {
2669 2669
             foreach ($terms as $term) {
2670
-                $tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang);
2670
+                $tr_id = apply_filters('translate_object_id', $term->term_id, $taxonomy, false, $lang);
2671 2671
                 
2672
-                if (!is_null($tr_id)){
2672
+                if (!is_null($tr_id)) {
2673 2673
                     // not using get_term - unfiltered get_term
2674 2674
                     $translated_term = $wpdb->get_row($wpdb->prepare("
2675 2675
                         SELECT * FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_id, $taxonomy));
@@ -2678,14 +2678,14 @@  discard block
 block discarded – undo
2678 2678
                 }
2679 2679
             }
2680 2680
 
2681
-            if (!is_taxonomy_hierarchical($taxonomy)){
2682
-                $terms_array = array_unique( array_map( 'intval', $terms_array ) );
2681
+            if (!is_taxonomy_hierarchical($taxonomy)) {
2682
+                $terms_array = array_unique(array_map('intval', $terms_array));
2683 2683
             }
2684 2684
 
2685 2685
             wp_set_post_terms($tr_post_id, $terms_array, $taxonomy);
2686 2686
             
2687
-            if ($taxonomy == $post_type . 'category') {
2688
-                geodir_set_postcat_structure($tr_post_id, $post_type . 'category');
2687
+            if ($taxonomy == $post_type.'category') {
2688
+                geodir_set_postcat_structure($tr_post_id, $post_type.'category');
2689 2689
             }
2690 2690
         }
2691 2691
     }
@@ -2706,15 +2706,15 @@  discard block
 block discarded – undo
2706 2706
 function geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang) {
2707 2707
     global $wpdb;
2708 2708
 
2709
-    $query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
2709
+    $query = $wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
2710 2710
     $wpdb->query($query);
2711 2711
 
2712
-    $query = $wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
2712
+    $query = $wpdb->prepare("SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
2713 2713
     $post_images = $wpdb->get_results($query);
2714 2714
 
2715
-    if ( !empty( $post_images ) ) {
2716
-        foreach ( $post_images as $post_image) {
2717
-            $image_data = (array)$post_image;
2715
+    if (!empty($post_images)) {
2716
+        foreach ($post_images as $post_image) {
2717
+            $image_data = (array) $post_image;
2718 2718
             unset($image_data['ID']);
2719 2719
             $image_data['post_id'] = $tr_post_id;
2720 2720
             
@@ -2747,13 +2747,13 @@  discard block
 block discarded – undo
2747 2747
 function geodir_wpml_duplicate_post_review($master_comment_id, $master_post_id, $tr_post_id, $lang) {
2748 2748
     global $wpdb, $plugin_prefix, $sitepress;
2749 2749
 
2750
-    $review = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d ORDER BY id ASC", $master_comment_id), ARRAY_A);
2750
+    $review = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id=%d ORDER BY id ASC", $master_comment_id), ARRAY_A);
2751 2751
 
2752 2752
     if (empty($review)) {
2753 2753
         return false;
2754 2754
     }
2755 2755
     if ($review['post_id'] != $master_post_id) {
2756
-        $wpdb->query($wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET post_id=%d WHERE comment_id=%d", $master_post_id, $master_comment_id));
2756
+        $wpdb->query($wpdb->prepare("UPDATE ".GEODIR_REVIEW_TABLE." SET post_id=%d WHERE comment_id=%d", $master_post_id, $master_comment_id));
2757 2757
         geodir_update_postrating($master_post_id, $post_type);
2758 2758
     }
2759 2759
 
@@ -2764,9 +2764,9 @@  discard block
 block discarded – undo
2764 2764
     }
2765 2765
 
2766 2766
     $post_type = get_post_type($master_post_id);
2767
-    $post_table = $plugin_prefix . $post_type . '_detail';
2767
+    $post_table = $plugin_prefix.$post_type.'_detail';
2768 2768
 
2769
-    $translated_post = $wpdb->get_row($wpdb->prepare("SELECT post_title, post_latitude, post_longitude, post_city, post_region, post_country FROM " . $post_table . " WHERE post_id = %d", $tr_post_id), ARRAY_A);
2769
+    $translated_post = $wpdb->get_row($wpdb->prepare("SELECT post_title, post_latitude, post_longitude, post_city, post_region, post_country FROM ".$post_table." WHERE post_id = %d", $tr_post_id), ARRAY_A);
2770 2770
     if (empty($translated_post)) {
2771 2771
         return false;
2772 2772
     }
@@ -2784,7 +2784,7 @@  discard block
 block discarded – undo
2784 2784
         unset($review['id']);
2785 2785
     }
2786 2786
 
2787
-    $tr_review_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d AND post_id=%d ORDER BY id ASC", $tr_comment_id, $tr_post_id));
2787
+    $tr_review_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id=%d AND post_id=%d ORDER BY id ASC", $tr_comment_id, $tr_post_id));
2788 2788
 
2789 2789
     if ($tr_review_id) { // update review
2790 2790
         $wpdb->update(GEODIR_REVIEW_TABLE, $review, array('id' => $tr_review_id));
@@ -2797,8 +2797,8 @@  discard block
 block discarded – undo
2797 2797
         geodir_update_postrating($tr_post_id, $post_type);
2798 2798
         
2799 2799
         if (defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_review') && $sitepress->get_setting('sync_comments_on_duplicates')) {
2800
-            $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id = %d", array($tr_comment_id)));
2801
-            $likes = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id=%d ORDER BY like_date ASC", $master_comment_id, $tr_post_id), ARRAY_A);
2800
+            $wpdb->query($wpdb->prepare("DELETE FROM ".GEODIR_COMMENTS_REVIEWS_TABLE." WHERE comment_id = %d", array($tr_comment_id)));
2801
+            $likes = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_COMMENTS_REVIEWS_TABLE." WHERE comment_id=%d ORDER BY like_date ASC", $master_comment_id, $tr_post_id), ARRAY_A);
2802 2802
 
2803 2803
             if (!empty($likes)) {
2804 2804
                 foreach ($likes as $like) {
@@ -2900,7 +2900,7 @@  discard block
 block discarded – undo
2900 2900
  * @return bool True if review star disabled, otherwise false.
2901 2901
  */ 
2902 2902
 function geodir_rating_disabled_post_types() {
2903
-	$post_types = get_option( 'geodir_disable_rating_cpt' );
2903
+	$post_types = get_option('geodir_disable_rating_cpt');
2904 2904
 	
2905 2905
 	/**
2906 2906
 	 * Filter the post types array which have rating disabled.
@@ -2909,7 +2909,7 @@  discard block
 block discarded – undo
2909 2909
 	 *
2910 2910
 	 * @param array $post_types Array of post types which have rating starts disabled.
2911 2911
 	 */
2912
-	return apply_filters( 'geodir_rating_disabled_post_types', $post_types );
2912
+	return apply_filters('geodir_rating_disabled_post_types', $post_types);
2913 2913
 }
2914 2914
 
2915 2915
 /**
@@ -2921,30 +2921,30 @@  discard block
 block discarded – undo
2921 2921
  * @param bool $taxonomy Whether $post_type is taxonomy or not.
2922 2922
  * @return bool True if review star disabled, otherwise false.
2923 2923
  */ 
2924
-function geodir_cpt_has_rating_disabled( $post_type = '', $taxonomy = false ) {
2924
+function geodir_cpt_has_rating_disabled($post_type = '', $taxonomy = false) {
2925 2925
 	$post_types = geodir_rating_disabled_post_types();
2926 2926
 	
2927
-	if ( empty( $post_types ) ) {
2927
+	if (empty($post_types)) {
2928 2928
 		return false;
2929 2929
 	}
2930 2930
 	
2931
-	if ( is_int( $post_type ) ) {
2932
-		$post_type = get_post_type( $post_type );
2931
+	if (is_int($post_type)) {
2932
+		$post_type = get_post_type($post_type);
2933 2933
 	}
2934 2934
 	
2935
-	if ( $taxonomy && !empty( $post_types ) ) {
2935
+	if ($taxonomy && !empty($post_types)) {
2936 2936
 		$posttypes = array();
2937 2937
 		
2938
-		foreach ( $post_types as $posttype ) {
2939
-			$posttypes[] = $posttype . 'category';
2940
-			$posttypes[] = $posttype . '_tags';
2938
+		foreach ($post_types as $posttype) {
2939
+			$posttypes[] = $posttype.'category';
2940
+			$posttypes[] = $posttype.'_tags';
2941 2941
 		}
2942 2942
 		
2943 2943
 		$post_types = $posttypes;
2944 2944
 	}
2945 2945
 
2946 2946
 	$return = false;
2947
-	if ( $post_type != '' && !empty( $post_types ) && in_array( $post_type, $post_types ) ) {
2947
+	if ($post_type != '' && !empty($post_types) && in_array($post_type, $post_types)) {
2948 2948
 		$return = true;
2949 2949
 	}
2950 2950
 
@@ -2959,7 +2959,7 @@  discard block
 block discarded – undo
2959 2959
  * @return bool True if Yoast SEO disabled on GD pages.
2960 2960
  */
2961 2961
 function geodir_disable_yoast_seo_metas() {
2962
-    return (bool)get_option( 'geodir_disable_yoast_meta' );
2962
+    return (bool) get_option('geodir_disable_yoast_meta');
2963 2963
 }
2964 2964
 
2965 2965
 /**
@@ -2970,30 +2970,30 @@  discard block
 block discarded – undo
2970 2970
  * @param int $post_id The post ID.
2971 2971
  * @return bool True if allowed.
2972 2972
  */
2973
-function geodir_wpml_allowed_to_duplicate( $post_id ) {
2973
+function geodir_wpml_allowed_to_duplicate($post_id) {
2974 2974
     $allowed = false;
2975 2975
     
2976
-    if ( !geodir_is_wpml() || empty( $post_id ) ) {
2976
+    if (!geodir_is_wpml() || empty($post_id)) {
2977 2977
         return $allowed;
2978 2978
     }
2979 2979
     
2980
-    $user_id = (int)get_current_user_id();
2980
+    $user_id = (int) get_current_user_id();
2981 2981
     
2982
-    if ( empty( $user_id ) ) {
2982
+    if (empty($user_id)) {
2983 2983
         return $allowed;
2984 2984
     }
2985 2985
     
2986
-    $post_type = get_post_type( $post_id );
2987
-    if ( !is_post_type_translated( $post_type ) || get_post_meta( $post_id, '_icl_lang_duplicate_of', true ) ) {
2986
+    $post_type = get_post_type($post_id);
2987
+    if (!is_post_type_translated($post_type) || get_post_meta($post_id, '_icl_lang_duplicate_of', true)) {
2988 2988
         return $allowed;
2989 2989
     }
2990 2990
     
2991
-    if ( geodir_listing_belong_to_current_user( $post_id ) ) {
2991
+    if (geodir_listing_belong_to_current_user($post_id)) {
2992 2992
         $allowed = true;
2993 2993
     }
2994 2994
     
2995
-    $disable_cpts = get_option( 'geodir_wpml_disable_duplicate' );
2996
-    if ( $allowed && !empty( $disable_cpts ) && in_array( $post_type, $disable_cpts ) ) {
2995
+    $disable_cpts = get_option('geodir_wpml_disable_duplicate');
2996
+    if ($allowed && !empty($disable_cpts) && in_array($post_type, $disable_cpts)) {
2997 2997
         $allowed = false;
2998 2998
     }
2999 2999
     
@@ -3003,7 +3003,7 @@  discard block
 block discarded – undo
3003 3003
      * @param bool $allowed True if allowed.
3004 3004
      * @param int $post_id The post ID.
3005 3005
      */
3006
-    return apply_filters( 'geodir_wpml_allowed_to_duplicate', $allowed, $post_id );
3006
+    return apply_filters('geodir_wpml_allowed_to_duplicate', $allowed, $post_id);
3007 3007
 }
3008 3008
 
3009 3009
 /**
@@ -3018,61 +3018,61 @@  discard block
 block discarded – undo
3018 3018
  * @param string $content_html The output html of the geodir_edit_post_link() function.
3019 3019
  * @return string Filtered html of the geodir_edit_post_link() function.
3020 3020
  */
3021
-function geodir_wpml_frontend_duplicate_listing( $content_html ) {
3021
+function geodir_wpml_frontend_duplicate_listing($content_html) {
3022 3022
     global $post, $preview, $sitepress;
3023 3023
     
3024
-    if ( !empty( $post->ID ) && !$preview && geodir_is_page( 'detail' ) && geodir_wpml_allowed_to_duplicate( $post->ID ) ) {
3024
+    if (!empty($post->ID) && !$preview && geodir_is_page('detail') && geodir_wpml_allowed_to_duplicate($post->ID)) {
3025 3025
         $post_id = $post->ID;
3026
-        $element_type = 'post_' . get_post_type( $post_id );
3027
-        $original_post_id = $sitepress->get_original_element_id( $post_id, $element_type );
3026
+        $element_type = 'post_'.get_post_type($post_id);
3027
+        $original_post_id = $sitepress->get_original_element_id($post_id, $element_type);
3028 3028
         
3029
-        if ( $original_post_id == $post_id ) {
3029
+        if ($original_post_id == $post_id) {
3030 3030
             $wpml_languages = $sitepress->get_active_languages();
3031
-            $post_language = $sitepress->get_language_for_element( $post_id, $element_type );
3031
+            $post_language = $sitepress->get_language_for_element($post_id, $element_type);
3032 3032
             
3033
-            if ( !empty( $wpml_languages ) && isset( $wpml_languages[ $post_language ] ) ) {
3034
-                unset( $wpml_languages[ $post_language ] );
3033
+            if (!empty($wpml_languages) && isset($wpml_languages[$post_language])) {
3034
+                unset($wpml_languages[$post_language]);
3035 3035
             }
3036 3036
             
3037
-            if ( !empty( $wpml_languages ) ) {
3038
-                $trid  = $sitepress->get_element_trid( $post_id, $element_type );
3039
-                $element_translations = $sitepress->get_element_translations( $trid, $element_type );
3040
-                $duplicates = $sitepress->get_duplicates( $post_id );
3037
+            if (!empty($wpml_languages)) {
3038
+                $trid = $sitepress->get_element_trid($post_id, $element_type);
3039
+                $element_translations = $sitepress->get_element_translations($trid, $element_type);
3040
+                $duplicates = $sitepress->get_duplicates($post_id);
3041 3041
                 
3042
-                $wpml_content = '<div class="geodir-company_info gd-detail-duplicate"><h3 class="widget-title">' . __( 'Translate Listing', 'geodirectory' ) . '</h3>';
3042
+                $wpml_content = '<div class="geodir-company_info gd-detail-duplicate"><h3 class="widget-title">'.__('Translate Listing', 'geodirectory').'</h3>';
3043 3043
                 $wpml_content .= '<table class="gd-duplicate-table" style="width:100%;margin:0"><tbody>';
3044
-                $wpml_content .= '<tr style="border-bottom:solid 1px #efefef"><th style="padding:0 2px 2px 2px">' . __( 'Language', 'geodirectory' ) . '</th><th style="width:25px;"></th><th style="width:5em;text-align:center">' . __( 'Translate', 'geodirectory' ) . '</th></tr>';
3044
+                $wpml_content .= '<tr style="border-bottom:solid 1px #efefef"><th style="padding:0 2px 2px 2px">'.__('Language', 'geodirectory').'</th><th style="width:25px;"></th><th style="width:5em;text-align:center">'.__('Translate', 'geodirectory').'</th></tr>';
3045 3045
                 
3046 3046
                 $needs_translation = false;
3047 3047
                 
3048
-                foreach ( $wpml_languages as $lang_code => $lang ) {
3048
+                foreach ($wpml_languages as $lang_code => $lang) {
3049 3049
                     $duplicates_text = '';
3050 3050
                     $translated = false;
3051 3051
                     
3052
-                    if ( !empty( $element_translations ) && isset( $element_translations[$lang_code] ) ) {
3052
+                    if (!empty($element_translations) && isset($element_translations[$lang_code])) {
3053 3053
                         $translated = true;
3054 3054
                         
3055
-                        if ( !empty( $duplicates ) && isset( $duplicates[$lang_code] ) ) {
3056
-                            $duplicates_text = ' ' . __( '(duplicate)', 'geodirectory' );
3055
+                        if (!empty($duplicates) && isset($duplicates[$lang_code])) {
3056
+                            $duplicates_text = ' '.__('(duplicate)', 'geodirectory');
3057 3057
                         }
3058 3058
                     } else {
3059 3059
                         $needs_translation = true;
3060 3060
                     }
3061 3061
                     
3062
-                    $wpml_content .= '<tr><td style="padding:4px">' . $lang['english_name'] . $duplicates_text . '</td><td>&nbsp;</td><td style="text-align:center;">';
3062
+                    $wpml_content .= '<tr><td style="padding:4px">'.$lang['english_name'].$duplicates_text.'</td><td>&nbsp;</td><td style="text-align:center;">';
3063 3063
                     
3064
-                    if ( $translated ) {
3064
+                    if ($translated) {
3065 3065
                         $wpml_content .= '<i class="fa fa-check" style="color:orange"></i>';
3066 3066
                     } else {
3067
-                        $wpml_content .= '<input name="gd_icl_dup[]" value="' . $lang_code . '" title="' . esc_attr__( 'Create duplicate', 'geodirectory' ) . '" type="checkbox">';
3067
+                        $wpml_content .= '<input name="gd_icl_dup[]" value="'.$lang_code.'" title="'.esc_attr__('Create duplicate', 'geodirectory').'" type="checkbox">';
3068 3068
                     }
3069 3069
                     
3070 3070
                     $wpml_content .= '</td></tr>';
3071 3071
                 }
3072 3072
                 
3073
-                if ( $needs_translation ) {
3074
-                    $nonce = wp_create_nonce( 'geodir_duplicate_nonce' );
3075
-                    $wpml_content .= '<tr><td>&nbsp;</td><td style="vertical-align:middle;padding-top:13px"><i style="display:none" class="fa fa-spin fa-refresh"></i></td><td style="padding:15px 3px 3px 3px;text-align:right"><button data-nonce="' . esc_attr( $nonce ) . '" data-post-id="' . $post_id . '" id="gd_make_duplicates" class="button-secondary">' . __( 'Duplicate', 'geodirectory' ) . '</button></td></tr>';
3073
+                if ($needs_translation) {
3074
+                    $nonce = wp_create_nonce('geodir_duplicate_nonce');
3075
+                    $wpml_content .= '<tr><td>&nbsp;</td><td style="vertical-align:middle;padding-top:13px"><i style="display:none" class="fa fa-spin fa-refresh"></i></td><td style="padding:15px 3px 3px 3px;text-align:right"><button data-nonce="'.esc_attr($nonce).'" data-post-id="'.$post_id.'" id="gd_make_duplicates" class="button-secondary">'.__('Duplicate', 'geodirectory').'</button></td></tr>';
3076 3076
                 }
3077 3077
                 
3078 3078
                 $wpml_content .= '</tbody></table>';
@@ -3094,12 +3094,12 @@  discard block
 block discarded – undo
3094 3094
  * @param array $settings GD design settings array.
3095 3095
  * @return array Filtered GD design settings array..
3096 3096
  */
3097
-function geodir_wpml_duplicate_settings( $settings = array() ) {
3097
+function geodir_wpml_duplicate_settings($settings = array()) {
3098 3098
     $new_settings = array();
3099 3099
     
3100
-    foreach ( $settings as $key => $setting ) {
3100
+    foreach ($settings as $key => $setting) {
3101 3101
         
3102
-        if ( isset( $setting['type'] ) && $setting['type'] == 'sectionend' && $setting['id'] == 'detail_page_settings' ) {
3102
+        if (isset($setting['type']) && $setting['type'] == 'sectionend' && $setting['id'] == 'detail_page_settings') {
3103 3103
             $new_settings[] = array(
3104 3104
                 'name' => __('Disable WPML duplicate translation', 'geodirectory'),
3105 3105
                 'desc' => __('Select post types to disable front end WPML duplicate translation. For selected post types the WPML duplicate option will be disabled from listing detail page sidebar.', 'geodirectory'),
Please login to merge, or discard this patch.
geodirectory-functions/map-functions/get_markers.php 2 patches
Indentation   +343 added lines, -343 removed lines patch added patch discarded remove patch
@@ -7,61 +7,61 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'homemap_catlist') {
10
-    global $gd_session;
11
-    $gd_post_type = sanitize_text_field($_REQUEST['post_type']);
12
-    $gd_session->set('homemap_catlist_ptype', $gd_post_type);
13
-    $post_taxonomy = geodir_get_taxonomies($gd_post_type);
14
-    $map_canvas_name = sanitize_text_field($_REQUEST['map_canvas']);
15
-    $child_collapse = (bool)$_REQUEST['child_collapse'];
16
-    echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true);
17
-    die;
10
+	global $gd_session;
11
+	$gd_post_type = sanitize_text_field($_REQUEST['post_type']);
12
+	$gd_session->set('homemap_catlist_ptype', $gd_post_type);
13
+	$post_taxonomy = geodir_get_taxonomies($gd_post_type);
14
+	$map_canvas_name = sanitize_text_field($_REQUEST['map_canvas']);
15
+	$child_collapse = (bool)$_REQUEST['child_collapse'];
16
+	echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true);
17
+	die;
18 18
 }
19 19
 
20 20
 // Send the content-type header with correct encoding
21 21
 header("Content-type: text/javascript; charset=utf-8");
22 22
 
23 23
 if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'cat') { // Retrives markers data for categories
24
-    echo get_markers();
25
-    exit;
24
+	echo get_markers();
25
+	exit;
26 26
 } else if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'info') { // Retrives marker info window html
27
-    /**
28
-     * @global object $wpdb WordPress Database object.
29
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
30
-     * @global object $gd_session GeoDirectory Session object.
31
-     */
32
-    global $wpdb, $plugin_prefix, $gd_session;
33
-
34
-    if ($_REQUEST['m_id'] != '') {
35
-        $pid = (int)$_REQUEST['m_id'];
36
-    } else {
37
-        echo __('No marker data found', 'geodirectory');
38
-        exit;
39
-    }
40
-
41
-    if (isset($_REQUEST['post_preview']) && $_REQUEST['post_preview'] != '' && $gd_ses_listing = $gd_session->get('listing')) {
42
-        $post = (object)$gd_ses_listing;
43
-        echo geodir_get_infowindow_html($post, $_REQUEST['post_preview']);
44
-    } else {
45
-        $geodir_post_type = get_post_type($pid);
46
-
47
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
48
-
49
-        $sql = $wpdb->prepare("SELECT * FROM " . $table . " WHERE post_id = %d", array($pid));
50
-
51
-        $postinfo = $wpdb->get_results($sql);
52
-
53
-        $data_arr = array();
54
-
55
-        if ($postinfo) {
56
-            $srcharr = array("'", "/", "-", '"', '\\');
57
-            $replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
58
-
59
-            foreach ($postinfo as $postinfo_obj) {
60
-                echo geodir_get_infowindow_html($postinfo_obj);
61
-            }
62
-        }
63
-    }
64
-    exit;
27
+	/**
28
+	 * @global object $wpdb WordPress Database object.
29
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
30
+	 * @global object $gd_session GeoDirectory Session object.
31
+	 */
32
+	global $wpdb, $plugin_prefix, $gd_session;
33
+
34
+	if ($_REQUEST['m_id'] != '') {
35
+		$pid = (int)$_REQUEST['m_id'];
36
+	} else {
37
+		echo __('No marker data found', 'geodirectory');
38
+		exit;
39
+	}
40
+
41
+	if (isset($_REQUEST['post_preview']) && $_REQUEST['post_preview'] != '' && $gd_ses_listing = $gd_session->get('listing')) {
42
+		$post = (object)$gd_ses_listing;
43
+		echo geodir_get_infowindow_html($post, $_REQUEST['post_preview']);
44
+	} else {
45
+		$geodir_post_type = get_post_type($pid);
46
+
47
+		$table = $plugin_prefix . $geodir_post_type . '_detail';
48
+
49
+		$sql = $wpdb->prepare("SELECT * FROM " . $table . " WHERE post_id = %d", array($pid));
50
+
51
+		$postinfo = $wpdb->get_results($sql);
52
+
53
+		$data_arr = array();
54
+
55
+		if ($postinfo) {
56
+			$srcharr = array("'", "/", "-", '"', '\\');
57
+			$replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
58
+
59
+			foreach ($postinfo as $postinfo_obj) {
60
+				echo geodir_get_infowindow_html($postinfo_obj);
61
+			}
62
+		}
63
+	}
64
+	exit;
65 65
 }
66 66
 
67 67
 /**
@@ -79,80 +79,80 @@  discard block
 block discarded – undo
79 79
  * @return string
80 80
  */
81 81
 function get_markers() {
82
-    global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes;
82
+	global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes;
83 83
 
84
-    $search = '';
85
-    $main_query_array;
84
+	$search = '';
85
+	$main_query_array;
86 86
 
87
-    $srcharr = array("'", "/", "-", '"', '\\', '&#39;');
88
-    $replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '', "&prime;");
87
+	$srcharr = array("'", "/", "-", '"', '\\', '&#39;');
88
+	$replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '', "&prime;");
89 89
 
90
-    $post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place';
90
+	$post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place';
91 91
 
92
-    $map_cat_ids_array = array('0');
93
-    $cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)");
92
+	$map_cat_ids_array = array('0');
93
+	$cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)");
94 94
 
95 95
 
96
-    $field_default_cat = '';
97
-    if (isset($_REQUEST['cat_id']) && $_REQUEST['cat_id'] != '') {
98
-        $map_cat_arr = trim($_REQUEST['cat_id'], ',');
96
+	$field_default_cat = '';
97
+	if (isset($_REQUEST['cat_id']) && $_REQUEST['cat_id'] != '') {
98
+		$map_cat_arr = trim($_REQUEST['cat_id'], ',');
99 99
 
100
-        if (!empty($map_cat_arr)) {
101
-            $field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category ";
100
+		if (!empty($map_cat_arr)) {
101
+			$field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category ";
102 102
 
103
-            $map_cat_ids_array = explode(',', $map_cat_arr);
104
-            $cat_find_array = array();
105
-            foreach ($map_cat_ids_array as $cat_id) {
106
-                $field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `" . $post_type . "category`) > 0) THEN $cat_id ";
107
-                $cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)";
108
-                $main_query_array[] = $cat_id;
109
-            }
103
+			$map_cat_ids_array = explode(',', $map_cat_arr);
104
+			$cat_find_array = array();
105
+			foreach ($map_cat_ids_array as $cat_id) {
106
+				$field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `" . $post_type . "category`) > 0) THEN $cat_id ";
107
+				$cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)";
108
+				$main_query_array[] = $cat_id;
109
+			}
110 110
 
111
-        }
112
-    }
111
+		}
112
+	}
113 113
 
114
-    if (!empty($field_default_cat))
115
-        $field_default_cat = '';
114
+	if (!empty($field_default_cat))
115
+		$field_default_cat = '';
116 116
 
117
-    if (!empty($cat_find_array))
118
-        $search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
117
+	if (!empty($cat_find_array))
118
+		$search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
119 119
 
120
-    $main_query_array = $map_cat_ids_array;
120
+	$main_query_array = $map_cat_ids_array;
121 121
   
122
-    if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) {
123
-        $search .= " AND p.post_title LIKE %s";
124
-        $main_query_array[] = "%" . $_REQUEST['search'] . "%";
125
-    }
126
-
127
-    /**
128
-     * Filter the marker query search SQL, values are replaces with %s or %d.
129
-     *
130
-     * @since 1.5.3
131
-     *
132
-     * @param string $search The SQL query for search/where.
133
-     */
134
-    $search = apply_filters('geodir_marker_search', $search);
135
-    /**
136
-     * Filter the marker query search SQL values %s and %d, this is an array of values.
137
-     *
138
-     * @since 1.5.3
139
-     *
140
-     * @param array $main_query_array The SQL query values for search/where.
141
-     */
142
-    $main_query_array = apply_filters('geodir_marker_main_query_array', $main_query_array);
143
-
144
-    $gd_posttype = '';
145
-    if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') {
146
-        $table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail';
147
-        $gd_posttype = " AND p.post_type = %s";
148
-        $main_query_array[] = $_REQUEST['gd_posttype'];
149
-
150
-    } else
151
-        $table = $plugin_prefix . 'gd_place_detail';
152
-
153
-    $join = ", " . $table . " AS pd ";
154
-
155
-    /**
122
+	if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) {
123
+		$search .= " AND p.post_title LIKE %s";
124
+		$main_query_array[] = "%" . $_REQUEST['search'] . "%";
125
+	}
126
+
127
+	/**
128
+	 * Filter the marker query search SQL, values are replaces with %s or %d.
129
+	 *
130
+	 * @since 1.5.3
131
+	 *
132
+	 * @param string $search The SQL query for search/where.
133
+	 */
134
+	$search = apply_filters('geodir_marker_search', $search);
135
+	/**
136
+	 * Filter the marker query search SQL values %s and %d, this is an array of values.
137
+	 *
138
+	 * @since 1.5.3
139
+	 *
140
+	 * @param array $main_query_array The SQL query values for search/where.
141
+	 */
142
+	$main_query_array = apply_filters('geodir_marker_main_query_array', $main_query_array);
143
+
144
+	$gd_posttype = '';
145
+	if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') {
146
+		$table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail';
147
+		$gd_posttype = " AND p.post_type = %s";
148
+		$main_query_array[] = $_REQUEST['gd_posttype'];
149
+
150
+	} else
151
+		$table = $plugin_prefix . 'gd_place_detail';
152
+
153
+	$join = ", " . $table . " AS pd ";
154
+
155
+	/**
156 156
 	 * Filter the SQL JOIN clause for the markers data
157 157
 	 *
158 158
 	 * @since 1.0.0
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
 	 * @param string $search Row of searched fields to use in WHERE clause.
170 170
 	 */
171 171
 	$search = apply_filters('geodir_home_map_listing_where', $search);
172
-    $search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search);
173
-    $cat_type = $post_type . 'category';
174
-    if ($post_type == 'gd_event') {
175
-        $event_select = ", pd.recurring_dates, pd.is_recurring";
176
-    } else {
177
-        $event_select = "";
178
-    }
179
-
180
-    $sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select;
181
-    /**
172
+	$search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search);
173
+	$cat_type = $post_type . 'category';
174
+	if ($post_type == 'gd_event') {
175
+		$event_select = ", pd.recurring_dates, pd.is_recurring";
176
+	} else {
177
+		$event_select = "";
178
+	}
179
+
180
+	$sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select;
181
+	/**
182 182
 	 * Filter the SQL SELECT clause to retrive fields data
183 183
 	 *
184 184
 	 * @since 1.0.0
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	$groupby = apply_filters('geodir_home_map_listing_groupby', $groupby);
199 199
 
200
-    $catsql = $wpdb->prepare("$select $field_default_cat FROM " . $wpdb->posts . " as p" . $join . " WHERE p.ID = pd.post_id AND p.post_status = 'publish' " . $search . $gd_posttype . $groupby , $main_query_array);
200
+	$catsql = $wpdb->prepare("$select $field_default_cat FROM " . $wpdb->posts . " as p" . $join . " WHERE p.ID = pd.post_id AND p.post_status = 'publish' " . $search . $gd_posttype . $groupby , $main_query_array);
201 201
     
202 202
 	/**
203 203
 	 * Filter the SQL query to retrive markers data
@@ -209,265 +209,265 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	$catsql = apply_filters('geodir_home_map_listing_query', $catsql, $search);
211 211
 
212
-    $catinfo = $wpdb->get_results($catsql);
212
+	$catinfo = $wpdb->get_results($catsql);
213 213
 	
214
-    $cat_content_info = array();
215
-    $content_data = array();
216
-    $post_ids = array();
217
-
218
-    /**
219
-     * Called before marker data is processed into JSON.
220
-     *
221
-     * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
222
-     *
223
-     * @since 1.5.3
224
-     * @param object $catinfo The posts object containing all marker data.
225
-     * @see 'geodir_after_marker_post_process'
226
-     */
227
-    $catinfo = apply_filters('geodir_before_marker_post_process', $catinfo);
228
-
229
-    /**
230
-     * Called before marker data is processed into JSON.
231
-     *
232
-     * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
233
-     *
234
-     * @since 1.4.9
235
-     * @param object $catinfo The posts object containing all marker data.
236
-     * @see 'geodir_after_marker_post_process'
237
-     */
238
-    do_action('geodir_before_marker_post_process_action', $catinfo);
239
-
240
-    // Sort any posts into a ajax array
241
-    if (!empty($catinfo)) {
242
-        $geodir_cat_icons = geodir_get_term_icon();
243
-        global $geodir_date_time_format, $geodir_date_format, $geodir_time_format;
244
-
245
-        $today = strtotime(date_i18n('Y-m-d'));
246
-        $show_dates = $post_type == 'gd_event' ? (int)get_option('geodir_event_infowindow_dates_count', 1) : 0;
214
+	$cat_content_info = array();
215
+	$content_data = array();
216
+	$post_ids = array();
217
+
218
+	/**
219
+	 * Called before marker data is processed into JSON.
220
+	 *
221
+	 * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
222
+	 *
223
+	 * @since 1.5.3
224
+	 * @param object $catinfo The posts object containing all marker data.
225
+	 * @see 'geodir_after_marker_post_process'
226
+	 */
227
+	$catinfo = apply_filters('geodir_before_marker_post_process', $catinfo);
228
+
229
+	/**
230
+	 * Called before marker data is processed into JSON.
231
+	 *
232
+	 * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
233
+	 *
234
+	 * @since 1.4.9
235
+	 * @param object $catinfo The posts object containing all marker data.
236
+	 * @see 'geodir_after_marker_post_process'
237
+	 */
238
+	do_action('geodir_before_marker_post_process_action', $catinfo);
239
+
240
+	// Sort any posts into a ajax array
241
+	if (!empty($catinfo)) {
242
+		$geodir_cat_icons = geodir_get_term_icon();
243
+		global $geodir_date_time_format, $geodir_date_format, $geodir_time_format;
244
+
245
+		$today = strtotime(date_i18n('Y-m-d'));
246
+		$show_dates = $post_type == 'gd_event' ? (int)get_option('geodir_event_infowindow_dates_count', 1) : 0;
247 247
         
248
-        foreach ($catinfo as $catinfo_obj) {
249
-            $post_title = $catinfo_obj->post_title;
248
+		foreach ($catinfo as $catinfo_obj) {
249
+			$post_title = $catinfo_obj->post_title;
250 250
             
251
-            if ($post_type == 'gd_event' && !empty($catinfo_obj->recurring_dates) && $show_dates > 0) {
252
-                $event_dates = '';
253
-                $recurring_data = isset($catinfo_obj->recurring_dates) ? maybe_unserialize($catinfo_obj->recurring_dates) : array();
251
+			if ($post_type == 'gd_event' && !empty($catinfo_obj->recurring_dates) && $show_dates > 0) {
252
+				$event_dates = '';
253
+				$recurring_data = isset($catinfo_obj->recurring_dates) ? maybe_unserialize($catinfo_obj->recurring_dates) : array();
254 254
 
255
-                $post_info = geodir_get_post_info($catinfo_obj->post_id);
255
+				$post_info = geodir_get_post_info($catinfo_obj->post_id);
256 256
                 
257
-                if (!empty($catinfo_obj->is_recurring) && !empty($recurring_data) && !empty($recurring_data['is_recurring']) && geodir_event_recurring_pkg($post_info)) {
258
-                    $starttimes = '';
259
-                    $endtimes = '';
260
-                    $astarttimes = array();
261
-                    $aendtimes = array();
262
-                    if ( !isset( $recurring_data['repeat_type'] ) ) {
263
-                        $recurring_data['repeat_type'] = 'custom';
264
-                    }
265
-                    $repeat_type = isset( $recurring_data['repeat_type'] ) && in_array( $recurring_data['repeat_type'], array( 'day', 'week', 'month', 'year', 'custom' ) ) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom
266
-                    $different_times = isset( $recurring_data['different_times'] ) && !empty( $recurring_data['different_times'] ) ? true : false;
257
+				if (!empty($catinfo_obj->is_recurring) && !empty($recurring_data) && !empty($recurring_data['is_recurring']) && geodir_event_recurring_pkg($post_info)) {
258
+					$starttimes = '';
259
+					$endtimes = '';
260
+					$astarttimes = array();
261
+					$aendtimes = array();
262
+					if ( !isset( $recurring_data['repeat_type'] ) ) {
263
+						$recurring_data['repeat_type'] = 'custom';
264
+					}
265
+					$repeat_type = isset( $recurring_data['repeat_type'] ) && in_array( $recurring_data['repeat_type'], array( 'day', 'week', 'month', 'year', 'custom' ) ) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom
266
+					$different_times = isset( $recurring_data['different_times'] ) && !empty( $recurring_data['different_times'] ) ? true : false;
267 267
         
268
-                    $recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
268
+					$recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
269 269
                     
270
-                    if ( !empty( $recurring_dates ) ) {
271
-                        if ( empty( $recurring_data['all_day'] ) ) {
272
-                            if ( $repeat_type == 'custom' && $different_times ) {
273
-                                $astarttimes = isset( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
274
-                                $aendtimes = isset( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
275
-                            } else {
276
-                                $starttimes = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
277
-                                $endtimes = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
278
-                            }
279
-                        }
270
+					if ( !empty( $recurring_dates ) ) {
271
+						if ( empty( $recurring_data['all_day'] ) ) {
272
+							if ( $repeat_type == 'custom' && $different_times ) {
273
+								$astarttimes = isset( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
274
+								$aendtimes = isset( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
275
+							} else {
276
+								$starttimes = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
277
+								$endtimes = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
278
+							}
279
+						}
280 280
                         
281
-                        $e = 0;
282
-                        foreach( $recurring_dates as $key => $date ) {
283
-                            if ( $repeat_type == 'custom' && $different_times ) {
284
-                                if ( !empty( $astarttimes ) && isset( $astarttimes[$key] ) ) {
285
-                                    $starttimes = $astarttimes[$key];
286
-                                    $endtimes = $aendtimes[$key];
287
-                                } else {
288
-                                    $starttimes = '';
289
-                                    $endtimes = '';
290
-                                }
291
-                            }
281
+						$e = 0;
282
+						foreach( $recurring_dates as $key => $date ) {
283
+							if ( $repeat_type == 'custom' && $different_times ) {
284
+								if ( !empty( $astarttimes ) && isset( $astarttimes[$key] ) ) {
285
+									$starttimes = $astarttimes[$key];
286
+									$endtimes = $aendtimes[$key];
287
+								} else {
288
+									$starttimes = '';
289
+									$endtimes = '';
290
+								}
291
+							}
292 292
                             
293
-                            $duration = isset( $recurring_data['duration_x'] ) && (int)$recurring_data['duration_x'] > 0 ? (int)$recurring_data['duration_x'] : 1;
294
-                            $duration--;
295
-                            $enddate = date_i18n( 'Y-m-d', strtotime( $date . ' + ' . $duration . ' day' ) );
293
+							$duration = isset( $recurring_data['duration_x'] ) && (int)$recurring_data['duration_x'] > 0 ? (int)$recurring_data['duration_x'] : 1;
294
+							$duration--;
295
+							$enddate = date_i18n( 'Y-m-d', strtotime( $date . ' + ' . $duration . ' day' ) );
296 296
                             
297
-                            // Hide past dates
298
-                            if ( strtotime( $enddate ) < $today ) {
299
-                                continue;
300
-                            }
297
+							// Hide past dates
298
+							if ( strtotime( $enddate ) < $today ) {
299
+								continue;
300
+							}
301 301
                                     
302
-                            $sdate = strtotime( $date . ' ' . $starttimes );
303
-                            $edate = strtotime( $enddate . ' ' . $endtimes );
302
+							$sdate = strtotime( $date . ' ' . $starttimes );
303
+							$edate = strtotime( $enddate . ' ' . $endtimes );
304 304
                                         
305
-                            $start_date = date_i18n( $geodir_date_time_format, $sdate );
306
-                            $end_date = date_i18n( $geodir_date_time_format, $edate );
305
+							$start_date = date_i18n( $geodir_date_time_format, $sdate );
306
+							$end_date = date_i18n( $geodir_date_time_format, $edate );
307 307
                             
308
-                            $same_day = false;
309
-                            $full_day = false;
310
-                            $same_datetime = false;
308
+							$same_day = false;
309
+							$full_day = false;
310
+							$same_datetime = false;
311 311
                             
312
-                            if ( $starttimes == $endtimes && ( $starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00' ) ) {
313
-                                $full_day = true;
314
-                            }
312
+							if ( $starttimes == $endtimes && ( $starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00' ) ) {
313
+								$full_day = true;
314
+							}
315 315
                             
316
-                            if ( $start_date == $end_date && $full_day ) {
317
-                                $same_datetime = true;
318
-                            }
319
-
320
-                            $link_date = date_i18n( 'Y-m-d', $sdate );
321
-                            $title_date = date_i18n( $geodir_date_format, $sdate );
322
-                            if ( $full_day ) {
323
-                                $start_date = $title_date;
324
-                                $end_date = date_i18n( $geodir_date_format, $edate );
325
-                            }
316
+							if ( $start_date == $end_date && $full_day ) {
317
+								$same_datetime = true;
318
+							}
319
+
320
+							$link_date = date_i18n( 'Y-m-d', $sdate );
321
+							$title_date = date_i18n( $geodir_date_format, $sdate );
322
+							if ( $full_day ) {
323
+								$start_date = $title_date;
324
+								$end_date = date_i18n( $geodir_date_format, $edate );
325
+							}
326 326
                             
327
-                            if ( !$same_datetime && !$full_day && date_i18n( 'Y-m-d', $sdate ) == date_i18n( 'Y-m-d', $edate ) ) {
328
-                                $same_day = true;
327
+							if ( !$same_datetime && !$full_day && date_i18n( 'Y-m-d', $sdate ) == date_i18n( 'Y-m-d', $edate ) ) {
328
+								$same_day = true;
329 329
                                 
330
-                                $start_date .= ' - ' . date_i18n( $geodir_time_format, $edate );
331
-                            }
330
+								$start_date .= ' - ' . date_i18n( $geodir_time_format, $edate );
331
+							}
332 332
                             
333
-                            $event_dates .= ' :: ' . $start_date;
333
+							$event_dates .= ' :: ' . $start_date;
334 334
                         
335
-                            if ( !$same_day && !$same_datetime ) {
336
-                                $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
337
-                            }
335
+							if ( !$same_day && !$same_datetime ) {
336
+								$event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
337
+							}
338 338
                             
339
-                            $e++;
339
+							$e++;
340 340
                             
341
-                            if ($show_dates > 0 && $e == $show_dates) { // only show 3 event dates
342
-                                break;
343
-                            }
344
-                        }
345
-                    }
346
-                } else {
347
-                    $start_date = isset( $recurring_data['event_start'] ) ? $recurring_data['event_start'] : '';
348
-                    $end_date = isset( $recurring_data['event_end'] ) ? $recurring_data['event_end'] : $start_date;
349
-                    $all_day = isset( $recurring_data['all_day'] ) && !empty( $recurring_data['all_day'] ) ? true : false;
350
-                    $starttime = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
351
-                    $endtime = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
341
+							if ($show_dates > 0 && $e == $show_dates) { // only show 3 event dates
342
+								break;
343
+							}
344
+						}
345
+					}
346
+				} else {
347
+					$start_date = isset( $recurring_data['event_start'] ) ? $recurring_data['event_start'] : '';
348
+					$end_date = isset( $recurring_data['event_end'] ) ? $recurring_data['event_end'] : $start_date;
349
+					$all_day = isset( $recurring_data['all_day'] ) && !empty( $recurring_data['all_day'] ) ? true : false;
350
+					$starttime = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
351
+					$endtime = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
352 352
                 
353
-                    $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
354
-                    $starttimes = isset( $recurring_data['starttimes'] ) && !empty( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
355
-                    $endtimes = isset( $recurring_data['endtimes'] ) && !empty( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
353
+					$event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
354
+					$starttimes = isset( $recurring_data['starttimes'] ) && !empty( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
355
+					$endtimes = isset( $recurring_data['endtimes'] ) && !empty( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
356 356
                     
357
-                    if ( !geodir_event_is_date( $start_date ) && !empty( $event_recurring_dates ) ) {
358
-                        $start_date = $event_recurring_dates[0];
359
-                    }
357
+					if ( !geodir_event_is_date( $start_date ) && !empty( $event_recurring_dates ) ) {
358
+						$start_date = $event_recurring_dates[0];
359
+					}
360 360
                                 
361
-                    if ( strtotime( $end_date ) < strtotime( $start_date ) ) {
362
-                        $end_date = $start_date;
363
-                    }
361
+					if ( strtotime( $end_date ) < strtotime( $start_date ) ) {
362
+						$end_date = $start_date;
363
+					}
364 364
                     
365
-                    if ($end_date != '' && strtotime($end_date) >= $today) {
366
-                        if ( $starttime == '' && !empty( $starttimes ) ) {
367
-                            $starttime = $starttimes[0];
368
-                            $endtime = $endtimes[0];
369
-                        }
365
+					if ($end_date != '' && strtotime($end_date) >= $today) {
366
+						if ( $starttime == '' && !empty( $starttimes ) ) {
367
+							$starttime = $starttimes[0];
368
+							$endtime = $endtimes[0];
369
+						}
370 370
                         
371
-                        $same_day = false;
372
-                        $one_day = false;
373
-                        if ( $start_date == $end_date && $all_day ) {
374
-                            $one_day = true;
375
-                        }
376
-
377
-                        if ( $all_day ) {
378
-                            $start_datetime = strtotime( $start_date );
379
-                            $end_datetime = strtotime( $end_date );
371
+						$same_day = false;
372
+						$one_day = false;
373
+						if ( $start_date == $end_date && $all_day ) {
374
+							$one_day = true;
375
+						}
376
+
377
+						if ( $all_day ) {
378
+							$start_datetime = strtotime( $start_date );
379
+							$end_datetime = strtotime( $end_date );
380 380
                             
381
-                            $start_date = date_i18n( $geodir_date_format, $start_datetime );
382
-                            $end_date = date_i18n( $geodir_date_format, $end_datetime );
383
-                            if ( $start_date == $end_date ) {
384
-                                $one_day = true;
385
-                            }
386
-                        } else {
387
-                            if ( $start_date == $end_date && $starttime == $endtime ) {
388
-                                $end_date = date_i18n( 'Y-m-d', strtotime( $start_date . ' ' . $starttime . ' +1 day' ) );
389
-                                $one_day = false;
390
-                            }
391
-                            $start_datetime = strtotime( $start_date . ' ' . $starttime );
392
-                            $end_datetime = strtotime( $end_date . ' ' . $endtime );
381
+							$start_date = date_i18n( $geodir_date_format, $start_datetime );
382
+							$end_date = date_i18n( $geodir_date_format, $end_datetime );
383
+							if ( $start_date == $end_date ) {
384
+								$one_day = true;
385
+							}
386
+						} else {
387
+							if ( $start_date == $end_date && $starttime == $endtime ) {
388
+								$end_date = date_i18n( 'Y-m-d', strtotime( $start_date . ' ' . $starttime . ' +1 day' ) );
389
+								$one_day = false;
390
+							}
391
+							$start_datetime = strtotime( $start_date . ' ' . $starttime );
392
+							$end_datetime = strtotime( $end_date . ' ' . $endtime );
393 393
                             
394
-                            $start_date = date_i18n( $geodir_date_time_format, $start_datetime );
395
-                            $end_date = date_i18n( $geodir_date_time_format, $end_datetime );
396
-                        }
394
+							$start_date = date_i18n( $geodir_date_time_format, $start_datetime );
395
+							$end_date = date_i18n( $geodir_date_time_format, $end_datetime );
396
+						}
397 397
 
398
-                        if ( !$one_day && date_i18n( 'Y-m-d', $start_datetime ) == date_i18n( 'Y-m-d', $end_datetime ) ) {
399
-                            $same_day = true;
398
+						if ( !$one_day && date_i18n( 'Y-m-d', $start_datetime ) == date_i18n( 'Y-m-d', $end_datetime ) ) {
399
+							$same_day = true;
400 400
                             
401
-                            $start_date .= ' - ' . date_i18n( $geodir_time_format, $end_datetime );
402
-                        }
401
+							$start_date .= ' - ' . date_i18n( $geodir_time_format, $end_datetime );
402
+						}
403 403
                         
404
-                        $event_dates .= ' :: ' . $start_date;
404
+						$event_dates .= ' :: ' . $start_date;
405 405
                         
406
-                        if ( !$same_day && !$one_day ) {
407
-                            $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
408
-                        }
409
-                    }
410
-                }
411
-
412
-                if (empty($event_dates)) {
413
-                    continue;
414
-                }
406
+						if ( !$same_day && !$one_day ) {
407
+							$event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
408
+						}
409
+					}
410
+				}
411
+
412
+				if (empty($event_dates)) {
413
+					continue;
414
+				}
415 415
                 
416
-                $post_title .= $event_dates;
417
-            }
416
+				$post_title .= $event_dates;
417
+			}
418 418
 
419
-            $map_cat_ids_array;
420
-            $default_cat = isset($catinfo_obj->default_category) ? $catinfo_obj->default_category : '';
419
+			$map_cat_ids_array;
420
+			$default_cat = isset($catinfo_obj->default_category) ? $catinfo_obj->default_category : '';
421 421
 
422
-            // if single cat lets just show that icon
423
-            if(is_array($map_cat_ids_array) && count($map_cat_ids_array)==1){
424
-                $default_cat = (int)$map_cat_ids_array[0];
425
-            }
422
+			// if single cat lets just show that icon
423
+			if(is_array($map_cat_ids_array) && count($map_cat_ids_array)==1){
424
+				$default_cat = (int)$map_cat_ids_array[0];
425
+			}
426 426
 
427
-            $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : '';
428
-            $mark_extra = (isset($catinfo_obj->marker_extra)) ? $catinfo_obj->marker_extra : '';
429
-            $title = str_replace($srcharr, $replarr, $post_title);
427
+			$icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : '';
428
+			$mark_extra = (isset($catinfo_obj->marker_extra)) ? $catinfo_obj->marker_extra : '';
429
+			$title = str_replace($srcharr, $replarr, $post_title);
430 430
             
431
-            if ($icon != '') {
432
-                $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes;
431
+			if ($icon != '') {
432
+				$gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes;
433 433
                 
434
-                if (isset($gd_marker_sizes[$icon])) {
435
-                    $icon_size = $gd_marker_sizes[$icon];
436
-                } else {
437
-                    $icon_size = geodir_get_marker_size($icon);
438
-                    $gd_marker_sizes[$icon] = $icon_size;
439
-                }               
440
-            } else {
441
-                $icon_size = array('w' => 36, 'h' => 45);
442
-            }
443
-
444
-            $content_data[] = '{"id":"' . $catinfo_obj->post_id . '","t": "' . $title . '","lt": "' . $catinfo_obj->post_latitude . '","ln": "' . $catinfo_obj->post_longitude . '","mk_id":"' . $catinfo_obj->post_id . '_' . $default_cat . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"'.$mark_extra.'}';
445
-            $post_ids[] = $catinfo_obj->post_id;
446
-        }
447
-    }
448
-
449
-    /**
450
-     * Called after marker data is processed into JSON.
451
-     *
452
-     * Called after marker data is processed into JSON, this action can be used to change the format or add/remove markers.
453
-     *
454
-     * @since 1.4.9
455
-     * @param array $content_data The array containing all markers in JSON format.
456
-     * @param object $catinfo The posts object containing all marker data.
457
-     * @see 'geodir_before_marker_post_process'
458
-     */
459
-    do_action('geodir_after_marker_post_process', $content_data, $catinfo);
460
-
461
-    if (!empty($content_data)) {
462
-        $cat_content_info[] = implode(',', $content_data);
463
-    }
464
-
465
-    $totalcount = count(array_unique($post_ids));
466
-
467
-    if (!empty($cat_content_info)) {
468
-        return '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
469
-    }
470
-    else {
471
-        return '[{"totalcount":"0"}]';
472
-    }
434
+				if (isset($gd_marker_sizes[$icon])) {
435
+					$icon_size = $gd_marker_sizes[$icon];
436
+				} else {
437
+					$icon_size = geodir_get_marker_size($icon);
438
+					$gd_marker_sizes[$icon] = $icon_size;
439
+				}               
440
+			} else {
441
+				$icon_size = array('w' => 36, 'h' => 45);
442
+			}
443
+
444
+			$content_data[] = '{"id":"' . $catinfo_obj->post_id . '","t": "' . $title . '","lt": "' . $catinfo_obj->post_latitude . '","ln": "' . $catinfo_obj->post_longitude . '","mk_id":"' . $catinfo_obj->post_id . '_' . $default_cat . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"'.$mark_extra.'}';
445
+			$post_ids[] = $catinfo_obj->post_id;
446
+		}
447
+	}
448
+
449
+	/**
450
+	 * Called after marker data is processed into JSON.
451
+	 *
452
+	 * Called after marker data is processed into JSON, this action can be used to change the format or add/remove markers.
453
+	 *
454
+	 * @since 1.4.9
455
+	 * @param array $content_data The array containing all markers in JSON format.
456
+	 * @param object $catinfo The posts object containing all marker data.
457
+	 * @see 'geodir_before_marker_post_process'
458
+	 */
459
+	do_action('geodir_after_marker_post_process', $content_data, $catinfo);
460
+
461
+	if (!empty($content_data)) {
462
+		$cat_content_info[] = implode(',', $content_data);
463
+	}
464
+
465
+	$totalcount = count(array_unique($post_ids));
466
+
467
+	if (!empty($cat_content_info)) {
468
+		return '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
469
+	}
470
+	else {
471
+		return '[{"totalcount":"0"}]';
472
+	}
473 473
 }
474 474
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     $gd_session->set('homemap_catlist_ptype', $gd_post_type);
13 13
     $post_taxonomy = geodir_get_taxonomies($gd_post_type);
14 14
     $map_canvas_name = sanitize_text_field($_REQUEST['map_canvas']);
15
-    $child_collapse = (bool)$_REQUEST['child_collapse'];
15
+    $child_collapse = (bool) $_REQUEST['child_collapse'];
16 16
     echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true);
17 17
     die;
18 18
 }
@@ -32,21 +32,21 @@  discard block
 block discarded – undo
32 32
     global $wpdb, $plugin_prefix, $gd_session;
33 33
 
34 34
     if ($_REQUEST['m_id'] != '') {
35
-        $pid = (int)$_REQUEST['m_id'];
35
+        $pid = (int) $_REQUEST['m_id'];
36 36
     } else {
37 37
         echo __('No marker data found', 'geodirectory');
38 38
         exit;
39 39
     }
40 40
 
41 41
     if (isset($_REQUEST['post_preview']) && $_REQUEST['post_preview'] != '' && $gd_ses_listing = $gd_session->get('listing')) {
42
-        $post = (object)$gd_ses_listing;
42
+        $post = (object) $gd_ses_listing;
43 43
         echo geodir_get_infowindow_html($post, $_REQUEST['post_preview']);
44 44
     } else {
45 45
         $geodir_post_type = get_post_type($pid);
46 46
 
47
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
47
+        $table = $plugin_prefix.$geodir_post_type.'_detail';
48 48
 
49
-        $sql = $wpdb->prepare("SELECT * FROM " . $table . " WHERE post_id = %d", array($pid));
49
+        $sql = $wpdb->prepare("SELECT * FROM ".$table." WHERE post_id = %d", array($pid));
50 50
 
51 51
         $postinfo = $wpdb->get_results($sql);
52 52
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     $post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place';
91 91
 
92 92
     $map_cat_ids_array = array('0');
93
-    $cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)");
93
+    $cat_find_array = array(" FIND_IN_SET(%d, pd.".$post_type."category)");
94 94
 
95 95
 
96 96
     $field_default_cat = '';
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
         $map_cat_arr = trim($_REQUEST['cat_id'], ',');
99 99
 
100 100
         if (!empty($map_cat_arr)) {
101
-            $field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category ";
101
+            $field_default_cat .= "WHEN (default_category IN (".$map_cat_arr.")) THEN default_category ";
102 102
 
103 103
             $map_cat_ids_array = explode(',', $map_cat_arr);
104 104
             $cat_find_array = array();
105 105
             foreach ($map_cat_ids_array as $cat_id) {
106
-                $field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `" . $post_type . "category`) > 0) THEN $cat_id ";
107
-                $cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)";
106
+                $field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `".$post_type."category`) > 0) THEN $cat_id ";
107
+                $cat_find_array[] = " FIND_IN_SET(%d, pd.".$post_type."category)";
108 108
                 $main_query_array[] = $cat_id;
109 109
             }
110 110
 
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
         $field_default_cat = '';
116 116
 
117 117
     if (!empty($cat_find_array))
118
-        $search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
118
+        $search .= "AND (".implode(' OR ', $cat_find_array).")";
119 119
 
120 120
     $main_query_array = $map_cat_ids_array;
121 121
   
122 122
     if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) {
123 123
         $search .= " AND p.post_title LIKE %s";
124
-        $main_query_array[] = "%" . $_REQUEST['search'] . "%";
124
+        $main_query_array[] = "%".$_REQUEST['search']."%";
125 125
     }
126 126
 
127 127
     /**
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
 
144 144
     $gd_posttype = '';
145 145
     if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') {
146
-        $table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail';
146
+        $table = $plugin_prefix.$_REQUEST['gd_posttype'].'_detail';
147 147
         $gd_posttype = " AND p.post_type = %s";
148 148
         $main_query_array[] = $_REQUEST['gd_posttype'];
149 149
 
150 150
     } else
151
-        $table = $plugin_prefix . 'gd_place_detail';
151
+        $table = $plugin_prefix.'gd_place_detail';
152 152
 
153
-    $join = ", " . $table . " AS pd ";
153
+    $join = ", ".$table." AS pd ";
154 154
 
155 155
     /**
156 156
 	 * Filter the SQL JOIN clause for the markers data
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	$search = apply_filters('geodir_home_map_listing_where', $search);
172 172
     $search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search);
173
-    $cat_type = $post_type . 'category';
173
+    $cat_type = $post_type.'category';
174 174
     if ($post_type == 'gd_event') {
175 175
         $event_select = ", pd.recurring_dates, pd.is_recurring";
176 176
     } else {
177 177
         $event_select = "";
178 178
     }
179 179
 
180
-    $sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select;
180
+    $sql_select = 'SELECT pd.default_category, pd.'.$cat_type.', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude'.$event_select;
181 181
     /**
182 182
 	 * Filter the SQL SELECT clause to retrive fields data
183 183
 	 *
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	$groupby = apply_filters('geodir_home_map_listing_groupby', $groupby);
199 199
 
200
-    $catsql = $wpdb->prepare("$select $field_default_cat FROM " . $wpdb->posts . " as p" . $join . " WHERE p.ID = pd.post_id AND p.post_status = 'publish' " . $search . $gd_posttype . $groupby , $main_query_array);
200
+    $catsql = $wpdb->prepare("$select $field_default_cat FROM ".$wpdb->posts." as p".$join." WHERE p.ID = pd.post_id AND p.post_status = 'publish' ".$search.$gd_posttype.$groupby, $main_query_array);
201 201
     
202 202
 	/**
203 203
 	 * Filter the SQL query to retrive markers data
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         global $geodir_date_time_format, $geodir_date_format, $geodir_time_format;
244 244
 
245 245
         $today = strtotime(date_i18n('Y-m-d'));
246
-        $show_dates = $post_type == 'gd_event' ? (int)get_option('geodir_event_infowindow_dates_count', 1) : 0;
246
+        $show_dates = $post_type == 'gd_event' ? (int) get_option('geodir_event_infowindow_dates_count', 1) : 0;
247 247
         
248 248
         foreach ($catinfo as $catinfo_obj) {
249 249
             $post_title = $catinfo_obj->post_title;
@@ -259,29 +259,29 @@  discard block
 block discarded – undo
259 259
                     $endtimes = '';
260 260
                     $astarttimes = array();
261 261
                     $aendtimes = array();
262
-                    if ( !isset( $recurring_data['repeat_type'] ) ) {
262
+                    if (!isset($recurring_data['repeat_type'])) {
263 263
                         $recurring_data['repeat_type'] = 'custom';
264 264
                     }
265
-                    $repeat_type = isset( $recurring_data['repeat_type'] ) && in_array( $recurring_data['repeat_type'], array( 'day', 'week', 'month', 'year', 'custom' ) ) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom
266
-                    $different_times = isset( $recurring_data['different_times'] ) && !empty( $recurring_data['different_times'] ) ? true : false;
265
+                    $repeat_type = isset($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom
266
+                    $different_times = isset($recurring_data['different_times']) && !empty($recurring_data['different_times']) ? true : false;
267 267
         
268 268
                     $recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
269 269
                     
270
-                    if ( !empty( $recurring_dates ) ) {
271
-                        if ( empty( $recurring_data['all_day'] ) ) {
272
-                            if ( $repeat_type == 'custom' && $different_times ) {
273
-                                $astarttimes = isset( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
274
-                                $aendtimes = isset( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
270
+                    if (!empty($recurring_dates)) {
271
+                        if (empty($recurring_data['all_day'])) {
272
+                            if ($repeat_type == 'custom' && $different_times) {
273
+                                $astarttimes = isset($recurring_data['starttimes']) ? $recurring_data['starttimes'] : array();
274
+                                $aendtimes = isset($recurring_data['endtimes']) ? $recurring_data['endtimes'] : array();
275 275
                             } else {
276
-                                $starttimes = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
277
-                                $endtimes = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
276
+                                $starttimes = isset($recurring_data['starttime']) ? $recurring_data['starttime'] : '';
277
+                                $endtimes = isset($recurring_data['endtime']) ? $recurring_data['endtime'] : '';
278 278
                             }
279 279
                         }
280 280
                         
281 281
                         $e = 0;
282
-                        foreach( $recurring_dates as $key => $date ) {
283
-                            if ( $repeat_type == 'custom' && $different_times ) {
284
-                                if ( !empty( $astarttimes ) && isset( $astarttimes[$key] ) ) {
282
+                        foreach ($recurring_dates as $key => $date) {
283
+                            if ($repeat_type == 'custom' && $different_times) {
284
+                                if (!empty($astarttimes) && isset($astarttimes[$key])) {
285 285
                                     $starttimes = $astarttimes[$key];
286 286
                                     $endtimes = $aendtimes[$key];
287 287
                                 } else {
@@ -290,50 +290,50 @@  discard block
 block discarded – undo
290 290
                                 }
291 291
                             }
292 292
                             
293
-                            $duration = isset( $recurring_data['duration_x'] ) && (int)$recurring_data['duration_x'] > 0 ? (int)$recurring_data['duration_x'] : 1;
293
+                            $duration = isset($recurring_data['duration_x']) && (int) $recurring_data['duration_x'] > 0 ? (int) $recurring_data['duration_x'] : 1;
294 294
                             $duration--;
295
-                            $enddate = date_i18n( 'Y-m-d', strtotime( $date . ' + ' . $duration . ' day' ) );
295
+                            $enddate = date_i18n('Y-m-d', strtotime($date.' + '.$duration.' day'));
296 296
                             
297 297
                             // Hide past dates
298
-                            if ( strtotime( $enddate ) < $today ) {
298
+                            if (strtotime($enddate) < $today) {
299 299
                                 continue;
300 300
                             }
301 301
                                     
302
-                            $sdate = strtotime( $date . ' ' . $starttimes );
303
-                            $edate = strtotime( $enddate . ' ' . $endtimes );
302
+                            $sdate = strtotime($date.' '.$starttimes);
303
+                            $edate = strtotime($enddate.' '.$endtimes);
304 304
                                         
305
-                            $start_date = date_i18n( $geodir_date_time_format, $sdate );
306
-                            $end_date = date_i18n( $geodir_date_time_format, $edate );
305
+                            $start_date = date_i18n($geodir_date_time_format, $sdate);
306
+                            $end_date = date_i18n($geodir_date_time_format, $edate);
307 307
                             
308 308
                             $same_day = false;
309 309
                             $full_day = false;
310 310
                             $same_datetime = false;
311 311
                             
312
-                            if ( $starttimes == $endtimes && ( $starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00' ) ) {
312
+                            if ($starttimes == $endtimes && ($starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00')) {
313 313
                                 $full_day = true;
314 314
                             }
315 315
                             
316
-                            if ( $start_date == $end_date && $full_day ) {
316
+                            if ($start_date == $end_date && $full_day) {
317 317
                                 $same_datetime = true;
318 318
                             }
319 319
 
320
-                            $link_date = date_i18n( 'Y-m-d', $sdate );
321
-                            $title_date = date_i18n( $geodir_date_format, $sdate );
322
-                            if ( $full_day ) {
320
+                            $link_date = date_i18n('Y-m-d', $sdate);
321
+                            $title_date = date_i18n($geodir_date_format, $sdate);
322
+                            if ($full_day) {
323 323
                                 $start_date = $title_date;
324
-                                $end_date = date_i18n( $geodir_date_format, $edate );
324
+                                $end_date = date_i18n($geodir_date_format, $edate);
325 325
                             }
326 326
                             
327
-                            if ( !$same_datetime && !$full_day && date_i18n( 'Y-m-d', $sdate ) == date_i18n( 'Y-m-d', $edate ) ) {
327
+                            if (!$same_datetime && !$full_day && date_i18n('Y-m-d', $sdate) == date_i18n('Y-m-d', $edate)) {
328 328
                                 $same_day = true;
329 329
                                 
330
-                                $start_date .= ' - ' . date_i18n( $geodir_time_format, $edate );
330
+                                $start_date .= ' - '.date_i18n($geodir_time_format, $edate);
331 331
                             }
332 332
                             
333
-                            $event_dates .= ' :: ' . $start_date;
333
+                            $event_dates .= ' :: '.$start_date;
334 334
                         
335
-                            if ( !$same_day && !$same_datetime ) {
336
-                                $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
335
+                            if (!$same_day && !$same_datetime) {
336
+                                $event_dates .= ' '.__('to', 'geodirectory').' '.$end_date;
337 337
                             }
338 338
                             
339 339
                             $e++;
@@ -344,67 +344,67 @@  discard block
 block discarded – undo
344 344
                         }
345 345
                     }
346 346
                 } else {
347
-                    $start_date = isset( $recurring_data['event_start'] ) ? $recurring_data['event_start'] : '';
348
-                    $end_date = isset( $recurring_data['event_end'] ) ? $recurring_data['event_end'] : $start_date;
349
-                    $all_day = isset( $recurring_data['all_day'] ) && !empty( $recurring_data['all_day'] ) ? true : false;
350
-                    $starttime = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
351
-                    $endtime = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
347
+                    $start_date = isset($recurring_data['event_start']) ? $recurring_data['event_start'] : '';
348
+                    $end_date = isset($recurring_data['event_end']) ? $recurring_data['event_end'] : $start_date;
349
+                    $all_day = isset($recurring_data['all_day']) && !empty($recurring_data['all_day']) ? true : false;
350
+                    $starttime = isset($recurring_data['starttime']) ? $recurring_data['starttime'] : '';
351
+                    $endtime = isset($recurring_data['endtime']) ? $recurring_data['endtime'] : '';
352 352
                 
353
-                    $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
354
-                    $starttimes = isset( $recurring_data['starttimes'] ) && !empty( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
355
-                    $endtimes = isset( $recurring_data['endtimes'] ) && !empty( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
353
+                    $event_recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
354
+                    $starttimes = isset($recurring_data['starttimes']) && !empty($recurring_data['starttimes']) ? $recurring_data['starttimes'] : array();
355
+                    $endtimes = isset($recurring_data['endtimes']) && !empty($recurring_data['endtimes']) ? $recurring_data['endtimes'] : array();
356 356
                     
357
-                    if ( !geodir_event_is_date( $start_date ) && !empty( $event_recurring_dates ) ) {
357
+                    if (!geodir_event_is_date($start_date) && !empty($event_recurring_dates)) {
358 358
                         $start_date = $event_recurring_dates[0];
359 359
                     }
360 360
                                 
361
-                    if ( strtotime( $end_date ) < strtotime( $start_date ) ) {
361
+                    if (strtotime($end_date) < strtotime($start_date)) {
362 362
                         $end_date = $start_date;
363 363
                     }
364 364
                     
365 365
                     if ($end_date != '' && strtotime($end_date) >= $today) {
366
-                        if ( $starttime == '' && !empty( $starttimes ) ) {
366
+                        if ($starttime == '' && !empty($starttimes)) {
367 367
                             $starttime = $starttimes[0];
368 368
                             $endtime = $endtimes[0];
369 369
                         }
370 370
                         
371 371
                         $same_day = false;
372 372
                         $one_day = false;
373
-                        if ( $start_date == $end_date && $all_day ) {
373
+                        if ($start_date == $end_date && $all_day) {
374 374
                             $one_day = true;
375 375
                         }
376 376
 
377
-                        if ( $all_day ) {
378
-                            $start_datetime = strtotime( $start_date );
379
-                            $end_datetime = strtotime( $end_date );
377
+                        if ($all_day) {
378
+                            $start_datetime = strtotime($start_date);
379
+                            $end_datetime = strtotime($end_date);
380 380
                             
381
-                            $start_date = date_i18n( $geodir_date_format, $start_datetime );
382
-                            $end_date = date_i18n( $geodir_date_format, $end_datetime );
383
-                            if ( $start_date == $end_date ) {
381
+                            $start_date = date_i18n($geodir_date_format, $start_datetime);
382
+                            $end_date = date_i18n($geodir_date_format, $end_datetime);
383
+                            if ($start_date == $end_date) {
384 384
                                 $one_day = true;
385 385
                             }
386 386
                         } else {
387
-                            if ( $start_date == $end_date && $starttime == $endtime ) {
388
-                                $end_date = date_i18n( 'Y-m-d', strtotime( $start_date . ' ' . $starttime . ' +1 day' ) );
387
+                            if ($start_date == $end_date && $starttime == $endtime) {
388
+                                $end_date = date_i18n('Y-m-d', strtotime($start_date.' '.$starttime.' +1 day'));
389 389
                                 $one_day = false;
390 390
                             }
391
-                            $start_datetime = strtotime( $start_date . ' ' . $starttime );
392
-                            $end_datetime = strtotime( $end_date . ' ' . $endtime );
391
+                            $start_datetime = strtotime($start_date.' '.$starttime);
392
+                            $end_datetime = strtotime($end_date.' '.$endtime);
393 393
                             
394
-                            $start_date = date_i18n( $geodir_date_time_format, $start_datetime );
395
-                            $end_date = date_i18n( $geodir_date_time_format, $end_datetime );
394
+                            $start_date = date_i18n($geodir_date_time_format, $start_datetime);
395
+                            $end_date = date_i18n($geodir_date_time_format, $end_datetime);
396 396
                         }
397 397
 
398
-                        if ( !$one_day && date_i18n( 'Y-m-d', $start_datetime ) == date_i18n( 'Y-m-d', $end_datetime ) ) {
398
+                        if (!$one_day && date_i18n('Y-m-d', $start_datetime) == date_i18n('Y-m-d', $end_datetime)) {
399 399
                             $same_day = true;
400 400
                             
401
-                            $start_date .= ' - ' . date_i18n( $geodir_time_format, $end_datetime );
401
+                            $start_date .= ' - '.date_i18n($geodir_time_format, $end_datetime);
402 402
                         }
403 403
                         
404
-                        $event_dates .= ' :: ' . $start_date;
404
+                        $event_dates .= ' :: '.$start_date;
405 405
                         
406
-                        if ( !$same_day && !$one_day ) {
407
-                            $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
406
+                        if (!$same_day && !$one_day) {
407
+                            $event_dates .= ' '.__('to', 'geodirectory').' '.$end_date;
408 408
                         }
409 409
                     }
410 410
                 }
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
             $default_cat = isset($catinfo_obj->default_category) ? $catinfo_obj->default_category : '';
421 421
 
422 422
             // if single cat lets just show that icon
423
-            if(is_array($map_cat_ids_array) && count($map_cat_ids_array)==1){
424
-                $default_cat = (int)$map_cat_ids_array[0];
423
+            if (is_array($map_cat_ids_array) && count($map_cat_ids_array) == 1) {
424
+                $default_cat = (int) $map_cat_ids_array[0];
425 425
             }
426 426
 
427 427
             $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : '';
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
                 $icon_size = array('w' => 36, 'h' => 45);
442 442
             }
443 443
 
444
-            $content_data[] = '{"id":"' . $catinfo_obj->post_id . '","t": "' . $title . '","lt": "' . $catinfo_obj->post_latitude . '","ln": "' . $catinfo_obj->post_longitude . '","mk_id":"' . $catinfo_obj->post_id . '_' . $default_cat . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"'.$mark_extra.'}';
444
+            $content_data[] = '{"id":"'.$catinfo_obj->post_id.'","t": "'.$title.'","lt": "'.$catinfo_obj->post_latitude.'","ln": "'.$catinfo_obj->post_longitude.'","mk_id":"'.$catinfo_obj->post_id.'_'.$default_cat.'","i":"'.$icon.'","w":"'.$icon_size['w'].'","h":"'.$icon_size['h'].'"'.$mark_extra.'}';
445 445
             $post_ids[] = $catinfo_obj->post_id;
446 446
         }
447 447
     }
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
     $totalcount = count(array_unique($post_ids));
466 466
 
467 467
     if (!empty($cat_content_info)) {
468
-        return '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
468
+        return '[{"totalcount":"'.$totalcount.'",'.substr(implode(',', $cat_content_info), 1).']';
469 469
     }
470 470
     else {
471 471
         return '[{"totalcount":"0"}]';
Please login to merge, or discard this patch.
geodirectory-admin/admin_hooks_actions.php 3 patches
Indentation   +1619 added lines, -1619 removed lines patch added patch discarded remove patch
@@ -10,33 +10,33 @@  discard block
 block discarded – undo
10 10
 
11 11
 add_action('admin_init', 'geodir_admin_init');
12 12
 if (!function_exists('geodir_admin_init')) {
13
-    /**
14
-     * Adds GD setting pages in admin.
15
-     *
16
-     * @since 1.0.0
17
-     * @package GeoDirectory
18
-     * @global string $current_tab The current settings tab name.
19
-     */
20
-    function geodir_admin_init()
21
-    {
22
-
23
-        if (is_admin()):
24
-            global $current_tab;
25
-            geodir_redirect_to_admin_panel_on_installed();
26
-            $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
-            if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
-                geodir_handle_option_form_submit($current_tab); // located in admin function.php
29
-            /**
30
-             * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31
-             *
32
-             * @since 1.0.0
33
-             */
34
-            do_action('admin_panel_init');
35
-            add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
36
-
37
-
38
-        endif;
39
-    }
13
+	/**
14
+	 * Adds GD setting pages in admin.
15
+	 *
16
+	 * @since 1.0.0
17
+	 * @package GeoDirectory
18
+	 * @global string $current_tab The current settings tab name.
19
+	 */
20
+	function geodir_admin_init()
21
+	{
22
+
23
+		if (is_admin()):
24
+			global $current_tab;
25
+			geodir_redirect_to_admin_panel_on_installed();
26
+			$current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
+			if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
+				geodir_handle_option_form_submit($current_tab); // located in admin function.php
29
+			/**
30
+			 * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31
+			 *
32
+			 * @since 1.0.0
33
+			 */
34
+			do_action('admin_panel_init');
35
+			add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
36
+
37
+
38
+		endif;
39
+	}
40 40
 }
41 41
 
42 42
 /**
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function geodir_redirect_to_admin_panel_on_installed()
49 49
 {
50
-    if (get_option('geodir_installation_redirect', false)) {
51
-        delete_option('geodir_installation_redirect');
52
-        wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
53
-    }
50
+	if (get_option('geodir_installation_redirect', false)) {
51
+		delete_option('geodir_installation_redirect');
52
+		wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
53
+	}
54 54
 }
55 55
 
56 56
 /**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function geodir_get_admin_option_form($current_tab)
64 64
 {
65
-    geodir_admin_option_form($current_tab);// defined in admin template tags.php
65
+	geodir_admin_option_form($current_tab);// defined in admin template tags.php
66 66
 }
67 67
 
68 68
 
@@ -86,24 +86,24 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function geodir_conditional_admin_script_load()
88 88
 {
89
-    global $pagenow;
89
+	global $pagenow;
90 90
 	
91 91
 	// Get the current post type
92 92
 	$post_type = geodir_admin_current_post_type();
93 93
 	$geodir_post_types = geodir_get_posttypes();
94 94
     
95 95
 	if ((isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') || (($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') && $post_type && in_array($post_type, $geodir_post_types)) || ($pagenow == 'edit-tags.php' || $pagenow == 'term.php' || $pagenow == 'edit-comments.php' || $pagenow == 'comment.php')) {
96
-        add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
97
-        add_action('admin_enqueue_scripts', 'geodir_admin_styles');
98
-        add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
96
+		add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
97
+		add_action('admin_enqueue_scripts', 'geodir_admin_styles');
98
+		add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
99 99
         
100
-        // Disable VC editor for GD post types.
101
-        if (class_exists('Vc_Role_Access_Controller')) {
102
-            add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 );
103
-        }
104
-    }
100
+		// Disable VC editor for GD post types.
101
+		if (class_exists('Vc_Role_Access_Controller')) {
102
+			add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 );
103
+		}
104
+	}
105 105
 
106
-    add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
106
+	add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
107 107
 
108 108
 }
109 109
 
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
  */
139 139
 function create_default_admin_main_nav()
140 140
 {
141
-    add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
142
-    add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
143
-    add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
144
-    add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
145
-    add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
146
-    //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
141
+	add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
142
+	add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
143
+	add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
144
+	add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
145
+	add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
146
+	//add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
147 147
 
148 148
 }
149 149
 
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
  */
157 157
 function geodir_admin_list_columns()
158 158
 {
159
-    if ($post_types = geodir_get_posttypes()) {
159
+	if ($post_types = geodir_get_posttypes()) {
160 160
 
161
-        foreach ($post_types as $post_type):
162
-            add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
163
-            //Filter-Payment-Manager to show Package
164
-            add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
161
+		foreach ($post_types as $post_type):
162
+			add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
163
+			//Filter-Payment-Manager to show Package
164
+			add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
165 165
 
166
-            add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
167
-        endforeach;
168
-    }
166
+			add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
167
+		endforeach;
168
+	}
169 169
 }
170 170
 
171 171
 /**
@@ -178,15 +178,15 @@  discard block
 block discarded – undo
178 178
  */
179 179
 function geodir_default_admin_main_tabs($tabs)
180 180
 {
181
-    return $tabs = array(
182
-        'general_settings' => array('label' => __('General', 'geodirectory')),
183
-        'design_settings' => array('label' => __('Design', 'geodirectory')),
184
-        'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
185
-        'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
186
-        'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
187
-        'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
188
-
189
-    );
181
+	return $tabs = array(
182
+		'general_settings' => array('label' => __('General', 'geodirectory')),
183
+		'design_settings' => array('label' => __('Design', 'geodirectory')),
184
+		'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
185
+		'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
186
+		'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
187
+		'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
188
+
189
+	);
190 190
 }
191 191
 
192 192
 add_action('do_meta_boxes', 'geodir_remove_image_box');
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
  */
200 200
 function geodir_remove_image_box()
201 201
 {
202
-    global $post;
202
+	global $post;
203 203
 
204
-    $geodir_posttypes = geodir_get_posttypes();
204
+	$geodir_posttypes = geodir_get_posttypes();
205 205
 
206
-    if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
206
+	if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
207 207
 
208
-        remove_meta_box('postimagediv', $post->post_type, 'side');
209
-        remove_meta_box('revisionsdiv', $post->post_type, 'normal');
208
+		remove_meta_box('postimagediv', $post->post_type, 'side');
209
+		remove_meta_box('revisionsdiv', $post->post_type, 'normal');
210 210
 
211
-    endif;
211
+	endif;
212 212
 
213 213
 }
214 214
 
@@ -223,27 +223,27 @@  discard block
 block discarded – undo
223 223
  */
224 224
 function geodir_meta_box_add()
225 225
 {
226
-    global $post;
226
+	global $post;
227 227
 
228
-    $geodir_post_types = geodir_get_posttypes('array');
229
-    $geodir_posttypes = array_keys($geodir_post_types);
228
+	$geodir_post_types = geodir_get_posttypes('array');
229
+	$geodir_posttypes = array_keys($geodir_post_types);
230 230
 
231
-    if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
231
+	if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
232 232
 
233
-        $geodir_posttype = $post->post_type;
234
-        $post_typename = __($geodir_post_types[$geodir_posttype]['labels']['singular_name'], 'geodirectory');
235
-        $post_typename = geodir_ucwords($post_typename);
233
+		$geodir_posttype = $post->post_type;
234
+		$post_typename = __($geodir_post_types[$geodir_posttype]['labels']['singular_name'], 'geodirectory');
235
+		$post_typename = geodir_ucwords($post_typename);
236 236
 
237
-        // Filter-Payment-Manager
237
+		// Filter-Payment-Manager
238 238
 
239
-        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
239
+		add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
240 240
 
241
-        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
241
+		add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
242 242
 
243
-        // no need of this box as all fields moved to main information box
244
-        //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
243
+		// no need of this box as all fields moved to main information box
244
+		//add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
245 245
 
246
-    endif;
246
+	endif;
247 247
 
248 248
 }
249 249
 
@@ -267,23 +267,23 @@  discard block
 block discarded – undo
267 267
 function geodir_hide_post_taxonomy_meta_boxes()
268 268
 {
269 269
 
270
-    $geodir_post_types = get_option('geodir_post_types');
270
+	$geodir_post_types = get_option('geodir_post_types');
271 271
 
272
-    if (!empty($geodir_post_types)) {
273
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
272
+	if (!empty($geodir_post_types)) {
273
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
274 274
 
275
-            $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
275
+			$gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
276 276
 
277
-            if(!empty($gd_taxonomy)) {
278
-                foreach ($gd_taxonomy as $tax) {
277
+			if(!empty($gd_taxonomy)) {
278
+				foreach ($gd_taxonomy as $tax) {
279 279
 
280
-                    remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
280
+					remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
281 281
 
282
-                }
283
-            }
282
+				}
283
+			}
284 284
 
285
-        }
286
-    }
285
+		}
286
+	}
287 287
 }
288 288
 
289 289
 add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict');
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
  */
298 298
 function geodir_add_listing_map_restrict($map_restirct)
299 299
 {
300
-    if (is_admin()) {
301
-        if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
302
-            $map_restirct = false;
303
-        }
304
-    }
305
-    return $map_restirct;
300
+	if (is_admin()) {
301
+		if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
302
+			$map_restirct = false;
303
+		}
304
+	}
305
+	return $map_restirct;
306 306
 }
307 307
 
308 308
 
@@ -321,16 +321,16 @@  discard block
 block discarded – undo
321 321
 function geodir_enable_editor_on_notifications($notification)
322 322
 {
323 323
 
324
-    if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
324
+	if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
325 325
 
326
-        foreach ($notification as $key => $value) {
327
-            if ($value['type'] == 'textarea')
328
-                $notification[$key]['type'] = 'editor';
329
-        }
326
+		foreach ($notification as $key => $value) {
327
+			if ($value['type'] == 'textarea')
328
+				$notification[$key]['type'] = 'editor';
329
+		}
330 330
 
331
-    }
331
+	}
332 332
 
333
-    return $notification;
333
+	return $notification;
334 334
 }
335 335
 
336 336
 
@@ -347,16 +347,16 @@  discard block
 block discarded – undo
347 347
 function geodir_enable_editor_on_design_settings($design_setting)
348 348
 {
349 349
 
350
-    if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
350
+	if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
351 351
 
352
-        foreach ($design_setting as $key => $value) {
353
-            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
354
-                $design_setting[$key]['type'] = 'editor';
355
-        }
352
+		foreach ($design_setting as $key => $value) {
353
+			if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
354
+				$design_setting[$key]['type'] = 'editor';
355
+		}
356 356
 
357
-    }
357
+	}
358 358
 
359
-    return $design_setting;
359
+	return $design_setting;
360 360
 }
361 361
 
362 362
 /* ----------- START MANAGE CUSTOM FIELDS ---------------- */
@@ -364,15 +364,15 @@  discard block
 block discarded – undo
364 364
 add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom');
365 365
 
366 366
 function geodir_manage_available_fields_predefined($sub_tab){
367
-    if($sub_tab=='custom_fields'){
368
-        geodir_custom_available_fields('predefined');
369
-    }
367
+	if($sub_tab=='custom_fields'){
368
+		geodir_custom_available_fields('predefined');
369
+	}
370 370
 }
371 371
 
372 372
 function geodir_manage_available_fields_custom($sub_tab){
373
-    if($sub_tab=='custom_fields'){
374
-        geodir_custom_available_fields('custom');
375
-    }
373
+	if($sub_tab=='custom_fields'){
374
+		geodir_custom_available_fields('custom');
375
+	}
376 376
 }
377 377
 
378 378
 
@@ -391,16 +391,16 @@  discard block
 block discarded – undo
391 391
 function geodir_manage_available_fields($sub_tab)
392 392
 {
393 393
 
394
-    switch ($sub_tab) {
395
-        case 'custom_fields':
396
-            geodir_custom_available_fields();
397
-            break;
394
+	switch ($sub_tab) {
395
+		case 'custom_fields':
396
+			geodir_custom_available_fields();
397
+			break;
398 398
 
399
-        case 'sorting_options':
400
-            geodir_sorting_options_available_fields();
401
-            break;
399
+		case 'sorting_options':
400
+			geodir_sorting_options_available_fields();
401
+			break;
402 402
 
403
-    }
403
+	}
404 404
 }
405 405
 
406 406
 
@@ -416,16 +416,16 @@  discard block
 block discarded – undo
416 416
 function geodir_manage_selected_fields($sub_tab)
417 417
 {
418 418
 
419
-    switch ($sub_tab) {
420
-        case 'custom_fields':
421
-            geodir_custom_selected_fields();
422
-            break;
419
+	switch ($sub_tab) {
420
+		case 'custom_fields':
421
+			geodir_custom_selected_fields();
422
+			break;
423 423
 
424
-        case 'sorting_options':
425
-            geodir_sorting_options_selected_fields();
426
-            break;
424
+		case 'sorting_options':
425
+			geodir_sorting_options_selected_fields();
426
+			break;
427 427
 
428
-    }
428
+	}
429 429
 }
430 430
 
431 431
 /**
@@ -437,52 +437,52 @@  discard block
 block discarded – undo
437 437
  */
438 438
 function geodir_sorting_options_available_fields()
439 439
 {
440
-    global $wpdb;
441
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
442
-    ?>
440
+	global $wpdb;
441
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
442
+	?>
443 443
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
444 444
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
445 445
     <ul>
446 446
     <?php
447
-        $sort_options = geodir_get_custom_sort_options($listing_type);
447
+		$sort_options = geodir_get_custom_sort_options($listing_type);
448 448
         
449
-        foreach ($sort_options as $key => $val) {
450
-            $val = stripslashes_deep($val); // strip slashes
451
-
452
-            $check_html_variable = $wpdb->get_var(
453
-                $wpdb->prepare(
454
-                    "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
455
-                    array($val['htmlvar_name'], $listing_type, $val['field_type'])
456
-                )
457
-            );
449
+		foreach ($sort_options as $key => $val) {
450
+			$val = stripslashes_deep($val); // strip slashes
451
+
452
+			$check_html_variable = $wpdb->get_var(
453
+				$wpdb->prepare(
454
+					"SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
455
+					array($val['htmlvar_name'], $listing_type, $val['field_type'])
456
+				)
457
+			);
458 458
             
459
-            $display = $check_html_variable ? ' style="display:none;"' : '';
460
-           ?>
459
+			$display = $check_html_variable ? ' style="display:none;"' : '';
460
+		   ?>
461 461
 
462 462
             <li   class="gd-cf-tooltip-wrap" <?php echo $display;?>>
463 463
                 <?php
464
-                if(isset($val['description']) && $val['description']){
465
-                    echo '<div class="gdcf-tooltip">'.$val['description'].'</div>';
466
-                }?>
464
+				if(isset($val['description']) && $val['description']){
465
+					echo '<div class="gdcf-tooltip">'.$val['description'].'</div>';
466
+				}?>
467 467
 
468 468
                 <a id="gd-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" data-field-type-key="<?php echo $val['htmlvar_name'];?>"  data-field-type="<?php echo $val['field_type'];?>"
469 469
                    title="<?php echo $val['site_title'];?>"
470 470
                    class="gd-draggable-form-items  gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);">
471 471
                     <?php if (isset($val['field_icon']) && strpos($val['field_icon'], 'fa fa-') !== false) {
472
-                        echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>';
473
-                    }elseif(isset($val['field_icon']) && $val['field_icon'] ){
474
-                        echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>';
475
-                    }else{
476
-                        echo '<i class="fa fa-cog" aria-hidden="true"></i>';
477
-                    }?>
472
+						echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>';
473
+					}elseif(isset($val['field_icon']) && $val['field_icon'] ){
474
+						echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>';
475
+					}else{
476
+						echo '<i class="fa fa-cog" aria-hidden="true"></i>';
477
+					}?>
478 478
                     <?php echo $val['site_title'];?>
479 479
                 </a>
480 480
             </li>
481 481
 
482 482
 
483 483
             <?php
484
-        }
485
-    ?>
484
+		}
485
+	?>
486 486
     </ul>
487 487
     <?php
488 488
 }
@@ -496,28 +496,28 @@  discard block
 block discarded – undo
496 496
  */
497 497
 function geodir_sorting_options_selected_fields()
498 498
 {
499
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
500
-    ?>
499
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
500
+	?>
501 501
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
502 502
     <ul class="core">
503 503
     <?php 
504
-        global $wpdb;
504
+		global $wpdb;
505 505
         
506
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
506
+		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
507 507
 
508
-        if (!empty($fields)) {
509
-            foreach ($fields as $field) {
510
-                //$result_str = $field->id;
511
-                $result_str = $field;
512
-                $field_type = $field->field_type;
513
-                $field_ins_upd = 'display';
508
+		if (!empty($fields)) {
509
+			foreach ($fields as $field) {
510
+				//$result_str = $field->id;
511
+				$result_str = $field;
512
+				$field_type = $field->field_type;
513
+				$field_ins_upd = 'display';
514 514
 
515
-                $default = false;
515
+				$default = false;
516 516
 
517
-                geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
518
-            }
519
-        }
520
-    ?>
517
+				geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
518
+			}
519
+		}
520
+	?>
521 521
     </ul>
522 522
     <?php
523 523
 }
@@ -530,12 +530,12 @@  discard block
 block discarded – undo
530 530
  */
531 531
 function geodir_custom_fields_custom($post_type=''){
532 532
 
533
-    $custom_fields = array();
533
+	$custom_fields = array();
534 534
 
535
-    /**
536
-     * @see `geodir_custom_fields`
537
-     */
538
-    return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
535
+	/**
536
+	 * @see `geodir_custom_fields`
537
+	 */
538
+	return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
539 539
 }
540 540
 
541 541
 
@@ -548,140 +548,140 @@  discard block
 block discarded – undo
548 548
  */
549 549
 function geodir_custom_fields($post_type=''){
550 550
     
551
-    $custom_fields = array(
552
-        'text' => array(
553
-            'field_type'  =>  'text',
554
-            'class' =>  'gd-text',
555
-            'icon'  =>  'fa fa-minus',
556
-            'name'  =>  __('Text', 'geodirectory'),
557
-            'description' =>  __('Add any sort of text field, text or numbers', 'geodirectory')
558
-        ),
559
-        'datepicker' => array(
560
-            'field_type'  =>  'datepicker',
561
-            'class' =>  'gd-datepicker',
562
-            'icon'  =>  'fa fa-calendar',
563
-            'name'  =>  __('Date', 'geodirectory'),
564
-            'description' =>  __('Adds a date picker.', 'geodirectory')
565
-        ),
566
-        'textarea' => array(
567
-            'field_type'  =>  'textarea',
568
-            'class' =>  'gd-textarea',
569
-            'icon'  =>  'fa fa-bars',
570
-            'name'  =>  __('Textarea', 'geodirectory'),
571
-            'description' =>  __('Adds a textarea', 'geodirectory')
572
-        ),
573
-        'time' => array(
574
-            'field_type'  =>  'time',
575
-            'class' =>  'gd-time',
576
-            'icon' =>  'fa fa-clock-o',
577
-            'name'  =>  __('Time', 'geodirectory'),
578
-            'description' =>  __('Adds a time picker', 'geodirectory')
579
-        ),
580
-        'checkbox' => array(
581
-            'field_type'  =>  'checkbox',
582
-            'class' =>  'gd-checkbox',
583
-            'icon' =>  'fa fa-check-square-o',
584
-            'name'  =>  __('Checkbox', 'geodirectory'),
585
-            'description' =>  __('Adds a checkbox', 'geodirectory')
586
-        ),
587
-        'phone' => array(
588
-            'field_type'  =>  'phone',
589
-            'class' =>  'gd-phone',
590
-            'icon' =>  'fa fa-phone',
591
-            'name'  =>  __('Phone', 'geodirectory'),
592
-            'description' =>  __('Adds a phone input', 'geodirectory')
593
-        ),
594
-        'radio' => array(
595
-            'field_type'  =>  'radio',
596
-            'class' =>  'gd-radio',
597
-            'icon' =>  'fa fa-dot-circle-o',
598
-            'name'  =>  __('Radio', 'geodirectory'),
599
-            'description' =>  __('Adds a radio input', 'geodirectory')
600
-        ),
601
-        'email' => array(
602
-            'field_type'  =>  'email',
603
-            'class' =>  'gd-email',
604
-            'icon' =>  'fa fa-envelope-o',
605
-            'name'  =>  __('Email', 'geodirectory'),
606
-            'description' =>  __('Adds a email input', 'geodirectory')
607
-        ),
608
-        'select' => array(
609
-            'field_type'  =>  'select',
610
-            'class' =>  'gd-select',
611
-            'icon' =>  'fa fa-caret-square-o-down',
612
-            'name'  =>  __('Select', 'geodirectory'),
613
-            'description' =>  __('Adds a select input', 'geodirectory')
614
-        ),
615
-        'multiselect' => array(
616
-            'field_type'  =>  'multiselect',
617
-            'class' =>  'gd-multiselect',
618
-            'icon' =>  'fa fa-caret-square-o-down',
619
-            'name'  =>  __('Multi Select', 'geodirectory'),
620
-            'description' =>  __('Adds a multiselect input', 'geodirectory')
621
-        ),
622
-        'url' => array(
623
-            'field_type'  =>  'url',
624
-            'class' =>  'gd-url',
625
-            'icon' =>  'fa fa-link',
626
-            'name'  =>  __('URL', 'geodirectory'),
627
-            'description' =>  __('Adds a url input', 'geodirectory')
628
-        ),
629
-        'html' => array(
630
-            'field_type'  =>  'html',
631
-            'class' =>  'gd-html',
632
-            'icon' =>  'fa fa-code',
633
-            'name'  =>  __('HTML', 'geodirectory'),
634
-            'description' =>  __('Adds a html input textarea', 'geodirectory')
635
-        ),
636
-        'file' => array(
637
-            'field_type'  =>  'file',
638
-            'class' =>  'gd-file',
639
-            'icon' =>  'fa fa-file',
640
-            'name'  =>  __('File Upload', 'geodirectory'),
641
-            'description' =>  __('Adds a file input', 'geodirectory')
642
-        )
643
-    );
644
-
645
-    /**
646
-     * Filter the custom fields array to be able to add or remove items.
647
-     * 
648
-     * @since 1.6.6
649
-     *
650
-     * @param array $custom_fields {
651
-     *     The custom fields array to be filtered.
652
-     *
653
-     *     @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file.
654
-     *     @type string $class The class for the field in backend.
655
-     *     @type string $icon Can be font-awesome class name or icon image url.
656
-     *     @type string $name The name of the field.
657
-     *     @type string $description A short description about the field.
658
-     *     @type array $defaults {
659
-     *                    Optional. Used to set the default value of the field.
660
-     *
661
-     *                    @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE
662
-     *                    @type int decimal_point limit if using FLOAT data_type
663
-     *                    @type string admin_title The admin title for the field.
664
-     *                    @type string site_title This will be the title for the field on the frontend.
665
-     *                    @type string admin_desc This will be shown below the field on the add listing form.
666
-     *                    @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.
667
-     *                    @type bool is_active If false the field will not be displayed anywhere.
668
-     *                    @type bool for_admin_use If true then only site admin can see and edit this field.
669
-     *                    @type string default_value The default value for the input on the add listing page.
670
-     *                    @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble]
671
-     *                    @type bool is_required If true the field will be required on the add listing page.
672
-     *                    @type string option_values The option values for select and multiselect only
673
-     *                    @type string validation_pattern HTML5 validation pattern (text input only by default).
674
-     *                    @type string validation_msg HTML5 validation message (text input only by default).
675
-     *                    @type string required_msg Required warning message.
676
-     *                    @type string field_icon Icon url or font awesome class.
677
-     *                    @type string css_class Field custom css class for field custom style.
678
-     *                    @type bool cat_sort If true the field will appear in the category sort options, if false the field will be hidden, leave blank to show option.
679
-     *                    @type bool cat_sort If true the field will appear in the advanced search sort options, if false the field will be hidden, leave blank to show option. (advanced search addon required)
680
-     *     }
681
-     * }
682
-     * @param string $post_type The post type requested.
683
-     */
684
-    return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
551
+	$custom_fields = array(
552
+		'text' => array(
553
+			'field_type'  =>  'text',
554
+			'class' =>  'gd-text',
555
+			'icon'  =>  'fa fa-minus',
556
+			'name'  =>  __('Text', 'geodirectory'),
557
+			'description' =>  __('Add any sort of text field, text or numbers', 'geodirectory')
558
+		),
559
+		'datepicker' => array(
560
+			'field_type'  =>  'datepicker',
561
+			'class' =>  'gd-datepicker',
562
+			'icon'  =>  'fa fa-calendar',
563
+			'name'  =>  __('Date', 'geodirectory'),
564
+			'description' =>  __('Adds a date picker.', 'geodirectory')
565
+		),
566
+		'textarea' => array(
567
+			'field_type'  =>  'textarea',
568
+			'class' =>  'gd-textarea',
569
+			'icon'  =>  'fa fa-bars',
570
+			'name'  =>  __('Textarea', 'geodirectory'),
571
+			'description' =>  __('Adds a textarea', 'geodirectory')
572
+		),
573
+		'time' => array(
574
+			'field_type'  =>  'time',
575
+			'class' =>  'gd-time',
576
+			'icon' =>  'fa fa-clock-o',
577
+			'name'  =>  __('Time', 'geodirectory'),
578
+			'description' =>  __('Adds a time picker', 'geodirectory')
579
+		),
580
+		'checkbox' => array(
581
+			'field_type'  =>  'checkbox',
582
+			'class' =>  'gd-checkbox',
583
+			'icon' =>  'fa fa-check-square-o',
584
+			'name'  =>  __('Checkbox', 'geodirectory'),
585
+			'description' =>  __('Adds a checkbox', 'geodirectory')
586
+		),
587
+		'phone' => array(
588
+			'field_type'  =>  'phone',
589
+			'class' =>  'gd-phone',
590
+			'icon' =>  'fa fa-phone',
591
+			'name'  =>  __('Phone', 'geodirectory'),
592
+			'description' =>  __('Adds a phone input', 'geodirectory')
593
+		),
594
+		'radio' => array(
595
+			'field_type'  =>  'radio',
596
+			'class' =>  'gd-radio',
597
+			'icon' =>  'fa fa-dot-circle-o',
598
+			'name'  =>  __('Radio', 'geodirectory'),
599
+			'description' =>  __('Adds a radio input', 'geodirectory')
600
+		),
601
+		'email' => array(
602
+			'field_type'  =>  'email',
603
+			'class' =>  'gd-email',
604
+			'icon' =>  'fa fa-envelope-o',
605
+			'name'  =>  __('Email', 'geodirectory'),
606
+			'description' =>  __('Adds a email input', 'geodirectory')
607
+		),
608
+		'select' => array(
609
+			'field_type'  =>  'select',
610
+			'class' =>  'gd-select',
611
+			'icon' =>  'fa fa-caret-square-o-down',
612
+			'name'  =>  __('Select', 'geodirectory'),
613
+			'description' =>  __('Adds a select input', 'geodirectory')
614
+		),
615
+		'multiselect' => array(
616
+			'field_type'  =>  'multiselect',
617
+			'class' =>  'gd-multiselect',
618
+			'icon' =>  'fa fa-caret-square-o-down',
619
+			'name'  =>  __('Multi Select', 'geodirectory'),
620
+			'description' =>  __('Adds a multiselect input', 'geodirectory')
621
+		),
622
+		'url' => array(
623
+			'field_type'  =>  'url',
624
+			'class' =>  'gd-url',
625
+			'icon' =>  'fa fa-link',
626
+			'name'  =>  __('URL', 'geodirectory'),
627
+			'description' =>  __('Adds a url input', 'geodirectory')
628
+		),
629
+		'html' => array(
630
+			'field_type'  =>  'html',
631
+			'class' =>  'gd-html',
632
+			'icon' =>  'fa fa-code',
633
+			'name'  =>  __('HTML', 'geodirectory'),
634
+			'description' =>  __('Adds a html input textarea', 'geodirectory')
635
+		),
636
+		'file' => array(
637
+			'field_type'  =>  'file',
638
+			'class' =>  'gd-file',
639
+			'icon' =>  'fa fa-file',
640
+			'name'  =>  __('File Upload', 'geodirectory'),
641
+			'description' =>  __('Adds a file input', 'geodirectory')
642
+		)
643
+	);
644
+
645
+	/**
646
+	 * Filter the custom fields array to be able to add or remove items.
647
+	 * 
648
+	 * @since 1.6.6
649
+	 *
650
+	 * @param array $custom_fields {
651
+	 *     The custom fields array to be filtered.
652
+	 *
653
+	 *     @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file.
654
+	 *     @type string $class The class for the field in backend.
655
+	 *     @type string $icon Can be font-awesome class name or icon image url.
656
+	 *     @type string $name The name of the field.
657
+	 *     @type string $description A short description about the field.
658
+	 *     @type array $defaults {
659
+	 *                    Optional. Used to set the default value of the field.
660
+	 *
661
+	 *                    @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE
662
+	 *                    @type int decimal_point limit if using FLOAT data_type
663
+	 *                    @type string admin_title The admin title for the field.
664
+	 *                    @type string site_title This will be the title for the field on the frontend.
665
+	 *                    @type string admin_desc This will be shown below the field on the add listing form.
666
+	 *                    @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.
667
+	 *                    @type bool is_active If false the field will not be displayed anywhere.
668
+	 *                    @type bool for_admin_use If true then only site admin can see and edit this field.
669
+	 *                    @type string default_value The default value for the input on the add listing page.
670
+	 *                    @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble]
671
+	 *                    @type bool is_required If true the field will be required on the add listing page.
672
+	 *                    @type string option_values The option values for select and multiselect only
673
+	 *                    @type string validation_pattern HTML5 validation pattern (text input only by default).
674
+	 *                    @type string validation_msg HTML5 validation message (text input only by default).
675
+	 *                    @type string required_msg Required warning message.
676
+	 *                    @type string field_icon Icon url or font awesome class.
677
+	 *                    @type string css_class Field custom css class for field custom style.
678
+	 *                    @type bool cat_sort If true the field will appear in the category sort options, if false the field will be hidden, leave blank to show option.
679
+	 *                    @type bool cat_sort If true the field will appear in the advanced search sort options, if false the field will be hidden, leave blank to show option. (advanced search addon required)
680
+	 *     }
681
+	 * }
682
+	 * @param string $post_type The post type requested.
683
+	 */
684
+	return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
685 685
 }
686 686
 
687 687
 /**
@@ -694,19 +694,19 @@  discard block
 block discarded – undo
694 694
  */
695 695
 function geodir_custom_available_fields($type='')
696 696
 {
697
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
698
-    ?>
697
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
698
+	?>
699 699
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
700 700
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" />
701 701
 
702 702
         <?php
703
-        if($type=='predefined'){
704
-            $cfs = geodir_custom_fields_predefined($listing_type);
705
-        }elseif($type=='custom'){
706
-            $cfs = geodir_custom_fields_custom($listing_type);
707
-        }else{
708
-            $cfs = geodir_custom_fields($listing_type);
709
-            ?>
703
+		if($type=='predefined'){
704
+			$cfs = geodir_custom_fields_predefined($listing_type);
705
+		}elseif($type=='custom'){
706
+			$cfs = geodir_custom_fields_custom($listing_type);
707
+		}else{
708
+			$cfs = geodir_custom_fields($listing_type);
709
+			?>
710 710
             <ul class="full gd-cf-tooltip-wrap">
711 711
                 <li>
712 712
                     <div class="gdcf-tooltip">
@@ -727,18 +727,18 @@  discard block
 block discarded – undo
727 727
             </ul>
728 728
 
729 729
             <?php
730
-        }
730
+		}
731 731
 
732
-    if(!empty($cfs)) {
733
-        echo '<ul>';
734
-        foreach ( $cfs as $id => $cf ) {
735
-            ?>
732
+	if(!empty($cfs)) {
733
+		echo '<ul>';
734
+		foreach ( $cfs as $id => $cf ) {
735
+			?>
736 736
 
737 737
             <li class="gd-cf-tooltip-wrap">
738 738
                 <?php
739
-                if ( isset( $cf['description'] ) && $cf['description'] ) {
740
-                    echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>';
741
-                } ?>
739
+				if ( isset( $cf['description'] ) && $cf['description'] ) {
740
+					echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>';
741
+				} ?>
742 742
 
743 743
                 <a id="gd-<?php echo $id; ?>"
744 744
                    data-field-custom-type="<?php echo $type; ?>"
@@ -748,21 +748,21 @@  discard block
 block discarded – undo
748 748
                    href="javascript:void(0);">
749 749
 
750 750
                     <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], 'fa fa-' ) !== false ) {
751
-                        echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>';
752
-                    } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
753
-                        echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>';
754
-                    } else {
755
-                        echo '<i class="fa fa-cog" aria-hidden="true"></i>';
756
-                    } ?>
751
+						echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>';
752
+					} elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
753
+						echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>';
754
+					} else {
755
+						echo '<i class="fa fa-cog" aria-hidden="true"></i>';
756
+					} ?>
757 757
                     <?php echo $cf['name']; ?>
758 758
                 </a>
759 759
             </li>
760 760
             <?php
761
-        }
762
-    }else{
763
-        _e('There are no custom fields here yet.', 'geodirectory');
764
-    }
765
-        ?>
761
+		}
762
+	}else{
763
+		_e('There are no custom fields here yet.', 'geodirectory');
764
+	}
765
+		?>
766 766
 
767 767
 
768 768
     </ul>
@@ -781,26 +781,26 @@  discard block
 block discarded – undo
781 781
  */
782 782
 function geodir_custom_selected_fields()
783 783
 {
784
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
785
-    ?>
784
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
785
+	?>
786 786
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
787 787
     <ul class="core">
788 788
     <?php 
789
-        global $wpdb;
790
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
791
-
792
-        if (!empty($fields)) {
793
-            foreach ($fields as $field) {
794
-                //$result_str = $field->id;
795
-                $result_str = $field;
796
-                $field_type = $field->field_type;
797
-                $field_type_key = $field->field_type_key;
798
-                $field_ins_upd = 'display';
799
-
800
-                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key);
801
-            }
802
-        }
803
-        ?></ul>
789
+		global $wpdb;
790
+		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
791
+
792
+		if (!empty($fields)) {
793
+			foreach ($fields as $field) {
794
+				//$result_str = $field->id;
795
+				$result_str = $field;
796
+				$field_type = $field->field_type;
797
+				$field_type_key = $field->field_type_key;
798
+				$field_ins_upd = 'display';
799
+
800
+				geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key);
801
+			}
802
+		}
803
+		?></ul>
804 804
 <?php
805 805
 
806 806
 }
@@ -819,16 +819,16 @@  discard block
 block discarded – undo
819 819
 function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type)
820 820
 {
821 821
 
822
-    switch ($sub_tab) {
823
-        case 'custom_fields':
824
-            $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
825
-            break;
822
+	switch ($sub_tab) {
823
+		case 'custom_fields':
824
+			$heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
825
+			break;
826 826
 
827
-        case 'sorting_options':
828
-            $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
829
-            break;
830
-    }
831
-    return $heading;
827
+		case 'sorting_options':
828
+			$heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
829
+			break;
830
+	}
831
+	return $heading;
832 832
 }
833 833
 
834 834
 
@@ -846,16 +846,16 @@  discard block
 block discarded – undo
846 846
 function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type)
847 847
 {
848 848
 
849
-    switch ($sub_tab) {
850
-        case 'custom_fields':
851
-            $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
852
-            break;
849
+	switch ($sub_tab) {
850
+		case 'custom_fields':
851
+			$heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
852
+			break;
853 853
 
854
-        case 'sorting_options':
855
-            $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
856
-            break;
857
-    }
858
-    return $heading;
854
+		case 'sorting_options':
855
+			$heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
856
+			break;
857
+	}
858
+	return $heading;
859 859
 }
860 860
 
861 861
 
@@ -873,16 +873,16 @@  discard block
 block discarded – undo
873 873
 function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type)
874 874
 {
875 875
 
876
-    switch ($sub_tab) {
877
-        case 'custom_fields':
878
-            $note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
879
-            break;
876
+	switch ($sub_tab) {
877
+		case 'custom_fields':
878
+			$note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
879
+			break;
880 880
 
881
-        case 'sorting_options':
882
-            $note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
883
-            break;
884
-    }
885
-    return $note;
881
+		case 'sorting_options':
882
+			$note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
883
+			break;
884
+	}
885
+	return $note;
886 886
 }
887 887
 
888 888
 
@@ -900,16 +900,16 @@  discard block
 block discarded – undo
900 900
 function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type)
901 901
 {
902 902
 
903
-    switch ($sub_tab) {
904
-        case 'custom_fields':
905
-            $heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
906
-            break;
903
+	switch ($sub_tab) {
904
+		case 'custom_fields':
905
+			$heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
906
+			break;
907 907
 
908
-        case 'sorting_options':
909
-            $heading = sprintf(__('List of fields that will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
910
-            break;
911
-    }
912
-    return $heading;
908
+		case 'sorting_options':
909
+			$heading = sprintf(__('List of fields that will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
910
+			break;
911
+	}
912
+	return $heading;
913 913
 }
914 914
 
915 915
 
@@ -927,16 +927,16 @@  discard block
 block discarded – undo
927 927
 function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type)
928 928
 {
929 929
 
930
-    switch ($sub_tab) {
931
-        case 'custom_fields':
932
-            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
933
-            break;
930
+	switch ($sub_tab) {
931
+		case 'custom_fields':
932
+			$note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
933
+			break;
934 934
 
935
-        case 'sorting_options':
936
-            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
937
-            break;
938
-    }
939
-    return $note;
935
+		case 'sorting_options':
936
+			$note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
937
+			break;
938
+	}
939
+	return $note;
940 940
 }
941 941
 
942 942
 
@@ -952,16 +952,16 @@  discard block
 block discarded – undo
952 952
  */
953 953
 function geodir_remove_unnecessary_fields()
954 954
 {
955
-    global $wpdb, $plugin_prefix;
955
+	global $wpdb, $plugin_prefix;
956 956
 
957
-    if (!get_option('geodir_remove_unnecessary_fields')) {
957
+	if (!get_option('geodir_remove_unnecessary_fields')) {
958 958
 
959
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
960
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
959
+		if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
960
+			$wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
961 961
 
962
-        update_option('geodir_remove_unnecessary_fields', '1');
962
+		update_option('geodir_remove_unnecessary_fields', '1');
963 963
 
964
-    }
964
+	}
965 965
 
966 966
 }
967 967
 
@@ -979,28 +979,28 @@  discard block
 block discarded – undo
979 979
  */
980 980
 function geodir_admin_ajax_handler()
981 981
 {
982
-    if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
983
-        $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
984
-        $diagnose_this = "";
985
-        switch ($geodir_admin_ajax_action) {
986
-            case 'diagnosis' :
987
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
988
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
989
-                    call_user_func('geodir_diagnose_' . $diagnose_this);
990
-
991
-                }
992
-                exit();
993
-                break;
994
-
995
-            case 'diagnosis-fix' :
996
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
997
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
998
-                call_user_func('geodir_diagnose_' . $diagnose_this);
999
-                exit();
1000
-                break;
1001
-        }
1002
-    }
1003
-    exit();
982
+	if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
983
+		$geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
984
+		$diagnose_this = "";
985
+		switch ($geodir_admin_ajax_action) {
986
+			case 'diagnosis' :
987
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
988
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
989
+					call_user_func('geodir_diagnose_' . $diagnose_this);
990
+
991
+				}
992
+				exit();
993
+				break;
994
+
995
+			case 'diagnosis-fix' :
996
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
997
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
998
+				call_user_func('geodir_diagnose_' . $diagnose_this);
999
+				exit();
1000
+				break;
1001
+		}
1002
+	}
1003
+	exit();
1004 1004
 }
1005 1005
 
1006 1006
 
@@ -1018,127 +1018,127 @@  discard block
 block discarded – undo
1018 1018
  */
1019 1019
 function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix)
1020 1020
 {
1021
-    global $wpdb;
1022
-    //$filter_arr['output_str'] .='###'.$table.'###';
1023
-    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
1024
-        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
1025
-        $filter_arr['is_error_during_diagnose'] = true;
1026
-
1027
-    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1028
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
1029
-        $filter_arr['is_error_during_diagnose'] = true;
1030
-        $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
1031
-        $filter_arr['is_error_during_diagnose'] = true;
1032
-
1033
-        if ($fix) {
1034
-            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
1035
-            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
1036
-
1037
-            if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
1038
-                //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
1039
-
1040
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
1041
-
1042
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1043
-                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
1044
-                } else {
1045
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1046
-                }
1047
-
1048
-            } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
1049
-
1050
-                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
1051
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
1052
-
1053
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1054
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
1055
-                } else {
1056
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1057
-                }
1058
-
1059
-            } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
1060
-
1061
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
1062
-
1063
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1064
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
1065
-                } else {
1066
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1067
-                }
1068
-
1069
-            }
1070
-
1071
-        }
1072
-
1073
-
1074
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1075
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
1076
-        $filter_arr['is_error_during_diagnose'] = true;
1077
-
1078
-        if ($fix) {
1079
-            if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
1080
-                if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
1081
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
1082
-                } else {
1083
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
1084
-                }
1085
-
1086
-            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
1087
-                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
1088
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1089
-                } else {
1090
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1091
-                }
1092
-                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1093
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1094
-                } else {
1095
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1096
-                }
1097
-            } else {// else rename the original table to _ms_bak
1098
-                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1099
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1100
-                } else {
1101
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1102
-                }
1103
-            }
1104
-        }
1105
-
1106
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1107
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
1108
-        $filter_arr['is_error_during_diagnose'] = true;
1109
-
1110
-        if ($fix) {
1111
-            // if original table exists but new does not, rename
1112
-            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1113
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1114
-            } else {
1115
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1116
-            }
1117
-
1118
-        }
1119
-
1120
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1121
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
1122
-        $filter_arr['is_error_during_diagnose'] = true;
1123
-
1124
-        if ($fix) {
1125
-            // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
1126
-            delete_option('geodirlocation_db_version');
1127
-            delete_option('geodirevents_db_version');
1128
-            delete_option('geodir_reviewrating_db_version');
1129
-            delete_option('gdevents_db_version');
1130
-            delete_option('geodirectory_db_version');
1131
-            delete_option('geodirclaim_db_version');
1132
-            delete_option('geodir_custom_posts_db_version');
1133
-            delete_option('geodir_reviewratings_db_version');
1134
-            delete_option('geodiradvancesearch_db_version');
1135
-            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
1136
-        }
1137
-
1138
-    } else {
1139
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
1140
-    }
1141
-    return $filter_arr;
1021
+	global $wpdb;
1022
+	//$filter_arr['output_str'] .='###'.$table.'###';
1023
+	if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
1024
+		$filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
1025
+		$filter_arr['is_error_during_diagnose'] = true;
1026
+
1027
+	} elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1028
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
1029
+		$filter_arr['is_error_during_diagnose'] = true;
1030
+		$filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
1031
+		$filter_arr['is_error_during_diagnose'] = true;
1032
+
1033
+		if ($fix) {
1034
+			$ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
1035
+			$new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
1036
+
1037
+			if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
1038
+				//$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
1039
+
1040
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
1041
+
1042
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1043
+					$filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
1044
+				} else {
1045
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1046
+				}
1047
+
1048
+			} elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
1049
+
1050
+				$wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
1051
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
1052
+
1053
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1054
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
1055
+				} else {
1056
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1057
+				}
1058
+
1059
+			} elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
1060
+
1061
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
1062
+
1063
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1064
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
1065
+				} else {
1066
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1067
+				}
1068
+
1069
+			}
1070
+
1071
+		}
1072
+
1073
+
1074
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1075
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
1076
+		$filter_arr['is_error_during_diagnose'] = true;
1077
+
1078
+		if ($fix) {
1079
+			if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
1080
+				if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
1081
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
1082
+				} else {
1083
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
1084
+				}
1085
+
1086
+			} elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
1087
+				if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
1088
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1089
+				} else {
1090
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1091
+				}
1092
+				if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1093
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1094
+				} else {
1095
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1096
+				}
1097
+			} else {// else rename the original table to _ms_bak
1098
+				if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1099
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1100
+				} else {
1101
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1102
+				}
1103
+			}
1104
+		}
1105
+
1106
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1107
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
1108
+		$filter_arr['is_error_during_diagnose'] = true;
1109
+
1110
+		if ($fix) {
1111
+			// if original table exists but new does not, rename
1112
+			if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1113
+				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1114
+			} else {
1115
+				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1116
+			}
1117
+
1118
+		}
1119
+
1120
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1121
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
1122
+		$filter_arr['is_error_during_diagnose'] = true;
1123
+
1124
+		if ($fix) {
1125
+			// if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
1126
+			delete_option('geodirlocation_db_version');
1127
+			delete_option('geodirevents_db_version');
1128
+			delete_option('geodir_reviewrating_db_version');
1129
+			delete_option('gdevents_db_version');
1130
+			delete_option('geodirectory_db_version');
1131
+			delete_option('geodirclaim_db_version');
1132
+			delete_option('geodir_custom_posts_db_version');
1133
+			delete_option('geodir_reviewratings_db_version');
1134
+			delete_option('geodiradvancesearch_db_version');
1135
+			$filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
1136
+		}
1137
+
1138
+	} else {
1139
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
1140
+	}
1141
+	return $filter_arr;
1142 1142
 }
1143 1143
 
1144 1144
 
@@ -1152,111 +1152,111 @@  discard block
 block discarded – undo
1152 1152
  */
1153 1153
 function geodir_diagnose_tags_sync()
1154 1154
 {
1155
-    global $wpdb, $plugin_prefix;
1156
-    $fix = isset($_POST['fix']) ? true : false;
1157
-    $step = isset($_POST['step']) ? strip_tags(esc_sql($_POST['step'])) : 0;
1158
-    $step_max_items = geodir_get_diagnose_step_max_items();
1159
-    $offset = (int) $step * $step_max_items;
1160
-    $ptype = isset($_POST['ptype']) ? strip_tags(esc_sql($_POST['ptype'])) : false;
1161
-
1162
-    $total_listings = geodir_total_listings_count();
1163
-    $total_ptype_listings = 0;
1164
-    if ($ptype) {
1165
-        $total_ptype_listings = geodir_total_listings_count($ptype);
1166
-    }
1167
-    $max_step = ceil($total_ptype_listings / $step_max_items) - 1;
1155
+	global $wpdb, $plugin_prefix;
1156
+	$fix = isset($_POST['fix']) ? true : false;
1157
+	$step = isset($_POST['step']) ? strip_tags(esc_sql($_POST['step'])) : 0;
1158
+	$step_max_items = geodir_get_diagnose_step_max_items();
1159
+	$offset = (int) $step * $step_max_items;
1160
+	$ptype = isset($_POST['ptype']) ? strip_tags(esc_sql($_POST['ptype'])) : false;
1161
+
1162
+	$total_listings = geodir_total_listings_count();
1163
+	$total_ptype_listings = 0;
1164
+	if ($ptype) {
1165
+		$total_ptype_listings = geodir_total_listings_count($ptype);
1166
+	}
1167
+	$max_step = ceil($total_ptype_listings / $step_max_items) - 1;
1168 1168
     
1169
-    //if($fix){echo 'true';}else{echo 'false';}
1170
-    $is_error_during_diagnose = false;
1171
-    $output_str = '';
1169
+	//if($fix){echo 'true';}else{echo 'false';}
1170
+	$is_error_during_diagnose = false;
1171
+	$output_str = '';
1172 1172
     
1173
-    if ($ptype && !empty($ptype) && $total_listings > $step_max_items) {
1174
-        $stepped_process = true;
1175
-    } else {
1176
-        $stepped_process = false;
1177
-    }
1178
-
1179
-    if ($stepped_process) {
1180
-        $sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset );
1181
-        $posts = $wpdb->get_results( $sql );
1182
-
1183
-        if (!empty($posts)) {
1184
-
1185
-            foreach ($posts as $p) {
1186
-                $p->post_type = $ptype;
1187
-                $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1188
-                if (empty($raw_tags)) {
1189
-                    $post_tags = '';
1190
-                } else {
1191
-                    $post_tags = implode(",", $raw_tags);
1192
-                }
1193
-                $tablename = $plugin_prefix . $p->post_type . '_detail';
1194
-                $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1195
-
1196
-            }
1197
-            if ($step >= $max_step) {
1198
-                $output_str = "done";    
1199
-            } else {
1200
-                $output_str = $step + 1;
1201
-            }
1202
-        }
1203
-
1204
-    } else {
1205
-        $all_postypes = geodir_get_posttypes();
1206
-
1207
-        if (!empty($all_postypes)) {
1208
-            foreach ($all_postypes as $key) {
1209
-                // update each GD CPT
1210
-                $posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail");
1211
-
1212
-                if (!empty($posts)) {
1213
-
1214
-                    foreach ($posts as $p) {
1215
-                        $p->post_type = $key;
1216
-                        $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1217
-                        if (empty($raw_tags)) {
1218
-                            $post_tags = '';
1219
-                        } else {
1220
-                            $post_tags = implode(",", $raw_tags);
1221
-                        }
1222
-                        $tablename = $plugin_prefix . $p->post_type . '_detail';
1223
-                        $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1224
-
1225
-                    }
1226
-                    $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1227
-                }
1228
-
1229
-            }
1230
-
1231
-        }
1232
-    }
1233
-
1234
-
1235
-    if ($is_error_during_diagnose) {
1236
-        $info_div_class = "geodir_problem_info";
1237
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1238
-    } else {
1239
-        $info_div_class = "geodir_noproblem_info";
1240
-        $fix_button_txt = '';
1241
-    }
1242
-
1243
-    if ($stepped_process) {
1244
-        $percent = ($step/$max_step) * 100;
1245
-        if ($output_str == 'done') {
1246
-            echo $output_str;
1247
-        } else {
1248
-            $output = array(
1249
-                'step' => $output_str,
1250
-                'percent' => $percent
1251
-            );
1252
-            echo json_encode($output);
1253
-        }
1254
-    } else {
1255
-        echo "<ul class='$info_div_class'>";
1256
-        echo $output_str;
1257
-        echo $fix_button_txt;
1258
-        echo "</ul>";
1259
-    }
1173
+	if ($ptype && !empty($ptype) && $total_listings > $step_max_items) {
1174
+		$stepped_process = true;
1175
+	} else {
1176
+		$stepped_process = false;
1177
+	}
1178
+
1179
+	if ($stepped_process) {
1180
+		$sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset );
1181
+		$posts = $wpdb->get_results( $sql );
1182
+
1183
+		if (!empty($posts)) {
1184
+
1185
+			foreach ($posts as $p) {
1186
+				$p->post_type = $ptype;
1187
+				$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1188
+				if (empty($raw_tags)) {
1189
+					$post_tags = '';
1190
+				} else {
1191
+					$post_tags = implode(",", $raw_tags);
1192
+				}
1193
+				$tablename = $plugin_prefix . $p->post_type . '_detail';
1194
+				$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1195
+
1196
+			}
1197
+			if ($step >= $max_step) {
1198
+				$output_str = "done";    
1199
+			} else {
1200
+				$output_str = $step + 1;
1201
+			}
1202
+		}
1203
+
1204
+	} else {
1205
+		$all_postypes = geodir_get_posttypes();
1206
+
1207
+		if (!empty($all_postypes)) {
1208
+			foreach ($all_postypes as $key) {
1209
+				// update each GD CPT
1210
+				$posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail");
1211
+
1212
+				if (!empty($posts)) {
1213
+
1214
+					foreach ($posts as $p) {
1215
+						$p->post_type = $key;
1216
+						$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1217
+						if (empty($raw_tags)) {
1218
+							$post_tags = '';
1219
+						} else {
1220
+							$post_tags = implode(",", $raw_tags);
1221
+						}
1222
+						$tablename = $plugin_prefix . $p->post_type . '_detail';
1223
+						$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1224
+
1225
+					}
1226
+					$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1227
+				}
1228
+
1229
+			}
1230
+
1231
+		}
1232
+	}
1233
+
1234
+
1235
+	if ($is_error_during_diagnose) {
1236
+		$info_div_class = "geodir_problem_info";
1237
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1238
+	} else {
1239
+		$info_div_class = "geodir_noproblem_info";
1240
+		$fix_button_txt = '';
1241
+	}
1242
+
1243
+	if ($stepped_process) {
1244
+		$percent = ($step/$max_step) * 100;
1245
+		if ($output_str == 'done') {
1246
+			echo $output_str;
1247
+		} else {
1248
+			$output = array(
1249
+				'step' => $output_str,
1250
+				'percent' => $percent
1251
+			);
1252
+			echo json_encode($output);
1253
+		}
1254
+	} else {
1255
+		echo "<ul class='$info_div_class'>";
1256
+		echo $output_str;
1257
+		echo $fix_button_txt;
1258
+		echo "</ul>";
1259
+	}
1260 1260
 }
1261 1261
 
1262 1262
 /**
@@ -1271,75 +1271,75 @@  discard block
 block discarded – undo
1271 1271
  */
1272 1272
 function geodir_diagnose_cats_sync()
1273 1273
 {
1274
-    global $wpdb, $plugin_prefix;
1275
-    $fix = isset($_POST['fix']) ? true : false;
1274
+	global $wpdb, $plugin_prefix;
1275
+	$fix = isset($_POST['fix']) ? true : false;
1276 1276
 
1277
-    //if($fix){echo 'true';}else{echo 'false';}
1278
-    $is_error_during_diagnose = false;
1279
-    $output_str = '';
1277
+	//if($fix){echo 'true';}else{echo 'false';}
1278
+	$is_error_during_diagnose = false;
1279
+	$output_str = '';
1280 1280
 
1281 1281
 
1282
-    $all_postypes = geodir_get_posttypes();
1282
+	$all_postypes = geodir_get_posttypes();
1283 1283
 
1284
-    if (!empty($all_postypes)) {
1285
-        foreach ($all_postypes as $key) {
1286
-            // update each GD CTP
1287
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
1284
+	if (!empty($all_postypes)) {
1285
+		foreach ($all_postypes as $key) {
1286
+			// update each GD CTP
1287
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
1288 1288
 
1289
-            if (!empty($posts)) {
1289
+			if (!empty($posts)) {
1290 1290
 
1291
-                foreach ($posts as $p) {
1292
-                    $p->post_type = $key;
1293
-                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
1291
+				foreach ($posts as $p) {
1292
+					$p->post_type = $key;
1293
+					$raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
1294 1294
 
1295
-                    if (empty($raw_cats)) {
1296
-                        $post_categories = get_post_meta($p->post_id, 'post_categories', true);
1295
+					if (empty($raw_cats)) {
1296
+						$post_categories = get_post_meta($p->post_id, 'post_categories', true);
1297 1297
 
1298
-                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1299
-                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1300
-                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1301
-                                if (is_numeric($cat_part)) {
1302
-                                    $raw_cats[] = (int)$cat_part;
1303
-                                }
1304
-                            }
1298
+						if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1299
+							$post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1300
+							foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1301
+								if (is_numeric($cat_part)) {
1302
+									$raw_cats[] = (int)$cat_part;
1303
+								}
1304
+							}
1305 1305
 
1306
-                        }
1306
+						}
1307 1307
 
1308
-                        if (!empty($raw_cats)) {
1309
-                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1308
+						if (!empty($raw_cats)) {
1309
+							$term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1310 1310
 
1311
-                        }
1311
+						}
1312 1312
 
1313
-                    }
1313
+					}
1314 1314
 
1315 1315
 
1316
-                    if (empty($raw_cats)) {
1317
-                        $post_cats = '';
1318
-                    } else {
1319
-                        $post_cats = ',' . implode(",", $raw_cats) . ',';
1320
-                    }
1321
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1322
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1323
-                }
1316
+					if (empty($raw_cats)) {
1317
+						$post_cats = '';
1318
+					} else {
1319
+						$post_cats = ',' . implode(",", $raw_cats) . ',';
1320
+					}
1321
+					$tablename = $plugin_prefix . $p->post_type . '_detail';
1322
+					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1323
+				}
1324 1324
 
1325
-            }
1326
-            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1325
+			}
1326
+			$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1327 1327
 
1328
-        }
1328
+		}
1329 1329
 
1330
-    }
1330
+	}
1331 1331
 
1332
-    if ($is_error_during_diagnose) {
1333
-        $info_div_class = "geodir_problem_info";
1334
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1335
-    } else {
1336
-        $info_div_class = "geodir_noproblem_info";
1337
-        $fix_button_txt = '';
1338
-    }
1339
-    echo "<ul class='$info_div_class'>";
1340
-    echo $output_str;
1341
-    echo $fix_button_txt;
1342
-    echo "</ul>";
1332
+	if ($is_error_during_diagnose) {
1333
+		$info_div_class = "geodir_problem_info";
1334
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1335
+	} else {
1336
+		$info_div_class = "geodir_noproblem_info";
1337
+		$fix_button_txt = '';
1338
+	}
1339
+	echo "<ul class='$info_div_class'>";
1340
+	echo $output_str;
1341
+	echo $fix_button_txt;
1342
+	echo "</ul>";
1343 1343
 
1344 1344
 }
1345 1345
 
@@ -1353,61 +1353,61 @@  discard block
 block discarded – undo
1353 1353
  */
1354 1354
 function geodir_diagnose_version_clear()
1355 1355
 {
1356
-    global $wpdb, $plugin_prefix;
1357
-    $fix = isset($_POST['fix']) ? true : false;
1358
-
1359
-    //if($fix){echo 'true';}else{echo 'false';}
1360
-    $is_error_during_diagnose = false;
1361
-    $output_str = '';
1362
-
1363
-
1364
-    $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1365
-        'Payment Manager' => 'geodir_payments_db_version',
1366
-        'GeoDirectory Framework' => 'gdf_db_version',
1367
-        'Advanced Search' => 'geodiradvancesearch_db_version',
1368
-        'Review Rating Manager' => 'geodir_reviewratings_db_version',
1369
-        'Claim Manager' => 'geodirclaim_db_version',
1370
-        'CPT Manager' => 'geodir_custom_posts_db_version',
1371
-        'Location Manager' => 'geodirlocation_db_version',
1372
-        'Payment Manager' => 'geodir_payments_db_version',
1373
-        'Events Manager' => 'geodirevents_db_version',
1374
-    );
1375
-
1376
-    /**
1377
-     * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1378
-     *
1379
-     * @since 1.0.0
1380
-     * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1381
-     */
1382
-    $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1383
-
1384
-    if (!empty($ver_arr)) {
1385
-        foreach ($ver_arr as $key => $val) {
1386
-            if (delete_option($val)) {
1387
-                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1388
-            } else {
1389
-                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1390
-            }
1391
-
1392
-        }
1393
-
1394
-        if ($output_str) {
1395
-            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1396
-        }
1397
-
1398
-    }
1399
-
1400
-    if ($is_error_during_diagnose) {
1401
-        $info_div_class = "geodir_problem_info";
1402
-        $fix_button_txt = "";
1403
-    } else {
1404
-        $info_div_class = "geodir_noproblem_info";
1405
-        $fix_button_txt = '';
1406
-    }
1407
-    echo "<ul class='$info_div_class'>";
1408
-    echo $output_str;
1409
-    echo $fix_button_txt;
1410
-    echo "</ul>";
1356
+	global $wpdb, $plugin_prefix;
1357
+	$fix = isset($_POST['fix']) ? true : false;
1358
+
1359
+	//if($fix){echo 'true';}else{echo 'false';}
1360
+	$is_error_during_diagnose = false;
1361
+	$output_str = '';
1362
+
1363
+
1364
+	$gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1365
+		'Payment Manager' => 'geodir_payments_db_version',
1366
+		'GeoDirectory Framework' => 'gdf_db_version',
1367
+		'Advanced Search' => 'geodiradvancesearch_db_version',
1368
+		'Review Rating Manager' => 'geodir_reviewratings_db_version',
1369
+		'Claim Manager' => 'geodirclaim_db_version',
1370
+		'CPT Manager' => 'geodir_custom_posts_db_version',
1371
+		'Location Manager' => 'geodirlocation_db_version',
1372
+		'Payment Manager' => 'geodir_payments_db_version',
1373
+		'Events Manager' => 'geodirevents_db_version',
1374
+	);
1375
+
1376
+	/**
1377
+	 * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1378
+	 *
1379
+	 * @since 1.0.0
1380
+	 * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1381
+	 */
1382
+	$ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1383
+
1384
+	if (!empty($ver_arr)) {
1385
+		foreach ($ver_arr as $key => $val) {
1386
+			if (delete_option($val)) {
1387
+				$output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1388
+			} else {
1389
+				$output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1390
+			}
1391
+
1392
+		}
1393
+
1394
+		if ($output_str) {
1395
+			$output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1396
+		}
1397
+
1398
+	}
1399
+
1400
+	if ($is_error_during_diagnose) {
1401
+		$info_div_class = "geodir_problem_info";
1402
+		$fix_button_txt = "";
1403
+	} else {
1404
+		$info_div_class = "geodir_noproblem_info";
1405
+		$fix_button_txt = '';
1406
+	}
1407
+	echo "<ul class='$info_div_class'>";
1408
+	echo $output_str;
1409
+	echo $fix_button_txt;
1410
+	echo "</ul>";
1411 1411
 
1412 1412
 }
1413 1413
 
@@ -1421,59 +1421,59 @@  discard block
 block discarded – undo
1421 1421
  */
1422 1422
 function geodir_diagnose_ratings()
1423 1423
 {
1424
-    global $wpdb;
1425
-    $fix = isset($_POST['fix']) ? true : false;
1426
-
1427
-    //if($fix){echo 'true';}else{echo 'false';}
1428
-    $is_error_during_diagnose = false;
1429
-    $output_str = '';
1430
-
1431
-    // check review locations
1432
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
1433
-        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1434
-        $is_error_during_diagnose = true;
1435
-
1436
-        if ($fix) {
1437
-            if (geodir_fix_review_location()) {
1438
-                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1439
-            } else {
1440
-                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1441
-            }
1442
-        }
1443
-
1444
-    } else {
1445
-        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1446
-    }
1447
-
1448
-    // check review content
1449
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1450
-        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1451
-        $is_error_during_diagnose = true;
1452
-
1453
-        if ($fix) {
1454
-            if (geodir_fix_review_content()) {
1455
-                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1456
-            } else {
1457
-                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1458
-            }
1459
-        }
1460
-
1461
-    } else {
1462
-        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1463
-    }
1464
-
1465
-
1466
-    if ($is_error_during_diagnose) {
1467
-        $info_div_class = "geodir_problem_info";
1468
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1469
-    } else {
1470
-        $info_div_class = "geodir_noproblem_info";
1471
-        $fix_button_txt = '';
1472
-    }
1473
-    echo "<ul class='$info_div_class'>";
1474
-    echo $output_str;
1475
-    echo $fix_button_txt;
1476
-    echo "</ul>";
1424
+	global $wpdb;
1425
+	$fix = isset($_POST['fix']) ? true : false;
1426
+
1427
+	//if($fix){echo 'true';}else{echo 'false';}
1428
+	$is_error_during_diagnose = false;
1429
+	$output_str = '';
1430
+
1431
+	// check review locations
1432
+	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
1433
+		$output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1434
+		$is_error_during_diagnose = true;
1435
+
1436
+		if ($fix) {
1437
+			if (geodir_fix_review_location()) {
1438
+				$output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1439
+			} else {
1440
+				$output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1441
+			}
1442
+		}
1443
+
1444
+	} else {
1445
+		$output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1446
+	}
1447
+
1448
+	// check review content
1449
+	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1450
+		$output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1451
+		$is_error_during_diagnose = true;
1452
+
1453
+		if ($fix) {
1454
+			if (geodir_fix_review_content()) {
1455
+				$output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1456
+			} else {
1457
+				$output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1458
+			}
1459
+		}
1460
+
1461
+	} else {
1462
+		$output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1463
+	}
1464
+
1465
+
1466
+	if ($is_error_during_diagnose) {
1467
+		$info_div_class = "geodir_problem_info";
1468
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1469
+	} else {
1470
+		$info_div_class = "geodir_noproblem_info";
1471
+		$fix_button_txt = '';
1472
+	}
1473
+	echo "<ul class='$info_div_class'>";
1474
+	echo $output_str;
1475
+	echo $fix_button_txt;
1476
+	echo "</ul>";
1477 1477
 
1478 1478
 }
1479 1479
 
@@ -1487,57 +1487,57 @@  discard block
 block discarded – undo
1487 1487
  */
1488 1488
 function geodir_diagnose_multisite_conversion()
1489 1489
 {
1490
-    global $wpdb;
1491
-    $fix = isset($_POST['fix']) ? true : false;
1492
-    //if($fix){echo 'true';}else{echo 'false';}
1493
-    $is_error_during_diagnose = false;
1494
-    $output_str = '';
1495
-
1496
-    $filter_arr = array();
1497
-    $filter_arr['output_str'] = $output_str;
1498
-    $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1499
-    $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1500
-        'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1501
-        'geodir_post_icon' => __('Post icon', 'geodirectory'),
1502
-        'geodir_attachments' => __('Attachments', 'geodirectory'),
1503
-        'geodir_post_review' => __('Reviews', 'geodirectory'),
1504
-        'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1505
-        'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1506
-    );
1507
-
1508
-    // allow other addons to hook in and add their checks
1509
-
1510
-    /**
1511
-     * Filter the array of tables.
1512
-     *
1513
-     * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks.
1514
-     *
1515
-     * @since 1.0.0
1516
-     * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1517
-     */
1518
-    $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1519
-
1520
-    foreach ($table_arr as $table => $table_name) {
1521
-        // Diagnose table
1522
-        $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1523
-    }
1524
-
1525
-
1526
-    $output_str = $filter_arr['output_str'];
1527
-    $is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1528
-
1529
-
1530
-    if ($is_error_during_diagnose) {
1531
-        $info_div_class = "geodir_problem_info";
1532
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1533
-    } else {
1534
-        $info_div_class = "geodir_noproblem_info";
1535
-        $fix_button_txt = '';
1536
-    }
1537
-    echo "<ul class='$info_div_class'>";
1538
-    echo $output_str;
1539
-    echo $fix_button_txt;
1540
-    echo "</ul>";
1490
+	global $wpdb;
1491
+	$fix = isset($_POST['fix']) ? true : false;
1492
+	//if($fix){echo 'true';}else{echo 'false';}
1493
+	$is_error_during_diagnose = false;
1494
+	$output_str = '';
1495
+
1496
+	$filter_arr = array();
1497
+	$filter_arr['output_str'] = $output_str;
1498
+	$filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1499
+	$table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1500
+		'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1501
+		'geodir_post_icon' => __('Post icon', 'geodirectory'),
1502
+		'geodir_attachments' => __('Attachments', 'geodirectory'),
1503
+		'geodir_post_review' => __('Reviews', 'geodirectory'),
1504
+		'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1505
+		'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1506
+	);
1507
+
1508
+	// allow other addons to hook in and add their checks
1509
+
1510
+	/**
1511
+	 * Filter the array of tables.
1512
+	 *
1513
+	 * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks.
1514
+	 *
1515
+	 * @since 1.0.0
1516
+	 * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1517
+	 */
1518
+	$table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1519
+
1520
+	foreach ($table_arr as $table => $table_name) {
1521
+		// Diagnose table
1522
+		$filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1523
+	}
1524
+
1525
+
1526
+	$output_str = $filter_arr['output_str'];
1527
+	$is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1528
+
1529
+
1530
+	if ($is_error_during_diagnose) {
1531
+		$info_div_class = "geodir_problem_info";
1532
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1533
+	} else {
1534
+		$info_div_class = "geodir_noproblem_info";
1535
+		$fix_button_txt = '';
1536
+	}
1537
+	echo "<ul class='$info_div_class'>";
1538
+	echo $output_str;
1539
+	echo $fix_button_txt;
1540
+	echo "</ul>";
1541 1541
 }
1542 1542
 
1543 1543
 /**
@@ -1555,39 +1555,39 @@  discard block
 block discarded – undo
1555 1555
  */
1556 1556
 function geodir_fix_virtual_page($slug, $page_title, $old_id, $option)
1557 1557
 {
1558
-    global $wpdb, $current_user;
1559
-
1560
-    if (!empty($old_id)) {
1561
-        wp_delete_post($old_id, true);
1562
-    }//delete post if already there
1563
-    else {
1564
-        $page_found = $wpdb->get_var(
1565
-            $wpdb->prepare(
1566
-                "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1567
-                array($slug)
1568
-            )
1569
-        );
1570
-        wp_delete_post($page_found, true);
1571
-
1572
-    }
1573
-
1574
-    $page_data = array(
1575
-        'post_status' => 'publish',
1576
-        'post_type' => 'page',
1577
-        'post_author' => $current_user->ID,
1578
-        'post_name' => $slug,
1579
-        'post_title' => $page_title,
1580
-        'post_content' => '',
1581
-        'post_parent' => 0,
1582
-        'comment_status' => 'closed'
1583
-    );
1584
-    $page_id = wp_insert_post($page_data);
1585
-    update_option($option, $page_id);
1586
-    if ($page_id) {
1587
-        return true;
1588
-    } else {
1589
-        return false;
1590
-    }
1558
+	global $wpdb, $current_user;
1559
+
1560
+	if (!empty($old_id)) {
1561
+		wp_delete_post($old_id, true);
1562
+	}//delete post if already there
1563
+	else {
1564
+		$page_found = $wpdb->get_var(
1565
+			$wpdb->prepare(
1566
+				"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1567
+				array($slug)
1568
+			)
1569
+		);
1570
+		wp_delete_post($page_found, true);
1571
+
1572
+	}
1573
+
1574
+	$page_data = array(
1575
+		'post_status' => 'publish',
1576
+		'post_type' => 'page',
1577
+		'post_author' => $current_user->ID,
1578
+		'post_name' => $slug,
1579
+		'post_title' => $page_title,
1580
+		'post_content' => '',
1581
+		'post_parent' => 0,
1582
+		'comment_status' => 'closed'
1583
+	);
1584
+	$page_id = wp_insert_post($page_data);
1585
+	update_option($option, $page_id);
1586
+	if ($page_id) {
1587
+		return true;
1588
+	} else {
1589
+		return false;
1590
+	}
1591 1591
 }
1592 1592
 
1593 1593
 /**
@@ -1599,212 +1599,212 @@  discard block
 block discarded – undo
1599 1599
  */
1600 1600
 function geodir_diagnose_default_pages()
1601 1601
 {
1602
-    global $wpdb;
1603
-    $is_error_during_diagnose = false;
1604
-    $output_str = '';
1605
-    $fix = isset($_POST['fix']) ? true : false;
1606
-
1607
-    //////////////////////////////////
1608
-    /* Diagnose GD Home Page Starts */
1609
-    //////////////////////////////////
1610
-    $option_value = get_option('geodir_home_page');
1611
-    $page = get_post($option_value);
1612
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1613
-
1614
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1615
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1616
-    else {
1617
-        $is_error_during_diagnose = true;
1618
-        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1619
-        if ($fix) {
1620
-            if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1621
-                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1622
-            } else {
1623
-                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1624
-            }
1625
-        }
1626
-    }
1627
-
1628
-    ////////////////////////////////
1629
-    /* Diagnose GD Home Page Ends */
1630
-    ////////////////////////////////
1631
-
1632
-    //////////////////////////////////
1633
-    /* Diagnose Add Listing Page Starts */
1634
-    //////////////////////////////////
1635
-    $option_value = get_option('geodir_add_listing_page');
1636
-    $page = get_post($option_value);
1637
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1638
-
1639
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1640
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1641
-    else {
1642
-        $is_error_during_diagnose = true;
1643
-        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1644
-        if ($fix) {
1645
-            if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1646
-                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1647
-            } else {
1648
-                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1649
-            }
1650
-        }
1651
-    }
1652
-
1653
-    ////////////////////////////////
1654
-    /* Diagnose Add Listing Page Ends */
1655
-    ////////////////////////////////
1656
-
1657
-
1658
-    //////////////////////////////////
1659
-    /* Diagnose Listing Preview Page Starts */
1660
-    //////////////////////////////////
1661
-    $option_value = get_option('geodir_preview_page');
1662
-    $page = get_post($option_value);
1663
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1664
-
1665
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1666
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1667
-    else {
1668
-        $is_error_during_diagnose = true;
1669
-        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1670
-        if ($fix) {
1671
-            if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1672
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1673
-            } else {
1674
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1675
-            }
1676
-        }
1677
-    }
1678
-
1679
-    ////////////////////////////////
1680
-    /* Diagnose Listing Preview Page Ends */
1681
-    ////////////////////////////////
1682
-
1683
-    //////////////////////////////////
1684
-    /* Diagnose Listing Success Page Starts */
1685
-    //////////////////////////////////
1686
-    $option_value = get_option('geodir_success_page');
1687
-    $page = get_post($option_value);
1688
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1689
-
1690
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1691
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1692
-    else {
1693
-        $is_error_during_diagnose = true;
1694
-        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1695
-        if ($fix) {
1696
-            if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1697
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1698
-            } else {
1699
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1700
-            }
1701
-        }
1702
-    }
1703
-
1704
-    ////////////////////////////////
1705
-    /* Diagnose Listing Sucess Page Ends */
1706
-    ////////////////////////////////
1707
-
1708
-    //////////////////////////////////
1709
-    /* Diagnose Info Page Starts */
1710
-    //////////////////////////////////
1711
-    $option_value = get_option('geodir_info_page');
1712
-    $page = get_post($option_value);
1713
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1714
-
1715
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1716
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1717
-    else {
1718
-        $is_error_during_diagnose = true;
1719
-        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1720
-        if ($fix) {
1721
-            if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1722
-                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1723
-            } else {
1724
-                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1725
-            }
1726
-        }
1727
-    }
1728
-
1729
-    ////////////////////////////////
1730
-    /* Diagnose Info Page Ends */
1731
-    ////////////////////////////////
1732
-
1733
-    //////////////////////////////////
1734
-    /* Diagnose Login Page Starts */
1735
-    //////////////////////////////////
1736
-    $option_value = get_option('geodir_login_page');
1737
-    $page = get_post($option_value);
1738
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1739
-
1740
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1741
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1742
-    else {
1743
-        $is_error_during_diagnose = true;
1744
-        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1745
-        if ($fix) {
1746
-            if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1747
-                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1748
-            } else {
1749
-                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1750
-            }
1751
-        }
1752
-    }
1753
-
1754
-    ////////////////////////////////
1755
-    /* Diagnose Info Page Ends */
1756
-    ////////////////////////////////
1757
-
1758
-    //////////////////////////////////
1759
-    /* Diagnose Location Page Starts */
1760
-    //////////////////////////////////
1761
-    $option_value = get_option('geodir_location_page');
1762
-    $page = get_post($option_value);
1763
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1764
-
1765
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1766
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1767
-    else {
1768
-        $is_error_during_diagnose = true;
1769
-        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1770
-        if ($fix) {
1771
-            if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1772
-                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1773
-            } else {
1774
-                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1775
-            }
1776
-        }
1777
-    }
1778
-
1779
-    ////////////////////////////////
1780
-    /* Diagnose Location Page Ends */
1781
-    ////////////////////////////////
1782
-
1783
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1784
-    /**
1785
-     * This action is called at the end of the GD Tools page check function.
1786
-     *
1787
-     * @since 1.5.2
1788
-     */
1789
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1790
-
1791
-    $output_str = $page_chk_arr['output_str'];
1792
-    $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1793
-
1794
-    if ($is_error_during_diagnose) {
1795
-        if ($fix) {
1796
-            flush_rewrite_rules();
1797
-        }
1798
-        $info_div_class = "geodir_problem_info";
1799
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1800
-    } else {
1801
-        $info_div_class = "geodir_noproblem_info";
1802
-        $fix_button_txt = '';
1803
-    }
1804
-    echo "<ul class='$info_div_class'>";
1805
-    echo $output_str;
1806
-    echo $fix_button_txt;
1807
-    echo "</ul>";
1602
+	global $wpdb;
1603
+	$is_error_during_diagnose = false;
1604
+	$output_str = '';
1605
+	$fix = isset($_POST['fix']) ? true : false;
1606
+
1607
+	//////////////////////////////////
1608
+	/* Diagnose GD Home Page Starts */
1609
+	//////////////////////////////////
1610
+	$option_value = get_option('geodir_home_page');
1611
+	$page = get_post($option_value);
1612
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1613
+
1614
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1615
+		$output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1616
+	else {
1617
+		$is_error_during_diagnose = true;
1618
+		$output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1619
+		if ($fix) {
1620
+			if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1621
+				$output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1622
+			} else {
1623
+				$output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1624
+			}
1625
+		}
1626
+	}
1627
+
1628
+	////////////////////////////////
1629
+	/* Diagnose GD Home Page Ends */
1630
+	////////////////////////////////
1631
+
1632
+	//////////////////////////////////
1633
+	/* Diagnose Add Listing Page Starts */
1634
+	//////////////////////////////////
1635
+	$option_value = get_option('geodir_add_listing_page');
1636
+	$page = get_post($option_value);
1637
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1638
+
1639
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1640
+		$output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1641
+	else {
1642
+		$is_error_during_diagnose = true;
1643
+		$output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1644
+		if ($fix) {
1645
+			if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1646
+				$output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1647
+			} else {
1648
+				$output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1649
+			}
1650
+		}
1651
+	}
1652
+
1653
+	////////////////////////////////
1654
+	/* Diagnose Add Listing Page Ends */
1655
+	////////////////////////////////
1656
+
1657
+
1658
+	//////////////////////////////////
1659
+	/* Diagnose Listing Preview Page Starts */
1660
+	//////////////////////////////////
1661
+	$option_value = get_option('geodir_preview_page');
1662
+	$page = get_post($option_value);
1663
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1664
+
1665
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1666
+		$output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1667
+	else {
1668
+		$is_error_during_diagnose = true;
1669
+		$output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1670
+		if ($fix) {
1671
+			if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1672
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1673
+			} else {
1674
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1675
+			}
1676
+		}
1677
+	}
1678
+
1679
+	////////////////////////////////
1680
+	/* Diagnose Listing Preview Page Ends */
1681
+	////////////////////////////////
1682
+
1683
+	//////////////////////////////////
1684
+	/* Diagnose Listing Success Page Starts */
1685
+	//////////////////////////////////
1686
+	$option_value = get_option('geodir_success_page');
1687
+	$page = get_post($option_value);
1688
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1689
+
1690
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1691
+		$output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1692
+	else {
1693
+		$is_error_during_diagnose = true;
1694
+		$output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1695
+		if ($fix) {
1696
+			if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1697
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1698
+			} else {
1699
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1700
+			}
1701
+		}
1702
+	}
1703
+
1704
+	////////////////////////////////
1705
+	/* Diagnose Listing Sucess Page Ends */
1706
+	////////////////////////////////
1707
+
1708
+	//////////////////////////////////
1709
+	/* Diagnose Info Page Starts */
1710
+	//////////////////////////////////
1711
+	$option_value = get_option('geodir_info_page');
1712
+	$page = get_post($option_value);
1713
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1714
+
1715
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1716
+		$output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1717
+	else {
1718
+		$is_error_during_diagnose = true;
1719
+		$output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1720
+		if ($fix) {
1721
+			if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1722
+				$output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1723
+			} else {
1724
+				$output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1725
+			}
1726
+		}
1727
+	}
1728
+
1729
+	////////////////////////////////
1730
+	/* Diagnose Info Page Ends */
1731
+	////////////////////////////////
1732
+
1733
+	//////////////////////////////////
1734
+	/* Diagnose Login Page Starts */
1735
+	//////////////////////////////////
1736
+	$option_value = get_option('geodir_login_page');
1737
+	$page = get_post($option_value);
1738
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1739
+
1740
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1741
+		$output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1742
+	else {
1743
+		$is_error_during_diagnose = true;
1744
+		$output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1745
+		if ($fix) {
1746
+			if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1747
+				$output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1748
+			} else {
1749
+				$output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1750
+			}
1751
+		}
1752
+	}
1753
+
1754
+	////////////////////////////////
1755
+	/* Diagnose Info Page Ends */
1756
+	////////////////////////////////
1757
+
1758
+	//////////////////////////////////
1759
+	/* Diagnose Location Page Starts */
1760
+	//////////////////////////////////
1761
+	$option_value = get_option('geodir_location_page');
1762
+	$page = get_post($option_value);
1763
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1764
+
1765
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1766
+		$output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1767
+	else {
1768
+		$is_error_during_diagnose = true;
1769
+		$output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1770
+		if ($fix) {
1771
+			if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1772
+				$output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1773
+			} else {
1774
+				$output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1775
+			}
1776
+		}
1777
+	}
1778
+
1779
+	////////////////////////////////
1780
+	/* Diagnose Location Page Ends */
1781
+	////////////////////////////////
1782
+
1783
+	$page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1784
+	/**
1785
+	 * This action is called at the end of the GD Tools page check function.
1786
+	 *
1787
+	 * @since 1.5.2
1788
+	 */
1789
+	$page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1790
+
1791
+	$output_str = $page_chk_arr['output_str'];
1792
+	$is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1793
+
1794
+	if ($is_error_during_diagnose) {
1795
+		if ($fix) {
1796
+			flush_rewrite_rules();
1797
+		}
1798
+		$info_div_class = "geodir_problem_info";
1799
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1800
+	} else {
1801
+		$info_div_class = "geodir_noproblem_info";
1802
+		$fix_button_txt = '';
1803
+	}
1804
+	echo "<ul class='$info_div_class'>";
1805
+	echo $output_str;
1806
+	echo $fix_button_txt;
1807
+	echo "</ul>";
1808 1808
 
1809 1809
 }
1810 1810
 
@@ -1816,26 +1816,26 @@  discard block
 block discarded – undo
1816 1816
  * @global object $wpdb WordPress Database object.
1817 1817
  */
1818 1818
 function geodir_diagnose_load_db_language() {
1819
-    global $wpdb;
1819
+	global $wpdb;
1820 1820
 	
1821 1821
 	$is_error_during_diagnose = geodirectory_load_db_language();
1822 1822
 
1823
-    $output_str = '';
1824
-    $fix_button_txt = '';
1823
+	$output_str = '';
1824
+	$fix_button_txt = '';
1825 1825
 
1826
-    if ($is_error_during_diagnose) {
1827
-        $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
1826
+	if ($is_error_during_diagnose) {
1827
+		$output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
1828 1828
 		$info_div_class = "geodir_problem_info";
1829
-    } else {
1830
-        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1829
+	} else {
1830
+		$output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1831 1831
 		$info_div_class = "geodir_noproblem_info";
1832
-        $fix_button_txt = '';
1833
-    }
1832
+		$fix_button_txt = '';
1833
+	}
1834 1834
     
1835 1835
 	echo "<ul class='$info_div_class'>";
1836
-    echo $output_str;
1837
-    echo $fix_button_txt;
1838
-    echo "</ul>";
1836
+	echo $output_str;
1837
+	echo $fix_button_txt;
1838
+	echo "</ul>";
1839 1839
 
1840 1840
 }
1841 1841
 
@@ -1866,23 +1866,23 @@  discard block
 block discarded – undo
1866 1866
  */
1867 1867
 function geodir_posts_clauses_request($clauses)
1868 1868
 {
1869
-    global $wpdb, $wp_query, $plugin_prefix;
1869
+	global $wpdb, $wp_query, $plugin_prefix;
1870 1870
 
1871
-    if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
1872
-        $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1871
+	if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
1872
+		$table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1873 1873
 
1874
-        $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1875
-        $clauses['join'] = $join;
1874
+		$join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1875
+		$clauses['join'] = $join;
1876 1876
 
1877
-        $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1878
-        $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire';
1879
-        $clauses['fields'] = $fields;
1877
+		$fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1878
+		$fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire';
1879
+		$clauses['fields'] = $fields;
1880 1880
 
1881
-        $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1882
-        $orderby = 'gd_expire ' . $order;
1883
-        $clauses['orderby'] = $orderby;
1884
-    }
1885
-    return $clauses;
1881
+		$order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1882
+		$orderby = 'gd_expire ' . $order;
1883
+		$clauses['orderby'] = $orderby;
1884
+	}
1885
+	return $clauses;
1886 1886
 }
1887 1887
 
1888 1888
 
@@ -1903,7 +1903,7 @@  discard block
 block discarded – undo
1903 1903
  */
1904 1904
 function gd_theme_switch_compat_check()
1905 1905
 {
1906
-    gd_set_theme_compat();
1906
+	gd_set_theme_compat();
1907 1907
 }
1908 1908
 
1909 1909
 /**
@@ -1916,27 +1916,27 @@  discard block
 block discarded – undo
1916 1916
  */
1917 1917
 function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\")
1918 1918
 {
1919
-    if (function_exists('str_getcsv')) {
1920
-        $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1921
-    } else {
1922
-        global $current_user;
1923
-        $upload_dir = wp_upload_dir();
1924
-
1925
-        $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1926
-        $handle = fopen($file, 'w');
1927
-
1928
-        fwrite($handle, $input);
1929
-        fclose($handle);
1930
-
1931
-        $handle = fopen($file, 'rt');
1932
-        if (PHP_VERSION >= '5.3.0') {
1933
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1934
-        } else {
1935
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1936
-        }
1937
-        fclose($handle);
1938
-    }
1939
-    return $fgetcsv;
1919
+	if (function_exists('str_getcsv')) {
1920
+		$fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1921
+	} else {
1922
+		global $current_user;
1923
+		$upload_dir = wp_upload_dir();
1924
+
1925
+		$file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1926
+		$handle = fopen($file, 'w');
1927
+
1928
+		fwrite($handle, $input);
1929
+		fclose($handle);
1930
+
1931
+		$handle = fopen($file, 'rt');
1932
+		if (PHP_VERSION >= '5.3.0') {
1933
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1934
+		} else {
1935
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1936
+		}
1937
+		fclose($handle);
1938
+	}
1939
+	return $fgetcsv;
1940 1940
 }
1941 1941
 
1942 1942
 add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv');
@@ -1951,375 +1951,375 @@  discard block
 block discarded – undo
1951 1951
  */
1952 1952
 function geodir_ajax_import_csv()
1953 1953
 {
1954
-    error_reporting(0); // hide error to get clean json response
1954
+	error_reporting(0); // hide error to get clean json response
1955 1955
 
1956
-    global $wpdb, $plugin_prefix, $current_user;
1957
-    $uploads = wp_upload_dir();
1958
-    ini_set('auto_detect_line_endings', true);
1956
+	global $wpdb, $plugin_prefix, $current_user;
1957
+	$uploads = wp_upload_dir();
1958
+	ini_set('auto_detect_line_endings', true);
1959 1959
 	
1960 1960
 	$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
1961 1961
 
1962
-    $task = isset($_POST['task']) ? $_POST['task'] : '';
1963
-    $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1964
-    $filename = $uploadedFile;
1965
-
1966
-    $uploads = wp_upload_dir();
1967
-    $uploads_dir = $uploads['path'];
1968
-    $image_name_arr = explode('/', $filename);
1969
-    $filename = end($image_name_arr);
1970
-    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1971
-    $return = array();
1972
-    $return['file'] = $uploadedFile;
1973
-    $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1974
-
1975
-    if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1976
-        $wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1977
-
1978
-        if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1979
-            $return['error'] = NULL;
1980
-
1981
-            $return['rows'] = 0;
1982
-
1983
-
1984
-
1985
-                if (($handle = fopen($target_path, "r")) !== FALSE) {
1986
-                    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1987
-                        if(is_array($data) && !empty($data)) {
1988
-                            $file[] = '"' . implode('","', $data) . '"';
1989
-                        }
1990
-                    }
1991
-                    fclose($handle);
1992
-                    $file = $file;
1993
-                }
1994
-
1995
-
1996
-
1997
-                $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1998
-
1999
-
2000
-            if (!$return['rows'] > 0) {
2001
-                $return['error'] = __('No data found in csv file.', 'geodirectory');
2002
-            }
2003
-        }
2004
-    }
2005
-    if ($task == 'prepare' || !empty($return['error'])) {
2006
-        echo json_encode($return);
2007
-        exit;
2008
-    }
2009
-
2010
-    $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
2011
-    $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
2012
-    $count = $importlimit;
2013
-    $requested_limit = $importlimit;
2014
-    $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
2015
-
2016
-    if ($count < $totRecords) {
2017
-        $count = $tmpCnt + $count;
2018
-        if ($count > $totRecords) {
2019
-            $count = $totRecords;
2020
-        }
2021
-    } else {
2022
-        $count = $totRecords;
2023
-    }
2024
-
2025
-    $total_records = 0;
2026
-    $rowcount = 0;
2027
-    $address_invalid = 0;
2028
-    $blank_address = 0;
2029
-    $upload_files = 0;
2030
-    $invalid_post_type = 0;
2031
-    $invalid_title = 0;
2032
-    $customKeyarray = array();
2033
-    $gd_post_info = array();
2034
-    $post_location = array();
2035
-    $countpost = 0;
2036
-
2037
-    if (!empty($file)) {
2038
-        $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
2039
-        $customKeyarray = $columns;
2040
-
2041
-        if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
2042
-            $return['error'] = CSV_INVAILD_FILE;
2043
-            echo json_encode($return);
2044
-            exit;
2045
-        }
2046
-
2047
-        for ($i = 1; $i <= $importlimit; $i++) {
2048
-            $current_index = $tmpCnt + $i;
2049
-            if (isset($file[$current_index])) {
2050
-                $total_records++;
2051
-
2052
-                $buffer = geodir_str_getcsv($file[$current_index]);
2053
-                $post_title = addslashes($buffer[0]);
2054
-                $current_post_author = $buffer[1];
2055
-                $post_desc = addslashes($buffer[2]);
2056
-                $post_cat = array();
2057
-                $catids_arr = array();
2058
-                $post_cat = trim($buffer[3]); // comma seperated category name
2059
-
2060
-                if ($post_cat) {
2061
-                    $post_cat_arr = explode(',', $post_cat);
2062
-
2063
-                    for ($c = 0; $c < count($post_cat_arr); $c++) {
2064
-                        $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
2065
-
2066
-                        if (!empty($buffer[5])) {
2067
-                            if (in_array($buffer[5], geodir_get_posttypes())) {
2068
-
2069
-                                $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
2070
-
2071
-                                if (get_term_by('name', $catid, $p_taxonomy[0])) {
2072
-                                    $cat = get_term_by('name', $catid, $p_taxonomy[0]);
2073
-                                    $catids_arr[] = $cat->slug;
2074
-                                } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
2075
-                                    $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2076
-                                    $catids_arr[] = $cat->slug;
2077
-                                } else {
2078
-                                    $ret = wp_insert_term($catid, $p_taxonomy[0]);
2079
-                                    if ($ret && !is_wp_error($ret)) {
2080
-                                        if (get_term_by('name', $catid, $p_taxonomy[0])) {
2081
-                                            $cat = get_term_by('name', $catid, $p_taxonomy[0]);
2082
-                                            $catids_arr[] = $cat->slug;
2083
-                                        } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
2084
-                                            $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2085
-                                            $catids_arr[] = $cat->slug;
2086
-                                        }
2087
-                                    }
2088
-                                }
2089
-                            }
2090
-                        }
2091
-                    }
2092
-                }
2093
-
2094
-                if (!$catids_arr) {
2095
-                    $catids_arr[] = 1;
2096
-                }
2097
-
2098
-                $post_tags = trim($buffer[4]); // comma seperated tags
2099
-
2100
-                $tag_arr = '';
2101
-                if ($post_tags) {
2102
-                    $tag_arr = explode(',', $post_tags);
2103
-                }
2104
-
2105
-                $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
2106
-
2107
-                $error = '';
2108
-                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
2109
-                    $invalid_post_type++;
2110
-                    continue;
2111
-                }
2112
-
2113
-                if ($post_title != '') {
2114
-                    $menu_order = 0;
2115
-                    $image_folder_name = 'uplaod/';
2116
-
2117
-                    $image_names = array();
2118
-
2119
-                    for ($c = 5; $c < count($customKeyarray); $c++) {
2120
-                        $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
2121
-
2122
-                        if ($customKeyarray[$c] == 'IMAGE') {
2123
-                            $buffer[$c] = trim($buffer[$c]);
2124
-
2125
-                            if (!empty($buffer[$c])) {
2126
-                                $image_names[] = $buffer[$c];
2127
-                            }
2128
-                        }
2129
-
2130
-                        if ($customKeyarray[$c] == 'alive_days') {
2131
-                            if ($buffer[$c] != '0' && $buffer[$c] != '') {
2132
-                                $submitdata = date('Y-m-d');
2133
-
2134
-                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
2135
-                            } else {
2136
-                                $gd_post_info['expire_date'] = 'Never';
2137
-                            }
2138
-                        }
2139
-
2140
-                        if ($customKeyarray[$c] == 'post_city') {
2141
-                            $post_city = addslashes($buffer[$c]);
2142
-                        }
2143
-
2144
-                        if ($customKeyarray[$c] == 'post_region') {
2145
-                            $post_region = addslashes($buffer[$c]);
2146
-                        }
2147
-
2148
-                        if ($customKeyarray[$c] == 'post_country') {
2149
-                            $post_country = addslashes($buffer[$c]);
2150
-                        }
2151
-
2152
-                        if ($customKeyarray[$c] == 'post_latitude') {
2153
-                            $post_latitude = addslashes($buffer[$c]);
2154
-                        }
2155
-
2156
-                        if ($customKeyarray[$c] == 'post_longitude') {
2157
-                            $post_longitude = addslashes($buffer[$c]);
2158
-                        }
1962
+	$task = isset($_POST['task']) ? $_POST['task'] : '';
1963
+	$uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1964
+	$filename = $uploadedFile;
1965
+
1966
+	$uploads = wp_upload_dir();
1967
+	$uploads_dir = $uploads['path'];
1968
+	$image_name_arr = explode('/', $filename);
1969
+	$filename = end($image_name_arr);
1970
+	$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1971
+	$return = array();
1972
+	$return['file'] = $uploadedFile;
1973
+	$return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1974
+
1975
+	if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1976
+		$wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1977
+
1978
+		if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1979
+			$return['error'] = NULL;
1980
+
1981
+			$return['rows'] = 0;
1982
+
1983
+
1984
+
1985
+				if (($handle = fopen($target_path, "r")) !== FALSE) {
1986
+					while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1987
+						if(is_array($data) && !empty($data)) {
1988
+							$file[] = '"' . implode('","', $data) . '"';
1989
+						}
1990
+					}
1991
+					fclose($handle);
1992
+					$file = $file;
1993
+				}
1994
+
1995
+
1996
+
1997
+				$return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1998
+
1999
+
2000
+			if (!$return['rows'] > 0) {
2001
+				$return['error'] = __('No data found in csv file.', 'geodirectory');
2002
+			}
2003
+		}
2004
+	}
2005
+	if ($task == 'prepare' || !empty($return['error'])) {
2006
+		echo json_encode($return);
2007
+		exit;
2008
+	}
2009
+
2010
+	$totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
2011
+	$importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
2012
+	$count = $importlimit;
2013
+	$requested_limit = $importlimit;
2014
+	$tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
2015
+
2016
+	if ($count < $totRecords) {
2017
+		$count = $tmpCnt + $count;
2018
+		if ($count > $totRecords) {
2019
+			$count = $totRecords;
2020
+		}
2021
+	} else {
2022
+		$count = $totRecords;
2023
+	}
2024
+
2025
+	$total_records = 0;
2026
+	$rowcount = 0;
2027
+	$address_invalid = 0;
2028
+	$blank_address = 0;
2029
+	$upload_files = 0;
2030
+	$invalid_post_type = 0;
2031
+	$invalid_title = 0;
2032
+	$customKeyarray = array();
2033
+	$gd_post_info = array();
2034
+	$post_location = array();
2035
+	$countpost = 0;
2036
+
2037
+	if (!empty($file)) {
2038
+		$columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
2039
+		$customKeyarray = $columns;
2040
+
2041
+		if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
2042
+			$return['error'] = CSV_INVAILD_FILE;
2043
+			echo json_encode($return);
2044
+			exit;
2045
+		}
2046
+
2047
+		for ($i = 1; $i <= $importlimit; $i++) {
2048
+			$current_index = $tmpCnt + $i;
2049
+			if (isset($file[$current_index])) {
2050
+				$total_records++;
2051
+
2052
+				$buffer = geodir_str_getcsv($file[$current_index]);
2053
+				$post_title = addslashes($buffer[0]);
2054
+				$current_post_author = $buffer[1];
2055
+				$post_desc = addslashes($buffer[2]);
2056
+				$post_cat = array();
2057
+				$catids_arr = array();
2058
+				$post_cat = trim($buffer[3]); // comma seperated category name
2059
+
2060
+				if ($post_cat) {
2061
+					$post_cat_arr = explode(',', $post_cat);
2062
+
2063
+					for ($c = 0; $c < count($post_cat_arr); $c++) {
2064
+						$catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
2065
+
2066
+						if (!empty($buffer[5])) {
2067
+							if (in_array($buffer[5], geodir_get_posttypes())) {
2068
+
2069
+								$p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
2070
+
2071
+								if (get_term_by('name', $catid, $p_taxonomy[0])) {
2072
+									$cat = get_term_by('name', $catid, $p_taxonomy[0]);
2073
+									$catids_arr[] = $cat->slug;
2074
+								} else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
2075
+									$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2076
+									$catids_arr[] = $cat->slug;
2077
+								} else {
2078
+									$ret = wp_insert_term($catid, $p_taxonomy[0]);
2079
+									if ($ret && !is_wp_error($ret)) {
2080
+										if (get_term_by('name', $catid, $p_taxonomy[0])) {
2081
+											$cat = get_term_by('name', $catid, $p_taxonomy[0]);
2082
+											$catids_arr[] = $cat->slug;
2083
+										} elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
2084
+											$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2085
+											$catids_arr[] = $cat->slug;
2086
+										}
2087
+									}
2088
+								}
2089
+							}
2090
+						}
2091
+					}
2092
+				}
2093
+
2094
+				if (!$catids_arr) {
2095
+					$catids_arr[] = 1;
2096
+				}
2097
+
2098
+				$post_tags = trim($buffer[4]); // comma seperated tags
2099
+
2100
+				$tag_arr = '';
2101
+				if ($post_tags) {
2102
+					$tag_arr = explode(',', $post_tags);
2103
+				}
2104
+
2105
+				$table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
2106
+
2107
+				$error = '';
2108
+				if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
2109
+					$invalid_post_type++;
2110
+					continue;
2111
+				}
2112
+
2113
+				if ($post_title != '') {
2114
+					$menu_order = 0;
2115
+					$image_folder_name = 'uplaod/';
2116
+
2117
+					$image_names = array();
2118
+
2119
+					for ($c = 5; $c < count($customKeyarray); $c++) {
2120
+						$gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
2121
+
2122
+						if ($customKeyarray[$c] == 'IMAGE') {
2123
+							$buffer[$c] = trim($buffer[$c]);
2124
+
2125
+							if (!empty($buffer[$c])) {
2126
+								$image_names[] = $buffer[$c];
2127
+							}
2128
+						}
2129
+
2130
+						if ($customKeyarray[$c] == 'alive_days') {
2131
+							if ($buffer[$c] != '0' && $buffer[$c] != '') {
2132
+								$submitdata = date('Y-m-d');
2133
+
2134
+								$gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
2135
+							} else {
2136
+								$gd_post_info['expire_date'] = 'Never';
2137
+							}
2138
+						}
2139
+
2140
+						if ($customKeyarray[$c] == 'post_city') {
2141
+							$post_city = addslashes($buffer[$c]);
2142
+						}
2143
+
2144
+						if ($customKeyarray[$c] == 'post_region') {
2145
+							$post_region = addslashes($buffer[$c]);
2146
+						}
2147
+
2148
+						if ($customKeyarray[$c] == 'post_country') {
2149
+							$post_country = addslashes($buffer[$c]);
2150
+						}
2151
+
2152
+						if ($customKeyarray[$c] == 'post_latitude') {
2153
+							$post_latitude = addslashes($buffer[$c]);
2154
+						}
2155
+
2156
+						if ($customKeyarray[$c] == 'post_longitude') {
2157
+							$post_longitude = addslashes($buffer[$c]);
2158
+						}
2159 2159
 						
2160 2160
 						// Post status
2161 2161
 						if ($customKeyarray[$c] == 'post_status') {
2162
-                            $post_status = sanitize_key( $buffer[$c] );
2163
-                        }
2164
-                    }
2165
-
2166
-                    /* ================ before array create ============== */
2167
-                    $location_result = geodir_get_default_location();
2168
-                    if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
2169
-                        $blank_address++;
2170
-                        continue;
2171
-                    } else if ($location_result->location_id == 0) {
2172
-                        if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
2173
-                            $address_invalid++;
2174
-                            continue;
2175
-                        }
2176
-                    }
2162
+							$post_status = sanitize_key( $buffer[$c] );
2163
+						}
2164
+					}
2165
+
2166
+					/* ================ before array create ============== */
2167
+					$location_result = geodir_get_default_location();
2168
+					if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
2169
+						$blank_address++;
2170
+						continue;
2171
+					} else if ($location_result->location_id == 0) {
2172
+						if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
2173
+							$address_invalid++;
2174
+							continue;
2175
+						}
2176
+					}
2177 2177
 					
2178 2178
 					// Default post status
2179 2179
 					$default_status = 'publish';
2180 2180
 					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
2181 2181
 					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
2182 2182
 
2183
-                    $my_post['post_title'] = $post_title;
2184
-                    $my_post['post_content'] = $post_desc;
2185
-                    $my_post['post_type'] = addslashes($buffer[5]);
2186
-                    $my_post['post_author'] = $current_post_author;
2187
-                    $my_post['post_status'] = $post_status;
2188
-                    $my_post['post_category'] = $catids_arr;
2189
-                    $my_post['post_tags'] = $tag_arr;
2190
-
2191
-                    $gd_post_info['post_tags'] = $tag_arr;
2192
-                    $gd_post_info['post_title'] = $post_title;
2193
-                    $gd_post_info['post_status'] = $post_status;
2194
-                    $gd_post_info['submit_time'] = time();
2195
-                    $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
2196
-
2197
-                    $last_postid = wp_insert_post($my_post);
2198
-                    $countpost++;
2199
-
2200
-                    // Check if we need to save post location as new location
2201
-                    if ($location_result->location_id > 0) {
2202
-                        if (isset($post_city) && isset($post_region)) {
2203
-                            $request_info['post_location'] = array(
2204
-                                'city' => $post_city,
2205
-                                'region' => $post_region,
2206
-                                'country' => $post_country,
2207
-                                'geo_lat' => $post_latitude,
2208
-                                'geo_lng' => $post_longitude
2209
-                            );
2210
-
2211
-                            $post_location_info = $request_info['post_location'];
2212
-                            if ($location_id = geodir_add_new_location($post_location_info))
2213
-                                $post_location_id = $location_id;
2214
-                        } else {
2215
-                            $post_location_id = 0;
2216
-                        }
2217
-                    } else {
2218
-                        $post_location_id = 0;
2219
-                    }
2220
-
2221
-                    /* ------- get default package info ----- */
2222
-                    $payment_info = array();
2223
-                    $package_info = array();
2224
-
2225
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2226
-                    $package_id = '';
2227
-                    if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2228
-                        $package_id = $gd_post_info['package_id'];
2229
-                    }
2230
-
2231
-                    if (!empty($package_info)) {
2232
-                        $payment_info['package_id'] = $package_info['pid'];
2233
-
2234
-                        if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2235
-                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2236
-                        } else {
2237
-                            $payment_info['expire_date'] = 'Never';
2238
-                        }
2239
-
2240
-                        $gd_post_info = array_merge($gd_post_info, $payment_info);
2241
-                    }
2242
-
2243
-                    $gd_post_info['post_location_id'] = $post_location_id;
2244
-
2245
-                    $post_type = get_post_type($last_postid);
2246
-
2247
-                    $table = $plugin_prefix . $post_type . '_detail';
2248
-
2249
-                    geodir_save_post_info($last_postid, $gd_post_info);
2250
-
2251
-                    if (!empty($image_names)) {
2252
-                        $upload_files++;
2253
-                        $menu_order = 1;
2254
-
2255
-                        foreach ($image_names as $image_name) {
2256
-                            $img_name_arr = explode('.', $image_name);
2257
-
2258
-                            $uploads = wp_upload_dir();
2259
-                            $sub_dir = $uploads['subdir'];
2260
-
2261
-                            $arr_file_type = wp_check_filetype($image_name);
2262
-                            $uploaded_file_type = $arr_file_type['type'];
2263
-
2264
-                            $attachment = array();
2265
-                            $attachment['post_id'] = $last_postid;
2266
-                            $attachment['title'] = $img_name_arr[0];
2267
-                            $attachment['content'] = '';
2268
-                            $attachment['file'] = $sub_dir . '/' . $image_name;
2269
-                            $attachment['mime_type'] = $uploaded_file_type;
2270
-                            $attachment['menu_order'] = $menu_order;
2271
-                            $attachment['is_featured'] = 0;
2272
-
2273
-                            $attachment_set = '';
2274
-
2275
-                            foreach ($attachment as $key => $val) {
2276
-                                if ($val != '')
2277
-                                    $attachment_set .= $key . " = '" . $val . "', ";
2278
-                            }
2279
-                            $attachment_set = trim($attachment_set, ", ");
2280
-
2281
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2282
-
2283
-                            if ($menu_order == 1) {
2284
-                                $post_type = get_post_type($last_postid);
2285
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2286
-                            }
2287
-                            $menu_order++;
2288
-                        }
2289
-                    }
2290
-
2291
-                    $gd_post_info['package_id'] = $package_id;
2292
-
2293
-                    /** This action is documented in geodirectory-functions/post-functions.php */
2294
-                    do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
2295
-
2296
-                    if (!empty($buffer[5])) {
2297
-                        if (in_array($buffer[5], geodir_get_posttypes())) {
2298
-                            $taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2299
-                            wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2300
-                            wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2301
-
2302
-                            $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2303
-                            $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2304
-                            geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2305
-                        }
2306
-                    }
2307
-                } else {
2308
-                    $invalid_title++;
2309
-                }
2310
-            }
2311
-        }
2312
-    }
2313
-    $return['rowcount'] = $countpost;
2314
-    $return['invalidcount'] = $address_invalid;
2315
-    $return['blank_address'] = $blank_address;
2316
-    $return['upload_files'] = $upload_files;
2317
-    $return['invalid_post_type'] = $invalid_post_type;
2318
-    $return['invalid_title'] = $invalid_title;
2319
-    $return['total_records'] = $total_records;
2320
-
2321
-    echo json_encode($return);
2322
-    exit;
2183
+					$my_post['post_title'] = $post_title;
2184
+					$my_post['post_content'] = $post_desc;
2185
+					$my_post['post_type'] = addslashes($buffer[5]);
2186
+					$my_post['post_author'] = $current_post_author;
2187
+					$my_post['post_status'] = $post_status;
2188
+					$my_post['post_category'] = $catids_arr;
2189
+					$my_post['post_tags'] = $tag_arr;
2190
+
2191
+					$gd_post_info['post_tags'] = $tag_arr;
2192
+					$gd_post_info['post_title'] = $post_title;
2193
+					$gd_post_info['post_status'] = $post_status;
2194
+					$gd_post_info['submit_time'] = time();
2195
+					$gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
2196
+
2197
+					$last_postid = wp_insert_post($my_post);
2198
+					$countpost++;
2199
+
2200
+					// Check if we need to save post location as new location
2201
+					if ($location_result->location_id > 0) {
2202
+						if (isset($post_city) && isset($post_region)) {
2203
+							$request_info['post_location'] = array(
2204
+								'city' => $post_city,
2205
+								'region' => $post_region,
2206
+								'country' => $post_country,
2207
+								'geo_lat' => $post_latitude,
2208
+								'geo_lng' => $post_longitude
2209
+							);
2210
+
2211
+							$post_location_info = $request_info['post_location'];
2212
+							if ($location_id = geodir_add_new_location($post_location_info))
2213
+								$post_location_id = $location_id;
2214
+						} else {
2215
+							$post_location_id = 0;
2216
+						}
2217
+					} else {
2218
+						$post_location_id = 0;
2219
+					}
2220
+
2221
+					/* ------- get default package info ----- */
2222
+					$payment_info = array();
2223
+					$package_info = array();
2224
+
2225
+					$package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2226
+					$package_id = '';
2227
+					if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2228
+						$package_id = $gd_post_info['package_id'];
2229
+					}
2230
+
2231
+					if (!empty($package_info)) {
2232
+						$payment_info['package_id'] = $package_info['pid'];
2233
+
2234
+						if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2235
+							$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2236
+						} else {
2237
+							$payment_info['expire_date'] = 'Never';
2238
+						}
2239
+
2240
+						$gd_post_info = array_merge($gd_post_info, $payment_info);
2241
+					}
2242
+
2243
+					$gd_post_info['post_location_id'] = $post_location_id;
2244
+
2245
+					$post_type = get_post_type($last_postid);
2246
+
2247
+					$table = $plugin_prefix . $post_type . '_detail';
2248
+
2249
+					geodir_save_post_info($last_postid, $gd_post_info);
2250
+
2251
+					if (!empty($image_names)) {
2252
+						$upload_files++;
2253
+						$menu_order = 1;
2254
+
2255
+						foreach ($image_names as $image_name) {
2256
+							$img_name_arr = explode('.', $image_name);
2257
+
2258
+							$uploads = wp_upload_dir();
2259
+							$sub_dir = $uploads['subdir'];
2260
+
2261
+							$arr_file_type = wp_check_filetype($image_name);
2262
+							$uploaded_file_type = $arr_file_type['type'];
2263
+
2264
+							$attachment = array();
2265
+							$attachment['post_id'] = $last_postid;
2266
+							$attachment['title'] = $img_name_arr[0];
2267
+							$attachment['content'] = '';
2268
+							$attachment['file'] = $sub_dir . '/' . $image_name;
2269
+							$attachment['mime_type'] = $uploaded_file_type;
2270
+							$attachment['menu_order'] = $menu_order;
2271
+							$attachment['is_featured'] = 0;
2272
+
2273
+							$attachment_set = '';
2274
+
2275
+							foreach ($attachment as $key => $val) {
2276
+								if ($val != '')
2277
+									$attachment_set .= $key . " = '" . $val . "', ";
2278
+							}
2279
+							$attachment_set = trim($attachment_set, ", ");
2280
+
2281
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2282
+
2283
+							if ($menu_order == 1) {
2284
+								$post_type = get_post_type($last_postid);
2285
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2286
+							}
2287
+							$menu_order++;
2288
+						}
2289
+					}
2290
+
2291
+					$gd_post_info['package_id'] = $package_id;
2292
+
2293
+					/** This action is documented in geodirectory-functions/post-functions.php */
2294
+					do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
2295
+
2296
+					if (!empty($buffer[5])) {
2297
+						if (in_array($buffer[5], geodir_get_posttypes())) {
2298
+							$taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2299
+							wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2300
+							wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2301
+
2302
+							$post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2303
+							$post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2304
+							geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2305
+						}
2306
+					}
2307
+				} else {
2308
+					$invalid_title++;
2309
+				}
2310
+			}
2311
+		}
2312
+	}
2313
+	$return['rowcount'] = $countpost;
2314
+	$return['invalidcount'] = $address_invalid;
2315
+	$return['blank_address'] = $blank_address;
2316
+	$return['upload_files'] = $upload_files;
2317
+	$return['invalid_post_type'] = $invalid_post_type;
2318
+	$return['invalid_title'] = $invalid_title;
2319
+	$return['total_records'] = $total_records;
2320
+
2321
+	echo json_encode($return);
2322
+	exit;
2323 2323
 }
2324 2324
 
2325 2325
 // Add the tab in left sidebar menu fro import & export page.
@@ -2339,9 +2339,9 @@  discard block
 block discarded – undo
2339 2339
  * @param $post object $post The post object of the post being saved.
2340 2340
  */
2341 2341
 function geodir_update_location_prefix($post_id,$post){
2342
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2343
-        update_option('geodir_location_prefix',$post->post_name);
2344
-    }
2342
+	if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2343
+		update_option('geodir_location_prefix',$post->post_name);
2344
+	}
2345 2345
 
2346 2346
 }
2347 2347
 
@@ -2352,50 +2352,50 @@  discard block
 block discarded – undo
2352 2352
 function geodir_ga_callback(){
2353 2353
 
2354 2354
 if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2355
-    $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2356
-    $code = "code=".$_REQUEST['code'];
2357
-    $grant_type = "&grant_type=authorization_code";
2358
-    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2359
-    $client_id = "&client_id=".get_option('geodir_ga_client_id');
2360
-    $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2355
+	$oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2356
+	$code = "code=".$_REQUEST['code'];
2357
+	$grant_type = "&grant_type=authorization_code";
2358
+	$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2359
+	$client_id = "&client_id=".get_option('geodir_ga_client_id');
2360
+	$client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2361 2361
 
2362
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2362
+	$auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2363 2363
 
2364
-    $response = wp_remote_post($auth_url, array('timeout' => 15));
2364
+	$response = wp_remote_post($auth_url, array('timeout' => 15));
2365 2365
 
2366
-    //print_r($response);
2366
+	//print_r($response);
2367 2367
 
2368
-    $error_msg =  __('Something went wrong','geodirectory');
2369
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2368
+	$error_msg =  __('Something went wrong','geodirectory');
2369
+	if(!empty($response['response']['code']) && $response['response']['code']==200){
2370 2370
 
2371
-        $parts = json_decode($response['body']);
2372
-        //print_r($parts);
2373
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2374
-        else{
2371
+		$parts = json_decode($response['body']);
2372
+		//print_r($parts);
2373
+		if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2374
+		else{
2375 2375
 
2376
-            update_option('gd_ga_access_token', $parts->access_token);
2377
-            update_option('gd_ga_refresh_token', $parts->refresh_token);
2378
-            ?><script>window.close();</script><?php
2379
-        }
2376
+			update_option('gd_ga_access_token', $parts->access_token);
2377
+			update_option('gd_ga_refresh_token', $parts->refresh_token);
2378
+			?><script>window.close();</script><?php
2379
+		}
2380 2380
 
2381 2381
 
2382
-    }
2383
-    elseif(!empty($response['response']['code'])) {
2384
-        $parts = json_decode($response['body']);
2382
+	}
2383
+	elseif(!empty($response['response']['code'])) {
2384
+		$parts = json_decode($response['body']);
2385 2385
 
2386
-        if(isset($parts->error)){
2387
-            echo $parts->error.": ".$parts->error_description;exit;
2388
-        }else{
2389
-            echo $error_msg." - #2";exit;
2390
-        }
2386
+		if(isset($parts->error)){
2387
+			echo $parts->error.": ".$parts->error_description;exit;
2388
+		}else{
2389
+			echo $error_msg." - #2";exit;
2390
+		}
2391 2391
 
2392
-    }else{
2392
+	}else{
2393 2393
 
2394
-        echo $error_msg." - #3";exit;
2394
+		echo $error_msg." - #3";exit;
2395 2395
 
2396
-    }
2396
+	}
2397 2397
 }
2398
-    exit;
2398
+	exit;
2399 2399
 }
2400 2400
 
2401 2401
 if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
@@ -2411,45 +2411,45 @@  discard block
 block discarded – undo
2411 2411
  * @return array Array of settings.
2412 2412
  */
2413 2413
 function geodir_uninstall_settings($general_settings) {
2414
-    $settings   = array();
2415
-    $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
2416
-    $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
2414
+	$settings   = array();
2415
+	$settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
2416
+	$settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
2417 2417
     
2418
-    $plugins    = get_plugins();
2419
-    $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
2418
+	$plugins    = get_plugins();
2419
+	$un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
2420 2420
     
2421
-    if (!empty($plugins) && !empty($un_plugins)) {
2422
-        foreach ($plugins as $plugin => $data) {
2423
-            $plugin_name = plugin_basename(dirname($plugin));
2421
+	if (!empty($plugins) && !empty($un_plugins)) {
2422
+		foreach ($plugins as $plugin => $data) {
2423
+			$plugin_name = plugin_basename(dirname($plugin));
2424 2424
             
2425
-            if (in_array($plugin_name, $un_plugins)) {
2426
-                $settings[] = array(
2427
-                    'type' => 'checkbox',
2428
-                    'id' => 'geodir_un_' . $plugin_name,
2429
-                    'name' => $data['Name'],
2430
-                    'desc' => __('Remove all data when deleted?', 'geodirectory'),
2431
-                    'std' => '0'
2432
-                );
2433
-            }
2434
-        }
2435
-    }
2425
+			if (in_array($plugin_name, $un_plugins)) {
2426
+				$settings[] = array(
2427
+					'type' => 'checkbox',
2428
+					'id' => 'geodir_un_' . $plugin_name,
2429
+					'name' => $data['Name'],
2430
+					'desc' => __('Remove all data when deleted?', 'geodirectory'),
2431
+					'std' => '0'
2432
+				);
2433
+			}
2434
+		}
2435
+	}
2436 2436
         
2437
-    $settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main');
2437
+	$settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main');
2438 2438
     
2439
-    /**
2440
-     * Filter the uninstall settings array.
2441
-     *
2442
-     * @since 1.6.9
2443
-     *
2444
-     * @param array $settings The settings array.
2445
-     */
2446
-    $settings = apply_filters('geodir_uninstall_settings', $settings);
2439
+	/**
2440
+	 * Filter the uninstall settings array.
2441
+	 *
2442
+	 * @since 1.6.9
2443
+	 *
2444
+	 * @param array $settings The settings array.
2445
+	 */
2446
+	$settings = apply_filters('geodir_uninstall_settings', $settings);
2447 2447
     
2448
-    if (!empty($settings) && count($settings) > 3) {
2449
-        return array_merge($general_settings, $settings);
2450
-    }
2448
+	if (!empty($settings) && count($settings) > 3) {
2449
+		return array_merge($general_settings, $settings);
2450
+	}
2451 2451
     
2452
-    return $general_settings;
2452
+	return $general_settings;
2453 2453
 }
2454 2454
 add_filter('geodir_general_settings', 'geodir_uninstall_settings', 100, 1);
2455 2455
 
@@ -2459,7 +2459,7 @@  discard block
 block discarded – undo
2459 2459
  * @since 1.6.9
2460 2460
  */
2461 2461
 function geodir_uninstall_settings_desc() {
2462
-    echo '<p class="gd-un-settings-desc">' . __('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory') . '</p>';
2462
+	echo '<p class="gd-un-settings-desc">' . __('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory') . '</p>';
2463 2463
 }
2464 2464
 add_action('geodir_settings_uninstall_settings_main_start', 'geodir_uninstall_settings_desc');
2465 2465
 
@@ -2475,18 +2475,18 @@  discard block
 block discarded – undo
2475 2475
  * @return array The settings array.
2476 2476
  */
2477 2477
 function geodir_resave_settings($settings = array()) {
2478
-    if (!empty($settings) && is_array($settings)) {
2479
-        $c = 0;
2478
+	if (!empty($settings) && is_array($settings)) {
2479
+		$c = 0;
2480 2480
         
2481
-        foreach ($settings as $setting) {
2482
-            if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) {
2483
-                $settings[$c]['std'] = $value;
2484
-            }
2485
-            $c++;
2486
-        }
2487
-    }
2488
-
2489
-    return $settings;
2481
+		foreach ($settings as $setting) {
2482
+			if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) {
2483
+				$settings[$c]['std'] = $value;
2484
+			}
2485
+			$c++;
2486
+		}
2487
+	}
2488
+
2489
+	return $settings;
2490 2490
 }
2491 2491
 
2492 2492
 /**
@@ -2498,9 +2498,9 @@  discard block
 block discarded – undo
2498 2498
  * @return array The modified settings.
2499 2499
  */
2500 2500
 function geodir_core_uninstall_settings($settings) {
2501
-    $settings[] = plugin_basename(dirname(dirname(__FILE__)));
2501
+	$settings[] = plugin_basename(dirname(dirname(__FILE__)));
2502 2502
     
2503
-    return $settings;
2503
+	return $settings;
2504 2504
 }
2505 2505
 add_filter('geodir_plugins_uninstall_settings', 'geodir_core_uninstall_settings', 10, 1);
2506 2506
 
@@ -2514,32 +2514,32 @@  discard block
 block discarded – undo
2514 2514
  */
2515 2515
 function geodir_diagnose_reload_db_countries()
2516 2516
 {
2517
-    global $wpdb, $plugin_prefix;
2518
-
2519
-    $is_error_during_diagnose = false;
2520
-    $output_str = '';
2521
-
2522
-    $delete = $wpdb->query("TRUNCATE TABLE ".GEODIR_COUNTRIES_TABLE);
2523
-
2524
-
2525
-    if ($delete) {
2526
-            $output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>";
2527
-        ob_start();
2528
-        geodir_diagnose_version_clear();
2529
-        ob_end_clean();
2530
-    }else{
2531
-        $output_str .= "<li><strong>" . __('Something went wrong.', 'geodirectory') . "</strong></li>";
2532
-    }
2533
-
2534
-    if ($is_error_during_diagnose) {
2535
-        $info_div_class = "geodir_problem_info";
2536
-        $fix_button_txt = "";
2537
-    } else {
2538
-        $info_div_class = "geodir_noproblem_info";
2539
-        $fix_button_txt = '';
2540
-    }
2541
-    echo "<ul class='$info_div_class'>";
2542
-    echo $output_str;
2543
-    echo $fix_button_txt;
2544
-    echo "</ul>";
2517
+	global $wpdb, $plugin_prefix;
2518
+
2519
+	$is_error_during_diagnose = false;
2520
+	$output_str = '';
2521
+
2522
+	$delete = $wpdb->query("TRUNCATE TABLE ".GEODIR_COUNTRIES_TABLE);
2523
+
2524
+
2525
+	if ($delete) {
2526
+			$output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>";
2527
+		ob_start();
2528
+		geodir_diagnose_version_clear();
2529
+		ob_end_clean();
2530
+	}else{
2531
+		$output_str .= "<li><strong>" . __('Something went wrong.', 'geodirectory') . "</strong></li>";
2532
+	}
2533
+
2534
+	if ($is_error_during_diagnose) {
2535
+		$info_div_class = "geodir_problem_info";
2536
+		$fix_button_txt = "";
2537
+	} else {
2538
+		$info_div_class = "geodir_noproblem_info";
2539
+		$fix_button_txt = '';
2540
+	}
2541
+	echo "<ul class='$info_div_class'>";
2542
+	echo $output_str;
2543
+	echo $fix_button_txt;
2544
+	echo "</ul>";
2545 2545
 }
2546 2546
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function geodir_get_admin_option_form($current_tab)
64 64
 {
65
-    geodir_admin_option_form($current_tab);// defined in admin template tags.php
65
+    geodir_admin_option_form($current_tab); // defined in admin template tags.php
66 66
 }
67 67
 
68 68
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 add_action('geodir_update_options_compatibility_settings', 'geodir_update_options_compatibility_settings');
71 71
 add_action('geodir_update_options_default_location_settings', 'geodir_location_form_submit');
72 72
 add_action('geodir_before_admin_panel', 'geodir_before_admin_panel'); // this function is in admin_functions.php
73
-add_action('geodir_before_update_options', 'geodir_before_update_options',10,2);
73
+add_action('geodir_before_update_options', 'geodir_before_update_options', 10, 2);
74 74
 
75 75
 //add_action('geodir_before_admin_panel', 'geodir_autoinstall_admin_header');
76 76
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         
100 100
         // Disable VC editor for GD post types.
101 101
         if (class_exists('Vc_Role_Access_Controller')) {
102
-            add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 );
102
+            add_filter('vc_role_access_with_post_types_can', '__return_false', 100);
103 103
         }
104 104
     }
105 105
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 add_action('admin_panel_init', 'geodir_admin_list_columns', 2);
127 127
 
128 128
 /* --- insert dummy post action ---*/
129
-add_action('geodir_insert_dummy_posts', 'geodir_insert_dummy_posts', 1,3);
130
-add_action('geodir_delete_dummy_posts', 'geodir_delete_dummy_posts', 1,3);
129
+add_action('geodir_insert_dummy_posts', 'geodir_insert_dummy_posts', 1, 3);
130
+add_action('geodir_delete_dummy_posts', 'geodir_delete_dummy_posts', 1, 3);
131 131
 
132 132
 
133 133
 /**
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 
237 237
         // Filter-Payment-Manager
238 238
 
239
-        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
239
+        add_meta_box('geodir_post_images', $post_typename.' '.__('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
240 240
 
241
-        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
241
+        add_meta_box('geodir_post_info', $post_typename.' '.__('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
242 242
 
243 243
         // no need of this box as all fields moved to main information box
244 244
         //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
 }
249 249
 
250
-add_action('save_post', 'geodir_post_information_save',10,2);
250
+add_action('save_post', 'geodir_post_information_save', 10, 2);
251 251
 
252 252
 
253 253
 
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
 
275 275
             $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
276 276
 
277
-            if(!empty($gd_taxonomy)) {
277
+            if (!empty($gd_taxonomy)) {
278 278
                 foreach ($gd_taxonomy as $tax) {
279 279
 
280
-                    remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
280
+                    remove_meta_box($tax.'div', $geodir_post_type, 'normal');
281 281
 
282 282
                 }
283 283
             }
@@ -363,14 +363,14 @@  discard block
 block discarded – undo
363 363
 add_action('geodir_manage_available_fields_predefined', 'geodir_manage_available_fields_predefined');
364 364
 add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom');
365 365
 
366
-function geodir_manage_available_fields_predefined($sub_tab){
367
-    if($sub_tab=='custom_fields'){
366
+function geodir_manage_available_fields_predefined($sub_tab) {
367
+    if ($sub_tab == 'custom_fields') {
368 368
         geodir_custom_available_fields('predefined');
369 369
     }
370 370
 }
371 371
 
372
-function geodir_manage_available_fields_custom($sub_tab){
373
-    if($sub_tab=='custom_fields'){
372
+function geodir_manage_available_fields_custom($sub_tab) {
373
+    if ($sub_tab == 'custom_fields') {
374 374
         geodir_custom_available_fields('custom');
375 375
     }
376 376
 }
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
     global $wpdb;
441 441
     $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
442 442
     ?>
443
-    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
443
+    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/>
444 444
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
445 445
     <ul>
446 446
     <?php
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 
452 452
             $check_html_variable = $wpdb->get_var(
453 453
                 $wpdb->prepare(
454
-                    "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
454
+                    "SELECT htmlvar_name FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
455 455
                     array($val['htmlvar_name'], $listing_type, $val['field_type'])
456 456
                 )
457 457
             );
@@ -459,23 +459,23 @@  discard block
 block discarded – undo
459 459
             $display = $check_html_variable ? ' style="display:none;"' : '';
460 460
            ?>
461 461
 
462
-            <li   class="gd-cf-tooltip-wrap" <?php echo $display;?>>
462
+            <li   class="gd-cf-tooltip-wrap" <?php echo $display; ?>>
463 463
                 <?php
464
-                if(isset($val['description']) && $val['description']){
464
+                if (isset($val['description']) && $val['description']) {
465 465
                     echo '<div class="gdcf-tooltip">'.$val['description'].'</div>';
466 466
                 }?>
467 467
 
468
-                <a id="gd-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" data-field-type-key="<?php echo $val['htmlvar_name'];?>"  data-field-type="<?php echo $val['field_type'];?>"
469
-                   title="<?php echo $val['site_title'];?>"
470
-                   class="gd-draggable-form-items  gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);">
468
+                <a id="gd-<?php echo $val['field_type']; ?>-_-<?php echo $val['htmlvar_name']; ?>" data-field-type-key="<?php echo $val['htmlvar_name']; ?>"  data-field-type="<?php echo $val['field_type']; ?>"
469
+                   title="<?php echo $val['site_title']; ?>"
470
+                   class="gd-draggable-form-items  gd-<?php echo $val['field_type']; ?> geodir-sort-<?php echo $val['htmlvar_name']; ?>" href="javascript:void(0);">
471 471
                     <?php if (isset($val['field_icon']) && strpos($val['field_icon'], 'fa fa-') !== false) {
472 472
                         echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>';
473
-                    }elseif(isset($val['field_icon']) && $val['field_icon'] ){
473
+                    }elseif (isset($val['field_icon']) && $val['field_icon']) {
474 474
                         echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>';
475
-                    }else{
475
+                    } else {
476 476
                         echo '<i class="fa fa-cog" aria-hidden="true"></i>';
477 477
                     }?>
478
-                    <?php echo $val['site_title'];?>
478
+                    <?php echo $val['site_title']; ?>
479 479
                 </a>
480 480
             </li>
481 481
 
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
     <?php 
504 504
         global $wpdb;
505 505
         
506
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
506
+        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
507 507
 
508 508
         if (!empty($fields)) {
509 509
             foreach ($fields as $field) {
@@ -528,14 +528,14 @@  discard block
 block discarded – undo
528 528
  * @since 1.6.9
529 529
  * @package GeoDirectory
530 530
  */
531
-function geodir_custom_fields_custom($post_type=''){
531
+function geodir_custom_fields_custom($post_type = '') {
532 532
 
533 533
     $custom_fields = array();
534 534
 
535 535
     /**
536 536
      * @see `geodir_custom_fields`
537 537
      */
538
-    return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
538
+    return apply_filters('geodir_custom_fields_custom', $custom_fields, $post_type);
539 539
 }
540 540
 
541 541
 
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
  * @since 1.6.6
547 547
  * @package GeoDirectory
548 548
  */
549
-function geodir_custom_fields($post_type=''){
549
+function geodir_custom_fields($post_type = '') {
550 550
     
551 551
     $custom_fields = array(
552 552
         'text' => array(
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
      * }
682 682
      * @param string $post_type The post type requested.
683 683
      */
684
-    return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
684
+    return apply_filters('geodir_custom_fields', $custom_fields, $post_type);
685 685
 }
686 686
 
687 687
 /**
@@ -692,25 +692,25 @@  discard block
 block discarded – undo
692 692
  * @param string $type The custom field type, predefined, custom or blank for default
693 693
  * @package GeoDirectory
694 694
  */
695
-function geodir_custom_available_fields($type='')
695
+function geodir_custom_available_fields($type = '')
696 696
 {
697 697
     $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
698 698
     ?>
699
-    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
699
+    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/>
700 700
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" />
701 701
 
702 702
         <?php
703
-        if($type=='predefined'){
703
+        if ($type == 'predefined') {
704 704
             $cfs = geodir_custom_fields_predefined($listing_type);
705
-        }elseif($type=='custom'){
705
+        }elseif ($type == 'custom') {
706 706
             $cfs = geodir_custom_fields_custom($listing_type);
707
-        }else{
707
+        } else {
708 708
             $cfs = geodir_custom_fields($listing_type);
709 709
             ?>
710 710
             <ul class="full gd-cf-tooltip-wrap">
711 711
                 <li>
712 712
                     <div class="gdcf-tooltip">
713
-                        <?php _e('This adds a section separator with a title.', 'geodirectory');?>
713
+                        <?php _e('This adds a section separator with a title.', 'geodirectory'); ?>
714 714
                     </div>
715 715
                     <a id="gt-fieldset"
716 716
                        class="gd-draggable-form-items gt-fieldset"
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 
722 722
                         <i class="fa fa-long-arrow-left " aria-hidden="true"></i>
723 723
                         <i class="fa fa-long-arrow-right " aria-hidden="true"></i>
724
-                        <?php _e('Fieldset (section separator)', 'geodirectory');?>
724
+                        <?php _e('Fieldset (section separator)', 'geodirectory'); ?>
725 725
                     </a>
726 726
                 </li>
727 727
             </ul>
@@ -729,15 +729,15 @@  discard block
 block discarded – undo
729 729
             <?php
730 730
         }
731 731
 
732
-    if(!empty($cfs)) {
732
+    if (!empty($cfs)) {
733 733
         echo '<ul>';
734
-        foreach ( $cfs as $id => $cf ) {
734
+        foreach ($cfs as $id => $cf) {
735 735
             ?>
736 736
 
737 737
             <li class="gd-cf-tooltip-wrap">
738 738
                 <?php
739
-                if ( isset( $cf['description'] ) && $cf['description'] ) {
740
-                    echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>';
739
+                if (isset($cf['description']) && $cf['description']) {
740
+                    echo '<div class="gdcf-tooltip">'.$cf['description'].'</div>';
741 741
                 } ?>
742 742
 
743 743
                 <a id="gd-<?php echo $id; ?>"
@@ -747,10 +747,10 @@  discard block
 block discarded – undo
747 747
                    class="gd-draggable-form-items <?php echo $cf['class']; ?>"
748 748
                    href="javascript:void(0);">
749 749
 
750
-                    <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], 'fa fa-' ) !== false ) {
751
-                        echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>';
752
-                    } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
753
-                        echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>';
750
+                    <?php if (isset($cf['icon']) && strpos($cf['icon'], 'fa fa-') !== false) {
751
+                        echo '<i class="'.$cf['icon'].'" aria-hidden="true"></i>';
752
+                    } elseif (isset($cf['icon']) && $cf['icon']) {
753
+                        echo '<b style="background-image: url("'.$cf['icon'].'")"></b>';
754 754
                     } else {
755 755
                         echo '<i class="fa fa-cog" aria-hidden="true"></i>';
756 756
                     } ?>
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
             </li>
760 760
             <?php
761 761
         }
762
-    }else{
762
+    } else {
763 763
         _e('There are no custom fields here yet.', 'geodirectory');
764 764
     }
765 765
         ?>
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
     <ul class="core">
788 788
     <?php 
789 789
         global $wpdb;
790
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
790
+        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
791 791
 
792 792
         if (!empty($fields)) {
793 793
             foreach ($fields as $field) {
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
                 $field_type_key = $field->field_type_key;
798 798
                 $field_ins_upd = 'display';
799 799
 
800
-                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key);
800
+                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd, $field_type_key);
801 801
             }
802 802
         }
803 803
         ?></ul>
@@ -956,8 +956,8 @@  discard block
 block discarded – undo
956 956
 
957 957
     if (!get_option('geodir_remove_unnecessary_fields')) {
958 958
 
959
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
960
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
959
+        if ($wpdb->get_var("SHOW COLUMNS FROM ".$plugin_prefix."gd_place_detail WHERE field = 'categories'"))
960
+            $wpdb->query("ALTER TABLE `".$plugin_prefix."gd_place_detail` DROP `categories`");
961 961
 
962 962
         update_option('geodir_remove_unnecessary_fields', '1');
963 963
 
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
             case 'diagnosis' :
987 987
                 if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
988 988
                     $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
989
-                    call_user_func('geodir_diagnose_' . $diagnose_this);
989
+                    call_user_func('geodir_diagnose_'.$diagnose_this);
990 990
 
991 991
                 }
992 992
                 exit();
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
             case 'diagnosis-fix' :
996 996
                 if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
997 997
                     $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
998
-                call_user_func('geodir_diagnose_' . $diagnose_this);
998
+                call_user_func('geodir_diagnose_'.$diagnose_this);
999 999
                 exit();
1000 1000
                 break;
1001 1001
         }
@@ -1020,50 +1020,50 @@  discard block
 block discarded – undo
1020 1020
 {
1021 1021
     global $wpdb;
1022 1022
     //$filter_arr['output_str'] .='###'.$table.'###';
1023
-    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
1024
-        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
1023
+    if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0) {
1024
+        $filter_arr['output_str'] .= "<li>".__('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory')."</li>";
1025 1025
         $filter_arr['is_error_during_diagnose'] = true;
1026 1026
 
1027
-    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1028
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
1027
+    } elseif ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
1028
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name)."</li>";
1029 1029
         $filter_arr['is_error_during_diagnose'] = true;
1030
-        $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
1030
+        $filter_arr['output_str'] .= "<li>".__('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory')."</li>";
1031 1031
         $filter_arr['is_error_during_diagnose'] = true;
1032 1032
 
1033 1033
         if ($fix) {
1034
-            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
1035
-            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
1034
+            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$table."_ms_bak"); // get backup table count
1035
+            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table"); // get new table count
1036 1036
 
1037 1037
             if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
1038 1038
                 //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
1039 1039
 
1040
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
1040
+                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename bak table to new table
1041 1041
 
1042
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1043
-                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
1042
+                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
1043
+                    $filter_arr['output_str'] .= "<li>".__('-->FIXED: Renamed and backed up the tables', 'geodirectory')."</li>";
1044 1044
                 } else {
1045
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1045
+                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
1046 1046
                 }
1047 1047
 
1048 1048
             } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
1049 1049
 
1050
-                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
1051
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
1050
+                $wpdb->query("RENAME TABLE ".$wpdb->prefix."$table TO ".$table."_ms_bak2"); // rename new table to bak2
1051
+                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$wpdb->prefix."$table"); // rename bak table to new table
1052 1052
 
1053
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1054
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
1053
+                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1054
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table)."</li>";
1055 1055
                 } else {
1056
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1056
+                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
1057 1057
                 }
1058 1058
 
1059 1059
             } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
1060 1060
 
1061
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
1061
+                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename ms_bak table to ms_bak2
1062 1062
 
1063
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1064
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
1063
+                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
1064
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table)."</li>";
1065 1065
                 } else {
1066
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1066
+                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
1067 1067
                 }
1068 1068
 
1069 1069
             }
@@ -1071,54 +1071,54 @@  discard block
 block discarded – undo
1071 1071
         }
1072 1072
 
1073 1073
 
1074
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1075
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
1074
+    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
1075
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name)."</li>";
1076 1076
         $filter_arr['is_error_during_diagnose'] = true;
1077 1077
 
1078 1078
         if ($fix) {
1079 1079
             if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
1080 1080
                 if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
1081
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
1081
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table)."</li>";
1082 1082
                 } else {
1083
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
1083
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table)."</li>";
1084 1084
                 }
1085 1085
 
1086
-            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
1087
-                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
1088
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1086
+            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table") == 0) {// if main table is empty but original is not, delete main and rename original
1087
+                if ($wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."$table")) {
1088
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix.$table)."</li>";
1089 1089
                 } else {
1090
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1090
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix.$table)."</li>";
1091 1091
                 }
1092
-                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1093
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1092
+                if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1093
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
1094 1094
                 } else {
1095
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1095
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
1096 1096
                 }
1097 1097
             } else {// else rename the original table to _ms_bak
1098
-                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1099
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1098
+                if ($wpdb->query("RENAME TABLE $table TO ".$table."_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1099
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table."_ms_bak")."</li>";
1100 1100
                 } else {
1101
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1101
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table."_ms_bak")."</li>";
1102 1102
                 }
1103 1103
             }
1104 1104
         }
1105 1105
 
1106
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1107
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
1106
+    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
1107
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name)."</li>";
1108 1108
         $filter_arr['is_error_during_diagnose'] = true;
1109 1109
 
1110 1110
         if ($fix) {
1111 1111
             // if original table exists but new does not, rename
1112
-            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1113
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1112
+            if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1113
+                $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
1114 1114
             } else {
1115
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1115
+                $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
1116 1116
             }
1117 1117
 
1118 1118
         }
1119 1119
 
1120
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1121
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
1120
+    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
1121
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name)."</li>";
1122 1122
         $filter_arr['is_error_during_diagnose'] = true;
1123 1123
 
1124 1124
         if ($fix) {
@@ -1132,11 +1132,11 @@  discard block
 block discarded – undo
1132 1132
             delete_option('geodir_custom_posts_db_version');
1133 1133
             delete_option('geodir_reviewratings_db_version');
1134 1134
             delete_option('geodiradvancesearch_db_version');
1135
-            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
1135
+            $filter_arr['output_str'] .= "<li>".__('-->TRY: Please refresh page to run table install functions', 'geodirectory')."</li>";
1136 1136
         }
1137 1137
 
1138 1138
     } else {
1139
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
1139
+        $filter_arr['output_str'] .= "<li>".sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name)."</li>";
1140 1140
     }
1141 1141
     return $filter_arr;
1142 1142
 }
@@ -1177,21 +1177,21 @@  discard block
 block discarded – undo
1177 1177
     }
1178 1178
 
1179 1179
     if ($stepped_process) {
1180
-        $sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset );
1181
-        $posts = $wpdb->get_results( $sql );
1180
+        $sql = $wpdb->prepare("SELECT * FROM ".$wpdb->prefix."geodir_".$ptype."_detail LIMIT %d OFFSET %d", $step_max_items, $offset);
1181
+        $posts = $wpdb->get_results($sql);
1182 1182
 
1183 1183
         if (!empty($posts)) {
1184 1184
 
1185 1185
             foreach ($posts as $p) {
1186 1186
                 $p->post_type = $ptype;
1187
-                $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1187
+                $raw_tags = wp_get_object_terms($p->post_id, $p->post_type.'_tags', array('fields' => 'names'));
1188 1188
                 if (empty($raw_tags)) {
1189 1189
                     $post_tags = '';
1190 1190
                 } else {
1191 1191
                     $post_tags = implode(",", $raw_tags);
1192 1192
                 }
1193
-                $tablename = $plugin_prefix . $p->post_type . '_detail';
1194
-                $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1193
+                $tablename = $plugin_prefix.$p->post_type.'_detail';
1194
+                $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1195 1195
 
1196 1196
             }
1197 1197
             if ($step >= $max_step) {
@@ -1207,23 +1207,23 @@  discard block
 block discarded – undo
1207 1207
         if (!empty($all_postypes)) {
1208 1208
             foreach ($all_postypes as $key) {
1209 1209
                 // update each GD CPT
1210
-                $posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail");
1210
+                $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail");
1211 1211
 
1212 1212
                 if (!empty($posts)) {
1213 1213
 
1214 1214
                     foreach ($posts as $p) {
1215 1215
                         $p->post_type = $key;
1216
-                        $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1216
+                        $raw_tags = wp_get_object_terms($p->post_id, $p->post_type.'_tags', array('fields' => 'names'));
1217 1217
                         if (empty($raw_tags)) {
1218 1218
                             $post_tags = '';
1219 1219
                         } else {
1220 1220
                             $post_tags = implode(",", $raw_tags);
1221 1221
                         }
1222
-                        $tablename = $plugin_prefix . $p->post_type . '_detail';
1223
-                        $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1222
+                        $tablename = $plugin_prefix.$p->post_type.'_detail';
1223
+                        $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1224 1224
 
1225 1225
                     }
1226
-                    $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1226
+                    $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
1227 1227
                 }
1228 1228
 
1229 1229
             }
@@ -1234,14 +1234,14 @@  discard block
 block discarded – undo
1234 1234
 
1235 1235
     if ($is_error_during_diagnose) {
1236 1236
         $info_div_class = "geodir_problem_info";
1237
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1237
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1238 1238
     } else {
1239 1239
         $info_div_class = "geodir_noproblem_info";
1240 1240
         $fix_button_txt = '';
1241 1241
     }
1242 1242
 
1243 1243
     if ($stepped_process) {
1244
-        $percent = ($step/$max_step) * 100;
1244
+        $percent = ($step / $max_step) * 100;
1245 1245
         if ($output_str == 'done') {
1246 1246
             echo $output_str;
1247 1247
         } else {
@@ -1284,29 +1284,29 @@  discard block
 block discarded – undo
1284 1284
     if (!empty($all_postypes)) {
1285 1285
         foreach ($all_postypes as $key) {
1286 1286
             // update each GD CTP
1287
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
1287
+            $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d WHERE d.".$key."category='' ");
1288 1288
 
1289 1289
             if (!empty($posts)) {
1290 1290
 
1291 1291
                 foreach ($posts as $p) {
1292 1292
                     $p->post_type = $key;
1293
-                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
1293
+                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type.'category', array('fields' => 'ids'));
1294 1294
 
1295 1295
                     if (empty($raw_cats)) {
1296 1296
                         $post_categories = get_post_meta($p->post_id, 'post_categories', true);
1297 1297
 
1298
-                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1299
-                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1300
-                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1298
+                        if (!empty($post_categories) && !empty($post_categories[$p->post_type.'category'])) {
1299
+                            $post_categories[$p->post_type.'category'] = str_replace("d:", "", $post_categories[$p->post_type.'category']);
1300
+                            foreach (explode(",", $post_categories[$p->post_type.'category']) as $cat_part) {
1301 1301
                                 if (is_numeric($cat_part)) {
1302
-                                    $raw_cats[] = (int)$cat_part;
1302
+                                    $raw_cats[] = (int) $cat_part;
1303 1303
                                 }
1304 1304
                             }
1305 1305
 
1306 1306
                         }
1307 1307
 
1308 1308
                         if (!empty($raw_cats)) {
1309
-                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1309
+                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type.'category');
1310 1310
 
1311 1311
                         }
1312 1312
 
@@ -1316,14 +1316,14 @@  discard block
 block discarded – undo
1316 1316
                     if (empty($raw_cats)) {
1317 1317
                         $post_cats = '';
1318 1318
                     } else {
1319
-                        $post_cats = ',' . implode(",", $raw_cats) . ',';
1319
+                        $post_cats = ','.implode(",", $raw_cats).',';
1320 1320
                     }
1321
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1322
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1321
+                    $tablename = $plugin_prefix.$p->post_type.'_detail';
1322
+                    $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET ".$p->post_type."category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1323 1323
                 }
1324 1324
 
1325 1325
             }
1326
-            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1326
+            $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
1327 1327
 
1328 1328
         }
1329 1329
 
@@ -1331,7 +1331,7 @@  discard block
 block discarded – undo
1331 1331
 
1332 1332
     if ($is_error_during_diagnose) {
1333 1333
         $info_div_class = "geodir_problem_info";
1334
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1334
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1335 1335
     } else {
1336 1336
         $info_div_class = "geodir_noproblem_info";
1337 1337
         $fix_button_txt = '';
@@ -1384,15 +1384,15 @@  discard block
 block discarded – undo
1384 1384
     if (!empty($ver_arr)) {
1385 1385
         foreach ($ver_arr as $key => $val) {
1386 1386
             if (delete_option($val)) {
1387
-                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1387
+                $output_str .= "<li>".$key.__(' Version: Deleted', 'geodirectory')."</li>";
1388 1388
             } else {
1389
-                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1389
+                $output_str .= "<li>".$key.__(' Version: Not Found', 'geodirectory')."</li>";
1390 1390
             }
1391 1391
 
1392 1392
         }
1393 1393
 
1394 1394
         if ($output_str) {
1395
-            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1395
+            $output_str .= "<li><strong>".__(' Upgrade/install scripts will run on next page reload.', 'geodirectory')."</strong></li>";
1396 1396
         }
1397 1397
 
1398 1398
     }
@@ -1429,43 +1429,43 @@  discard block
 block discarded – undo
1429 1429
     $output_str = '';
1430 1430
 
1431 1431
     // check review locations
1432
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
1433
-        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1432
+    if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
1433
+        $output_str .= "<li>".__('Review locations missing or broken', 'geodirectory')."</li>";
1434 1434
         $is_error_during_diagnose = true;
1435 1435
 
1436 1436
         if ($fix) {
1437 1437
             if (geodir_fix_review_location()) {
1438
-                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1438
+                $output_str .= "<li><strong>".__('-->FIXED: Review locations fixed', 'geodirectory')."</strong></li>";
1439 1439
             } else {
1440
-                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1440
+                $output_str .= "<li><strong>".__('-->FAILED: Review locations fix failed', 'geodirectory')."</strong></li>";
1441 1441
             }
1442 1442
         }
1443 1443
 
1444 1444
     } else {
1445
-        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1445
+        $output_str .= "<li>".__('Review locations ok', 'geodirectory')."</li>";
1446 1446
     }
1447 1447
 
1448 1448
     // check review content
1449
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1450
-        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1449
+    if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_content IS NULL")) {
1450
+        $output_str .= "<li>".__('Review content missing or broken', 'geodirectory')."</li>";
1451 1451
         $is_error_during_diagnose = true;
1452 1452
 
1453 1453
         if ($fix) {
1454 1454
             if (geodir_fix_review_content()) {
1455
-                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1455
+                $output_str .= "<li><strong>".__('-->FIXED: Review content fixed', 'geodirectory')."</strong></li>";
1456 1456
             } else {
1457
-                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1457
+                $output_str .= "<li><strong>".__('-->FAILED: Review content fix failed', 'geodirectory')."</strong></li>";
1458 1458
             }
1459 1459
         }
1460 1460
 
1461 1461
     } else {
1462
-        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1462
+        $output_str .= "<li>".__('Review content ok', 'geodirectory')."</li>";
1463 1463
     }
1464 1464
 
1465 1465
 
1466 1466
     if ($is_error_during_diagnose) {
1467 1467
         $info_div_class = "geodir_problem_info";
1468
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1468
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1469 1469
     } else {
1470 1470
         $info_div_class = "geodir_noproblem_info";
1471 1471
         $fix_button_txt = '';
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
 
1530 1530
     if ($is_error_during_diagnose) {
1531 1531
         $info_div_class = "geodir_problem_info";
1532
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1532
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1533 1533
     } else {
1534 1534
         $info_div_class = "geodir_noproblem_info";
1535 1535
         $fix_button_txt = '';
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
     else {
1564 1564
         $page_found = $wpdb->get_var(
1565 1565
             $wpdb->prepare(
1566
-                "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1566
+                "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;",
1567 1567
                 array($slug)
1568 1568
             )
1569 1569
         );
@@ -1609,18 +1609,18 @@  discard block
 block discarded – undo
1609 1609
     //////////////////////////////////
1610 1610
     $option_value = get_option('geodir_home_page');
1611 1611
     $page = get_post($option_value);
1612
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1612
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1613 1613
 
1614
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1615
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1614
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1615
+        $output_str .= "<li>".__('GD Home page exists with proper setting.', 'geodirectory')."</li>";
1616 1616
     else {
1617 1617
         $is_error_during_diagnose = true;
1618
-        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1618
+        $output_str .= "<li><strong>".__('GD Home page is missing.', 'geodirectory')."</strong></li>";
1619 1619
         if ($fix) {
1620 1620
             if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1621
-                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1621
+                $output_str .= "<li><strong>".__('-->FIXED: GD Home page fixed', 'geodirectory')."</strong></li>";
1622 1622
             } else {
1623
-                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1623
+                $output_str .= "<li><strong>".__('-->FAILED: GD Home page fix failed', 'geodirectory')."</strong></li>";
1624 1624
             }
1625 1625
         }
1626 1626
     }
@@ -1634,18 +1634,18 @@  discard block
 block discarded – undo
1634 1634
     //////////////////////////////////
1635 1635
     $option_value = get_option('geodir_add_listing_page');
1636 1636
     $page = get_post($option_value);
1637
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1637
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1638 1638
 
1639
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1640
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1639
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1640
+        $output_str .= "<li>".__('Add Listing page exists with proper setting.', 'geodirectory')."</li>";
1641 1641
     else {
1642 1642
         $is_error_during_diagnose = true;
1643
-        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1643
+        $output_str .= "<li><strong>".__('Add Listing page is missing.', 'geodirectory')."</strong></li>";
1644 1644
         if ($fix) {
1645 1645
             if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1646
-                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1646
+                $output_str .= "<li><strong>".__('-->FIXED: Add Listing page fixed', 'geodirectory')."</strong></li>";
1647 1647
             } else {
1648
-                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1648
+                $output_str .= "<li><strong>".__('-->FAILED: Add Listing page fix failed', 'geodirectory')."</strong></li>";
1649 1649
             }
1650 1650
         }
1651 1651
     }
@@ -1660,18 +1660,18 @@  discard block
 block discarded – undo
1660 1660
     //////////////////////////////////
1661 1661
     $option_value = get_option('geodir_preview_page');
1662 1662
     $page = get_post($option_value);
1663
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1663
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1664 1664
 
1665
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1666
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1665
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1666
+        $output_str .= "<li>".__('Listing Preview page exists with proper setting.', 'geodirectory')."</li>";
1667 1667
     else {
1668 1668
         $is_error_during_diagnose = true;
1669
-        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1669
+        $output_str .= "<li><strong>".__('Listing Preview page is missing.', 'geodirectory')."</strong></li>";
1670 1670
         if ($fix) {
1671 1671
             if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1672
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1672
+                $output_str .= "<li><strong>".__('-->FIXED: Listing Preview page fixed', 'geodirectory')."</strong></li>";
1673 1673
             } else {
1674
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1674
+                $output_str .= "<li><strong>".__('-->FAILED: Listing Preview page fix failed', 'geodirectory')."</strong></li>";
1675 1675
             }
1676 1676
         }
1677 1677
     }
@@ -1685,18 +1685,18 @@  discard block
 block discarded – undo
1685 1685
     //////////////////////////////////
1686 1686
     $option_value = get_option('geodir_success_page');
1687 1687
     $page = get_post($option_value);
1688
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1688
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1689 1689
 
1690
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1691
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1690
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1691
+        $output_str .= "<li>".__('Listing Success page exists with proper setting.', 'geodirectory')."</li>";
1692 1692
     else {
1693 1693
         $is_error_during_diagnose = true;
1694
-        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1694
+        $output_str .= "<li><strong>".__('Listing Success page is missing.', 'geodirectory')."</strong></li>";
1695 1695
         if ($fix) {
1696 1696
             if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1697
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1697
+                $output_str .= "<li><strong>".__('-->FIXED: Listing Success page fixed', 'geodirectory')."</strong></li>";
1698 1698
             } else {
1699
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1699
+                $output_str .= "<li><strong>".__('-->FAILED: Listing Success page fix failed', 'geodirectory')."</strong></li>";
1700 1700
             }
1701 1701
         }
1702 1702
     }
@@ -1710,18 +1710,18 @@  discard block
 block discarded – undo
1710 1710
     //////////////////////////////////
1711 1711
     $option_value = get_option('geodir_info_page');
1712 1712
     $page = get_post($option_value);
1713
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1713
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1714 1714
 
1715
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1716
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1715
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1716
+        $output_str .= "<li>".__('Info page exists with proper setting.', 'geodirectory')."</li>";
1717 1717
     else {
1718 1718
         $is_error_during_diagnose = true;
1719
-        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1719
+        $output_str .= "<li><strong>".__('Info page is missing.', 'geodirectory')."</strong></li>";
1720 1720
         if ($fix) {
1721 1721
             if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1722
-                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1722
+                $output_str .= "<li><strong>".__('-->FIXED: Info page fixed', 'geodirectory')."</strong></li>";
1723 1723
             } else {
1724
-                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1724
+                $output_str .= "<li><strong>".__('-->FAILED: Info page fix failed', 'geodirectory')."</strong></li>";
1725 1725
             }
1726 1726
         }
1727 1727
     }
@@ -1735,18 +1735,18 @@  discard block
 block discarded – undo
1735 1735
     //////////////////////////////////
1736 1736
     $option_value = get_option('geodir_login_page');
1737 1737
     $page = get_post($option_value);
1738
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1738
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1739 1739
 
1740
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1741
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1740
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1741
+        $output_str .= "<li>".__('Login page exists with proper setting.', 'geodirectory')."</li>";
1742 1742
     else {
1743 1743
         $is_error_during_diagnose = true;
1744
-        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1744
+        $output_str .= "<li><strong>".__('Login page is missing.', 'geodirectory')."</strong></li>";
1745 1745
         if ($fix) {
1746 1746
             if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1747
-                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1747
+                $output_str .= "<li><strong>".__('-->FIXED: Login page fixed', 'geodirectory')."</strong></li>";
1748 1748
             } else {
1749
-                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1749
+                $output_str .= "<li><strong>".__('-->FAILED: Login page fix failed', 'geodirectory')."</strong></li>";
1750 1750
             }
1751 1751
         }
1752 1752
     }
@@ -1760,18 +1760,18 @@  discard block
 block discarded – undo
1760 1760
     //////////////////////////////////
1761 1761
     $option_value = get_option('geodir_location_page');
1762 1762
     $page = get_post($option_value);
1763
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1763
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1764 1764
 
1765
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1766
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1765
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1766
+        $output_str .= "<li>".__('Location page exists with proper setting.', 'geodirectory')."</li>";
1767 1767
     else {
1768 1768
         $is_error_during_diagnose = true;
1769
-        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1769
+        $output_str .= "<li><strong>".__('Location page is missing.', 'geodirectory')."</strong></li>";
1770 1770
         if ($fix) {
1771 1771
             if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1772
-                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1772
+                $output_str .= "<li><strong>".__('-->FIXED: Location page fixed', 'geodirectory')."</strong></li>";
1773 1773
             } else {
1774
-                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1774
+                $output_str .= "<li><strong>".__('-->FAILED: Location page fix failed', 'geodirectory')."</strong></li>";
1775 1775
             }
1776 1776
         }
1777 1777
     }
@@ -1780,13 +1780,13 @@  discard block
 block discarded – undo
1780 1780
     /* Diagnose Location Page Ends */
1781 1781
     ////////////////////////////////
1782 1782
 
1783
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1783
+    $page_chk_arr = array('output_str'=>$output_str, 'is_error_during_diagnose'=>$is_error_during_diagnose);
1784 1784
     /**
1785 1785
      * This action is called at the end of the GD Tools page check function.
1786 1786
      *
1787 1787
      * @since 1.5.2
1788 1788
      */
1789
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1789
+    $page_chk_arr = apply_filters('geodir_diagnose_default_pages', $page_chk_arr);
1790 1790
 
1791 1791
     $output_str = $page_chk_arr['output_str'];
1792 1792
     $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
@@ -1796,7 +1796,7 @@  discard block
 block discarded – undo
1796 1796
             flush_rewrite_rules();
1797 1797
         }
1798 1798
         $info_div_class = "geodir_problem_info";
1799
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1799
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1800 1800
     } else {
1801 1801
         $info_div_class = "geodir_noproblem_info";
1802 1802
         $fix_button_txt = '';
@@ -1824,10 +1824,10 @@  discard block
 block discarded – undo
1824 1824
     $fix_button_txt = '';
1825 1825
 
1826 1826
     if ($is_error_during_diagnose) {
1827
-        $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
1827
+        $output_str .= "<li>".__('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory').' '.geodir_plugin_path().'/db-language.php'."</li>";
1828 1828
 		$info_div_class = "geodir_problem_info";
1829 1829
     } else {
1830
-        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1830
+        $output_str .= "<li>".__('Load custom fields in to file for translation: ok', 'geodirectory')."</li>";
1831 1831
 		$info_div_class = "geodir_noproblem_info";
1832 1832
         $fix_button_txt = '';
1833 1833
     }
@@ -1869,17 +1869,17 @@  discard block
 block discarded – undo
1869 1869
     global $wpdb, $wp_query, $plugin_prefix;
1870 1870
 
1871 1871
     if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
1872
-        $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1872
+        $table = $plugin_prefix.$wp_query->query_vars['post_type'].'_detail';
1873 1873
 
1874
-        $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1874
+        $join = $clauses['join'].' INNER JOIN '.$table.' AS gd_posts ON (gd_posts.post_id = '.$wpdb->posts.'.ID)';
1875 1875
         $clauses['join'] = $join;
1876 1876
 
1877
-        $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1877
+        $fields = $clauses['fields'] != '' ? $clauses['fields'].', ' : '';
1878 1878
         $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire';
1879 1879
         $clauses['fields'] = $fields;
1880 1880
 
1881 1881
         $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1882
-        $orderby = 'gd_expire ' . $order;
1882
+        $orderby = 'gd_expire '.$order;
1883 1883
         $clauses['orderby'] = $orderby;
1884 1884
     }
1885 1885
     return $clauses;
@@ -1922,7 +1922,7 @@  discard block
 block discarded – undo
1922 1922
         global $current_user;
1923 1923
         $upload_dir = wp_upload_dir();
1924 1924
 
1925
-        $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1925
+        $file = $upload_dir['path'].'/temp_'.$current_user->data->ID.'/geodir_tmp.csv';
1926 1926
         $handle = fopen($file, 'w');
1927 1927
 
1928 1928
         fwrite($handle, $input);
@@ -1967,7 +1967,7 @@  discard block
 block discarded – undo
1967 1967
     $uploads_dir = $uploads['path'];
1968 1968
     $image_name_arr = explode('/', $filename);
1969 1969
     $filename = end($image_name_arr);
1970
-    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1970
+    $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename;
1971 1971
     $return = array();
1972 1972
     $return['file'] = $uploadedFile;
1973 1973
     $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
@@ -1984,8 +1984,8 @@  discard block
 block discarded – undo
1984 1984
 
1985 1985
                 if (($handle = fopen($target_path, "r")) !== FALSE) {
1986 1986
                     while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1987
-                        if(is_array($data) && !empty($data)) {
1988
-                            $file[] = '"' . implode('","', $data) . '"';
1987
+                        if (is_array($data) && !empty($data)) {
1988
+                            $file[] = '"'.implode('","', $data).'"';
1989 1989
                         }
1990 1990
                     }
1991 1991
                     fclose($handle);
@@ -2102,10 +2102,10 @@  discard block
 block discarded – undo
2102 2102
                     $tag_arr = explode(',', $post_tags);
2103 2103
                 }
2104 2104
 
2105
-                $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
2105
+                $table = $plugin_prefix.$buffer[5].'_detail'; // check table in database
2106 2106
 
2107 2107
                 $error = '';
2108
-                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
2108
+                if ($wpdb->get_var("SHOW TABLES LIKE '".$table."'") != $table) {
2109 2109
                     $invalid_post_type++;
2110 2110
                     continue;
2111 2111
                 }
@@ -2131,7 +2131,7 @@  discard block
 block discarded – undo
2131 2131
                             if ($buffer[$c] != '0' && $buffer[$c] != '') {
2132 2132
                                 $submitdata = date('Y-m-d');
2133 2133
 
2134
-                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
2134
+                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata."+".addslashes($buffer[$c])." days"));
2135 2135
                             } else {
2136 2136
                                 $gd_post_info['expire_date'] = 'Never';
2137 2137
                             }
@@ -2159,7 +2159,7 @@  discard block
 block discarded – undo
2159 2159
 						
2160 2160
 						// Post status
2161 2161
 						if ($customKeyarray[$c] == 'post_status') {
2162
-                            $post_status = sanitize_key( $buffer[$c] );
2162
+                            $post_status = sanitize_key($buffer[$c]);
2163 2163
                         }
2164 2164
                     }
2165 2165
 
@@ -2177,8 +2177,8 @@  discard block
 block discarded – undo
2177 2177
 					
2178 2178
 					// Default post status
2179 2179
 					$default_status = 'publish';
2180
-					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
2181
-					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
2180
+					$post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
2181
+					$post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
2182 2182
 
2183 2183
                     $my_post['post_title'] = $post_title;
2184 2184
                     $my_post['post_content'] = $post_desc;
@@ -2222,7 +2222,7 @@  discard block
 block discarded – undo
2222 2222
                     $payment_info = array();
2223 2223
                     $package_info = array();
2224 2224
 
2225
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2225
+                    $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]);
2226 2226
                     $package_id = '';
2227 2227
                     if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2228 2228
                         $package_id = $gd_post_info['package_id'];
@@ -2232,7 +2232,7 @@  discard block
 block discarded – undo
2232 2232
                         $payment_info['package_id'] = $package_info['pid'];
2233 2233
 
2234 2234
                         if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2235
-                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2235
+                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+".$package_info['alive_days']." days"));
2236 2236
                         } else {
2237 2237
                             $payment_info['expire_date'] = 'Never';
2238 2238
                         }
@@ -2244,7 +2244,7 @@  discard block
 block discarded – undo
2244 2244
 
2245 2245
                     $post_type = get_post_type($last_postid);
2246 2246
 
2247
-                    $table = $plugin_prefix . $post_type . '_detail';
2247
+                    $table = $plugin_prefix.$post_type.'_detail';
2248 2248
 
2249 2249
                     geodir_save_post_info($last_postid, $gd_post_info);
2250 2250
 
@@ -2265,7 +2265,7 @@  discard block
 block discarded – undo
2265 2265
                             $attachment['post_id'] = $last_postid;
2266 2266
                             $attachment['title'] = $img_name_arr[0];
2267 2267
                             $attachment['content'] = '';
2268
-                            $attachment['file'] = $sub_dir . '/' . $image_name;
2268
+                            $attachment['file'] = $sub_dir.'/'.$image_name;
2269 2269
                             $attachment['mime_type'] = $uploaded_file_type;
2270 2270
                             $attachment['menu_order'] = $menu_order;
2271 2271
                             $attachment['is_featured'] = 0;
@@ -2274,15 +2274,15 @@  discard block
 block discarded – undo
2274 2274
 
2275 2275
                             foreach ($attachment as $key => $val) {
2276 2276
                                 if ($val != '')
2277
-                                    $attachment_set .= $key . " = '" . $val . "', ";
2277
+                                    $attachment_set .= $key." = '".$val."', ";
2278 2278
                             }
2279 2279
                             $attachment_set = trim($attachment_set, ", ");
2280 2280
 
2281
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2281
+                            $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
2282 2282
 
2283 2283
                             if ($menu_order == 1) {
2284 2284
                                 $post_type = get_post_type($last_postid);
2285
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2285
+                                $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($sub_dir.'/'.$image_name, $last_postid)));
2286 2286
                             }
2287 2287
                             $menu_order++;
2288 2288
                         }
@@ -2323,11 +2323,11 @@  discard block
 block discarded – undo
2323 2323
 }
2324 2324
 
2325 2325
 // Add the tab in left sidebar menu fro import & export page.
2326
-add_filter( 'geodir_settings_tabs_array', 'geodir_import_export_tab', 94 );
2326
+add_filter('geodir_settings_tabs_array', 'geodir_import_export_tab', 94);
2327 2327
 
2328 2328
 // Handle ajax request for import/export.
2329
-add_action( 'wp_ajax_geodir_import_export', 'geodir_ajax_import_export' );
2330
-add_action( 'wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export' );
2329
+add_action('wp_ajax_geodir_import_export', 'geodir_ajax_import_export');
2330
+add_action('wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export');
2331 2331
 
2332 2332
 
2333 2333
 /**
@@ -2338,40 +2338,40 @@  discard block
 block discarded – undo
2338 2338
  * @param $post_id int $post_id The post ID of the post being saved.
2339 2339
  * @param $post object $post The post object of the post being saved.
2340 2340
  */
2341
-function geodir_update_location_prefix($post_id,$post){
2342
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2343
-        update_option('geodir_location_prefix',$post->post_name);
2341
+function geodir_update_location_prefix($post_id, $post) {
2342
+    if ($post->post_type == 'page' && $post->post_name && $post_id == get_option('geodir_location_page')) {
2343
+        update_option('geodir_location_prefix', $post->post_name);
2344 2344
     }
2345 2345
 
2346 2346
 }
2347 2347
 
2348
-add_action('save_post', 'geodir_update_location_prefix',10,2);
2348
+add_action('save_post', 'geodir_update_location_prefix', 10, 2);
2349 2349
 
2350
-add_action( 'wp_ajax_geodir_ga_callback', 'geodir_ga_callback' );
2350
+add_action('wp_ajax_geodir_ga_callback', 'geodir_ga_callback');
2351 2351
 
2352
-function geodir_ga_callback(){
2352
+function geodir_ga_callback() {
2353 2353
 
2354
-if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2354
+if (isset($_REQUEST['code']) && $_REQUEST['code']) {
2355 2355
     $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2356 2356
     $code = "code=".$_REQUEST['code'];
2357 2357
     $grant_type = "&grant_type=authorization_code";
2358
-    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2358
+    $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback";
2359 2359
     $client_id = "&client_id=".get_option('geodir_ga_client_id');
2360 2360
     $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2361 2361
 
2362
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2362
+    $auth_url = $oAuthURL.$code.$redirect_uri.$grant_type.$client_id.$client_secret;
2363 2363
 
2364 2364
     $response = wp_remote_post($auth_url, array('timeout' => 15));
2365 2365
 
2366 2366
     //print_r($response);
2367 2367
 
2368
-    $error_msg =  __('Something went wrong','geodirectory');
2369
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2368
+    $error_msg = __('Something went wrong', 'geodirectory');
2369
+    if (!empty($response['response']['code']) && $response['response']['code'] == 200) {
2370 2370
 
2371 2371
         $parts = json_decode($response['body']);
2372 2372
         //print_r($parts);
2373
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2374
-        else{
2373
+        if (!isset($parts->access_token)) {echo $error_msg." - #1"; exit; }
2374
+        else {
2375 2375
 
2376 2376
             update_option('gd_ga_access_token', $parts->access_token);
2377 2377
             update_option('gd_ga_refresh_token', $parts->refresh_token);
@@ -2380,18 +2380,18 @@  discard block
 block discarded – undo
2380 2380
 
2381 2381
 
2382 2382
     }
2383
-    elseif(!empty($response['response']['code'])) {
2383
+    elseif (!empty($response['response']['code'])) {
2384 2384
         $parts = json_decode($response['body']);
2385 2385
 
2386
-        if(isset($parts->error)){
2387
-            echo $parts->error.": ".$parts->error_description;exit;
2388
-        }else{
2389
-            echo $error_msg." - #2";exit;
2386
+        if (isset($parts->error)) {
2387
+            echo $parts->error.": ".$parts->error_description; exit;
2388
+        } else {
2389
+            echo $error_msg." - #2"; exit;
2390 2390
         }
2391 2391
 
2392
-    }else{
2392
+    } else {
2393 2393
 
2394
-        echo $error_msg." - #3";exit;
2394
+        echo $error_msg." - #3"; exit;
2395 2395
 
2396 2396
     }
2397 2397
 }
@@ -2413,7 +2413,7 @@  discard block
 block discarded – undo
2413 2413
 function geodir_uninstall_settings($general_settings) {
2414 2414
     $settings   = array();
2415 2415
     $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
2416
-    $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
2416
+    $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory'));
2417 2417
     
2418 2418
     $plugins    = get_plugins();
2419 2419
     $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
@@ -2425,7 +2425,7 @@  discard block
 block discarded – undo
2425 2425
             if (in_array($plugin_name, $un_plugins)) {
2426 2426
                 $settings[] = array(
2427 2427
                     'type' => 'checkbox',
2428
-                    'id' => 'geodir_un_' . $plugin_name,
2428
+                    'id' => 'geodir_un_'.$plugin_name,
2429 2429
                     'name' => $data['Name'],
2430 2430
                     'desc' => __('Remove all data when deleted?', 'geodirectory'),
2431 2431
                     'std' => '0'
@@ -2459,7 +2459,7 @@  discard block
 block discarded – undo
2459 2459
  * @since 1.6.9
2460 2460
  */
2461 2461
 function geodir_uninstall_settings_desc() {
2462
-    echo '<p class="gd-un-settings-desc">' . __('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory') . '</p>';
2462
+    echo '<p class="gd-un-settings-desc">'.__('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory').'</p>';
2463 2463
 }
2464 2464
 add_action('geodir_settings_uninstall_settings_main_start', 'geodir_uninstall_settings_desc');
2465 2465
 
@@ -2523,12 +2523,12 @@  discard block
 block discarded – undo
2523 2523
 
2524 2524
 
2525 2525
     if ($delete) {
2526
-            $output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>";
2526
+            $output_str .= "<li><strong>".__('Table dropped, refresh page to reinstall.', 'geodirectory')."</strong></li>";
2527 2527
         ob_start();
2528 2528
         geodir_diagnose_version_clear();
2529 2529
         ob_end_clean();
2530
-    }else{
2531
-        $output_str .= "<li><strong>" . __('Something went wrong.', 'geodirectory') . "</strong></li>";
2530
+    } else {
2531
+        $output_str .= "<li><strong>".__('Something went wrong.', 'geodirectory')."</strong></li>";
2532 2532
     }
2533 2533
 
2534 2534
     if ($is_error_during_diagnose) {
Please login to merge, or discard this patch.
Braces   +61 added lines, -54 removed lines patch added patch discarded remove patch
@@ -24,8 +24,11 @@  discard block
 block discarded – undo
24 24
             global $current_tab;
25 25
             geodir_redirect_to_admin_panel_on_installed();
26 26
             $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
-            if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
-                geodir_handle_option_form_submit($current_tab); // located in admin function.php
27
+            if (!(isset($_REQUEST['action']))) {
28
+            	// this will avoid Ajax requests
29
+                geodir_handle_option_form_submit($current_tab);
30
+            }
31
+            // located in admin function.php
29 32
             /**
30 33
              * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31 34
              *
@@ -324,8 +327,9 @@  discard block
 block discarded – undo
324 327
     if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
325 328
 
326 329
         foreach ($notification as $key => $value) {
327
-            if ($value['type'] == 'textarea')
328
-                $notification[$key]['type'] = 'editor';
330
+            if ($value['type'] == 'textarea') {
331
+                            $notification[$key]['type'] = 'editor';
332
+            }
329 333
         }
330 334
 
331 335
     }
@@ -350,8 +354,9 @@  discard block
 block discarded – undo
350 354
     if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
351 355
 
352 356
         foreach ($design_setting as $key => $value) {
353
-            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
354
-                $design_setting[$key]['type'] = 'editor';
357
+            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') {
358
+                            $design_setting[$key]['type'] = 'editor';
359
+            }
355 360
         }
356 361
 
357 362
     }
@@ -470,9 +475,9 @@  discard block
 block discarded – undo
470 475
                    class="gd-draggable-form-items  gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);">
471 476
                     <?php if (isset($val['field_icon']) && strpos($val['field_icon'], 'fa fa-') !== false) {
472 477
                         echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>';
473
-                    }elseif(isset($val['field_icon']) && $val['field_icon'] ){
478
+                    } elseif(isset($val['field_icon']) && $val['field_icon'] ){
474 479
                         echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>';
475
-                    }else{
480
+                    } else{
476 481
                         echo '<i class="fa fa-cog" aria-hidden="true"></i>';
477 482
                     }?>
478 483
                     <?php echo $val['site_title'];?>
@@ -702,9 +707,9 @@  discard block
 block discarded – undo
702 707
         <?php
703 708
         if($type=='predefined'){
704 709
             $cfs = geodir_custom_fields_predefined($listing_type);
705
-        }elseif($type=='custom'){
710
+        } elseif($type=='custom'){
706 711
             $cfs = geodir_custom_fields_custom($listing_type);
707
-        }else{
712
+        } else{
708 713
             $cfs = geodir_custom_fields($listing_type);
709 714
             ?>
710 715
             <ul class="full gd-cf-tooltip-wrap">
@@ -759,7 +764,7 @@  discard block
 block discarded – undo
759 764
             </li>
760 765
             <?php
761 766
         }
762
-    }else{
767
+    } else{
763 768
         _e('There are no custom fields here yet.', 'geodirectory');
764 769
     }
765 770
         ?>
@@ -956,8 +961,9 @@  discard block
 block discarded – undo
956 961
 
957 962
     if (!get_option('geodir_remove_unnecessary_fields')) {
958 963
 
959
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
960
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
964
+        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) {
965
+                    $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
966
+        }
961 967
 
962 968
         update_option('geodir_remove_unnecessary_fields', '1');
963 969
 
@@ -993,8 +999,9 @@  discard block
 block discarded – undo
993 999
                 break;
994 1000
 
995 1001
             case 'diagnosis-fix' :
996
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
997
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
1002
+                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
1003
+                                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
1004
+                }
998 1005
                 call_user_func('geodir_diagnose_' . $diagnose_this);
999 1006
                 exit();
1000 1007
                 break;
@@ -1609,11 +1616,11 @@  discard block
 block discarded – undo
1609 1616
     //////////////////////////////////
1610 1617
     $option_value = get_option('geodir_home_page');
1611 1618
     $page = get_post($option_value);
1612
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1619
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1613 1620
 
1614
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1615
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1616
-    else {
1621
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1622
+            $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1623
+    } else {
1617 1624
         $is_error_during_diagnose = true;
1618 1625
         $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1619 1626
         if ($fix) {
@@ -1634,11 +1641,11 @@  discard block
 block discarded – undo
1634 1641
     //////////////////////////////////
1635 1642
     $option_value = get_option('geodir_add_listing_page');
1636 1643
     $page = get_post($option_value);
1637
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1644
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1638 1645
 
1639
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1640
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1641
-    else {
1646
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1647
+            $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1648
+    } else {
1642 1649
         $is_error_during_diagnose = true;
1643 1650
         $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1644 1651
         if ($fix) {
@@ -1660,11 +1667,11 @@  discard block
 block discarded – undo
1660 1667
     //////////////////////////////////
1661 1668
     $option_value = get_option('geodir_preview_page');
1662 1669
     $page = get_post($option_value);
1663
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1670
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1664 1671
 
1665
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1666
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1667
-    else {
1672
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1673
+            $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1674
+    } else {
1668 1675
         $is_error_during_diagnose = true;
1669 1676
         $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1670 1677
         if ($fix) {
@@ -1685,11 +1692,11 @@  discard block
 block discarded – undo
1685 1692
     //////////////////////////////////
1686 1693
     $option_value = get_option('geodir_success_page');
1687 1694
     $page = get_post($option_value);
1688
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1695
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1689 1696
 
1690
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1691
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1692
-    else {
1697
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1698
+            $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1699
+    } else {
1693 1700
         $is_error_during_diagnose = true;
1694 1701
         $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1695 1702
         if ($fix) {
@@ -1710,11 +1717,11 @@  discard block
 block discarded – undo
1710 1717
     //////////////////////////////////
1711 1718
     $option_value = get_option('geodir_info_page');
1712 1719
     $page = get_post($option_value);
1713
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1720
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1714 1721
 
1715
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1716
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1717
-    else {
1722
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1723
+            $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1724
+    } else {
1718 1725
         $is_error_during_diagnose = true;
1719 1726
         $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1720 1727
         if ($fix) {
@@ -1735,11 +1742,11 @@  discard block
 block discarded – undo
1735 1742
     //////////////////////////////////
1736 1743
     $option_value = get_option('geodir_login_page');
1737 1744
     $page = get_post($option_value);
1738
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1745
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1739 1746
 
1740
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1741
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1742
-    else {
1747
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1748
+            $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1749
+    } else {
1743 1750
         $is_error_during_diagnose = true;
1744 1751
         $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1745 1752
         if ($fix) {
@@ -1760,11 +1767,11 @@  discard block
 block discarded – undo
1760 1767
     //////////////////////////////////
1761 1768
     $option_value = get_option('geodir_location_page');
1762 1769
     $page = get_post($option_value);
1763
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1770
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1764 1771
 
1765
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1766
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1767
-    else {
1772
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1773
+            $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1774
+    } else {
1768 1775
         $is_error_during_diagnose = true;
1769 1776
         $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1770 1777
         if ($fix) {
@@ -2209,8 +2216,9 @@  discard block
 block discarded – undo
2209 2216
                             );
2210 2217
 
2211 2218
                             $post_location_info = $request_info['post_location'];
2212
-                            if ($location_id = geodir_add_new_location($post_location_info))
2213
-                                $post_location_id = $location_id;
2219
+                            if ($location_id = geodir_add_new_location($post_location_info)) {
2220
+                                                            $post_location_id = $location_id;
2221
+                            }
2214 2222
                         } else {
2215 2223
                             $post_location_id = 0;
2216 2224
                         }
@@ -2273,8 +2281,9 @@  discard block
 block discarded – undo
2273 2281
                             $attachment_set = '';
2274 2282
 
2275 2283
                             foreach ($attachment as $key => $val) {
2276
-                                if ($val != '')
2277
-                                    $attachment_set .= $key . " = '" . $val . "', ";
2284
+                                if ($val != '') {
2285
+                                                                    $attachment_set .= $key . " = '" . $val . "', ";
2286
+                                }
2278 2287
                             }
2279 2288
                             $attachment_set = trim($attachment_set, ", ");
2280 2289
 
@@ -2370,8 +2379,7 @@  discard block
 block discarded – undo
2370 2379
 
2371 2380
         $parts = json_decode($response['body']);
2372 2381
         //print_r($parts);
2373
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2374
-        else{
2382
+        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} else{
2375 2383
 
2376 2384
             update_option('gd_ga_access_token', $parts->access_token);
2377 2385
             update_option('gd_ga_refresh_token', $parts->refresh_token);
@@ -2379,17 +2387,16 @@  discard block
 block discarded – undo
2379 2387
         }
2380 2388
 
2381 2389
 
2382
-    }
2383
-    elseif(!empty($response['response']['code'])) {
2390
+    } elseif(!empty($response['response']['code'])) {
2384 2391
         $parts = json_decode($response['body']);
2385 2392
 
2386 2393
         if(isset($parts->error)){
2387 2394
             echo $parts->error.": ".$parts->error_description;exit;
2388
-        }else{
2395
+        } else{
2389 2396
             echo $error_msg." - #2";exit;
2390 2397
         }
2391 2398
 
2392
-    }else{
2399
+    } else{
2393 2400
 
2394 2401
         echo $error_msg." - #3";exit;
2395 2402
 
@@ -2527,7 +2534,7 @@  discard block
 block discarded – undo
2527 2534
         ob_start();
2528 2535
         geodir_diagnose_version_clear();
2529 2536
         ob_end_clean();
2530
-    }else{
2537
+    } else{
2531 2538
         $output_str .= "<li><strong>" . __('Something went wrong.', 'geodirectory') . "</strong></li>";
2532 2539
     }
2533 2540
 
Please login to merge, or discard this patch.