Test Failed
Push — master ( 305a97...c65ca2 )
by Stiofan
11:12
created
geodirectory_hooks_actions.php 1 patch
Indentation   +1078 added lines, -1078 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  */
20 20
 function geodir_get_ajax_url()
21 21
 {
22
-    return admin_url('admin-ajax.php?action=geodir_ajax_action');
22
+	return admin_url('admin-ajax.php?action=geodir_ajax_action');
23 23
 }
24 24
 
25 25
 /////////////////////
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 add_filter('query_vars', 'geodir_add_geodir_page_var');
88 88
 add_action('wp', 'geodir_add_page_id_in_query_var'); // problem fix in wordpress 3.8
89 89
 if (get_option('permalink_structure') != '')
90
-    add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
90
+	add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
91 91
 
92 92
 add_filter('parse_query', 'geodir_modified_query');
93 93
 
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
 /* POST AND LOOP ACTIONS */
155 155
 ////////////////////////
156 156
 if (!is_admin()) {
157
-    add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtural page from everywhere
158
-    add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100);
159
-    /** Exclude Virtual Pages From Pages List **/
160
-    add_action('pre_get_posts', 'set_listing_request', 0);
161
-    add_action('pre_get_posts', 'geodir_listing_loop_filter', 1);
162
-    add_filter('excerpt_more', 'geodir_excerpt_more', 1000);
163
-    add_filter('excerpt_length', 'geodir_excerpt_length', 1000);
164
-    add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter
157
+	add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtural page from everywhere
158
+	add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100);
159
+	/** Exclude Virtual Pages From Pages List **/
160
+	add_action('pre_get_posts', 'set_listing_request', 0);
161
+	add_action('pre_get_posts', 'geodir_listing_loop_filter', 1);
162
+	add_filter('excerpt_more', 'geodir_excerpt_more', 1000);
163
+	add_filter('excerpt_length', 'geodir_excerpt_length', 1000);
164
+	add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter
165 165
 }
166 166
 
167 167
 
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
  */
223 223
 function geodir_unset_prev_theme_nav_location($newname)
224 224
 {
225
-    $geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname);
226
-    if ($geodir_theme_location) {
227
-        update_option('geodir_theme_location_nav', $geodir_theme_location);
228
-    } else {
229
-        update_option('geodir_theme_location_nav', '');
230
-    }
225
+	$geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname);
226
+	if ($geodir_theme_location) {
227
+		update_option('geodir_theme_location_nav', $geodir_theme_location);
228
+	} else {
229
+		update_option('geodir_theme_location_nav', '');
230
+	}
231 231
 }
232 232
 
233 233
 /// add action for theme switch to blank previous theme navigation location setting
@@ -248,32 +248,32 @@  discard block
 block discarded – undo
248 248
  */
249 249
 function geodir_add_post_filters()
250 250
 {
251
-    /**
252
-     * Contains all function for filtering listing.
253
-     *
254
-     * @since 1.0.0
255
-     * @package GeoDirectory
256
-     */
257
-    include_once('geodirectory-functions/listing_filters.php');
251
+	/**
252
+	 * Contains all function for filtering listing.
253
+	 *
254
+	 * @since 1.0.0
255
+	 * @package GeoDirectory
256
+	 */
257
+	include_once('geodirectory-functions/listing_filters.php');
258 258
 }
259 259
 
260 260
 
261 261
 if (!function_exists('geodir_init_defaults')) {
262
-    /**
263
-     * Calls the function to register the GeoDirectory default CPT and taxonomies.
264
-     *
265
-     * @since 1.0.0
266
-     * @package GeoDirectory
267
-     */
268
-    function geodir_init_defaults()
269
-    {
270
-        if (function_exists('geodir_register_defaults')) {
262
+	/**
263
+	 * Calls the function to register the GeoDirectory default CPT and taxonomies.
264
+	 *
265
+	 * @since 1.0.0
266
+	 * @package GeoDirectory
267
+	 */
268
+	function geodir_init_defaults()
269
+	{
270
+		if (function_exists('geodir_register_defaults')) {
271 271
 
272
-            geodir_register_defaults();
272
+			geodir_register_defaults();
273 273
 
274
-        }
274
+		}
275 275
 
276
-    }
276
+	}
277 277
 }
278 278
 
279 279
 
@@ -295,26 +295,26 @@  discard block
 block discarded – undo
295 295
 // CALLED ON 'sidebars_widgets' FILTER
296 296
 
297 297
 if (!function_exists('geodir_restrict_widget')) {
298
-    /**
299
-     * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page.
300
-     *
301
-     * @global bool $is_listing Sets the global value to true if on a GD category page. False if not.
302
-     * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not.
303
-     * @since 1.0.0
304
-     * @package GeoDirectory
305
-     */
306
-    function geodir_restrict_widget()
307
-    {
308
-        global $is_listing, $is_single_place;
298
+	/**
299
+	 * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page.
300
+	 *
301
+	 * @global bool $is_listing Sets the global value to true if on a GD category page. False if not.
302
+	 * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not.
303
+	 * @since 1.0.0
304
+	 * @package GeoDirectory
305
+	 */
306
+	function geodir_restrict_widget()
307
+	{
308
+		global $is_listing, $is_single_place;
309 309
 
310
-        // set is listing	
311
-        (geodir_is_page('listing')) ? $is_listing = true : $is_listing = false;
310
+		// set is listing	
311
+		(geodir_is_page('listing')) ? $is_listing = true : $is_listing = false;
312 312
 
313
-        // set is single place
314
-        (geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false;
313
+		// set is single place
314
+		(geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false;
315 315
 
316 316
 
317
-    }
317
+	}
318 318
 }
319 319
 
320 320
 
@@ -335,32 +335,32 @@  discard block
 block discarded – undo
335 335
  */
336 336
 function geodir_detail_page_sidebar_content_sorting()
337 337
 {
338
-    $arr_detail_page_sidebar_content =
339
-        /**
340
-         * An array of functions to be called to be displayed on the details (post) page sidebar.
341
-         *
342
-         * This filter can be used to remove sections of the details page sidebar,
343
-         * add new sections or rearrange the order of the sections.
344
-         *
345
-         * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called.
346
-         * @since 1.0.0
347
-         */
348
-        apply_filters('geodir_detail_page_sidebar_content',
349
-            array('geodir_social_sharing_buttons',
350
-                'geodir_share_this_button',
351
-                'geodir_detail_page_google_analytics',
352
-                'geodir_edit_post_link',
353
-                'geodir_detail_page_review_rating',
354
-                'geodir_detail_page_more_info'
355
-            ) // end of array 
356
-        ); // end of apply filter
357
-    if (!empty($arr_detail_page_sidebar_content)) {
358
-        foreach ($arr_detail_page_sidebar_content as $content_function) {
359
-            if (function_exists($content_function)) {
360
-                add_action('geodir_detail_page_sidebar', $content_function);
361
-            }
362
-        }
363
-    }
338
+	$arr_detail_page_sidebar_content =
339
+		/**
340
+		 * An array of functions to be called to be displayed on the details (post) page sidebar.
341
+		 *
342
+		 * This filter can be used to remove sections of the details page sidebar,
343
+		 * add new sections or rearrange the order of the sections.
344
+		 *
345
+		 * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called.
346
+		 * @since 1.0.0
347
+		 */
348
+		apply_filters('geodir_detail_page_sidebar_content',
349
+			array('geodir_social_sharing_buttons',
350
+				'geodir_share_this_button',
351
+				'geodir_detail_page_google_analytics',
352
+				'geodir_edit_post_link',
353
+				'geodir_detail_page_review_rating',
354
+				'geodir_detail_page_more_info'
355
+			) // end of array 
356
+		); // end of apply filter
357
+	if (!empty($arr_detail_page_sidebar_content)) {
358
+		foreach ($arr_detail_page_sidebar_content as $content_function) {
359
+			if (function_exists($content_function)) {
360
+				add_action('geodir_detail_page_sidebar', $content_function);
361
+			}
362
+		}
363
+	}
364 364
 }
365 365
 
366 366
 add_action('geodir_after_edit_post_link', 'geodir_add_to_favourite_link', 1);
@@ -375,14 +375,14 @@  discard block
 block discarded – undo
375 375
  */
376 376
 function geodir_add_to_favourite_link()
377 377
 {
378
-    global $post, $preview;
379
-    if (!$preview && geodir_is_page('detail')) {
380
-        ?>
378
+	global $post, $preview;
379
+	if (!$preview && geodir_is_page('detail')) {
380
+		?>
381 381
         <p class="edit_link">
382 382
             <?php geodir_favourite_html($post->post_author, $post->ID); ?>
383 383
         </p>
384 384
     <?php
385
-    }
385
+	}
386 386
 }
387 387
 
388 388
 /**
@@ -396,41 +396,41 @@  discard block
 block discarded – undo
396 396
  */
397 397
 function geodir_social_sharing_buttons()
398 398
 {
399
-    global $preview;
400
-    ob_start(); // Start  buffering;
401
-    /**
402
-     * This action is called before the social buttons twitter,facebook and google plus are output in a containing div.
403
-     *
404
-     * @since 1.0.0
405
-     */
406
-    do_action('geodir_before_social_sharing_buttons');
407
-    if (!$preview) {
408
-        ?>
399
+	global $preview;
400
+	ob_start(); // Start  buffering;
401
+	/**
402
+	 * This action is called before the social buttons twitter,facebook and google plus are output in a containing div.
403
+	 *
404
+	 * @since 1.0.0
405
+	 */
406
+	do_action('geodir_before_social_sharing_buttons');
407
+	if (!$preview) {
408
+		?>
409 409
         <div class="likethis">
410 410
             <?php geodir_twitter_tweet_button(); ?>
411 411
             <?php geodir_fb_like_button(); ?>
412 412
             <?php geodir_google_plus_button(); ?>
413 413
         </div>
414 414
     <?php
415
-    }// end of if, if its a preview or not
416
-
417
-    /**
418
-     * This action is called after the social buttons twitter,facebook and google plus are output in a containing div.
419
-     *
420
-     * @since 1.0.0
421
-     */
422
-    do_action('geodir_after_social_sharing_buttons');
423
-    $content_html = ob_get_clean();
424
-    if (trim($content_html) != '')
425
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
426
-    if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
427
-        /**
428
-         * Filter the geodir_social_sharing_buttons() function content.
429
-         *
430
-         * @param string $content_html The output html of the geodir_social_sharing_buttons() function.
431
-         */
432
-        echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html);
433
-    }
415
+	}// end of if, if its a preview or not
416
+
417
+	/**
418
+	 * This action is called after the social buttons twitter,facebook and google plus are output in a containing div.
419
+	 *
420
+	 * @since 1.0.0
421
+	 */
422
+	do_action('geodir_after_social_sharing_buttons');
423
+	$content_html = ob_get_clean();
424
+	if (trim($content_html) != '')
425
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
426
+	if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
427
+		/**
428
+		 * Filter the geodir_social_sharing_buttons() function content.
429
+		 *
430
+		 * @param string $content_html The output html of the geodir_social_sharing_buttons() function.
431
+		 */
432
+		echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html);
433
+	}
434 434
 
435 435
 
436 436
 }
@@ -446,39 +446,39 @@  discard block
 block discarded – undo
446 446
  */
447 447
 function geodir_share_this_button()
448 448
 {
449
-    global $preview;
450
-    ob_start(); // Start buffering;
451
-    /**
452
-     * This is called before the share this html in the function geodir_share_this_button()
453
-     *
454
-     * @since 1.0.0
455
-     */
456
-    do_action('geodir_before_share_this_button');
457
-    if (!$preview) {
458
-        ?>
449
+	global $preview;
450
+	ob_start(); // Start buffering;
451
+	/**
452
+	 * This is called before the share this html in the function geodir_share_this_button()
453
+	 *
454
+	 * @since 1.0.0
455
+	 */
456
+	do_action('geodir_before_share_this_button');
457
+	if (!$preview) {
458
+		?>
459 459
         <div class="share clearfix">
460 460
             <?php geodir_share_this_button_code(); ?>
461 461
         </div>
462 462
     <?php
463
-    }// end of if, if its a preview or not
464
-    /**
465
-     * This is called after the share this html in the function geodir_share_this_button()
466
-     *
467
-     * @since 1.0.0
468
-     */
469
-    do_action('geodir_after_share_this_button');
470
-    $content_html = ob_get_clean();
471
-    if (trim($content_html) != '')
472
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-sharethis">' . $content_html . '</div>';
473
-    if ((int)get_option('geodir_disable_sharethis_button_section') != 1) {
474
-        /**
475
-         * Filter the geodir_share_this_button() function content.
476
-         *
477
-         * @param string $content_html The output html of the geodir_share_this_button() function.
478
-         * @since 1.0.0
479
-         */
480
-        echo $content_html = apply_filters('geodir_share_this_button_html', $content_html);
481
-    }
463
+	}// end of if, if its a preview or not
464
+	/**
465
+	 * This is called after the share this html in the function geodir_share_this_button()
466
+	 *
467
+	 * @since 1.0.0
468
+	 */
469
+	do_action('geodir_after_share_this_button');
470
+	$content_html = ob_get_clean();
471
+	if (trim($content_html) != '')
472
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-sharethis">' . $content_html . '</div>';
473
+	if ((int)get_option('geodir_disable_sharethis_button_section') != 1) {
474
+		/**
475
+		 * Filter the geodir_share_this_button() function content.
476
+		 *
477
+		 * @param string $content_html The output html of the geodir_share_this_button() function.
478
+		 * @since 1.0.0
479
+		 */
480
+		echo $content_html = apply_filters('geodir_share_this_button_html', $content_html);
481
+	}
482 482
 
483 483
 }
484 484
 
@@ -494,46 +494,46 @@  discard block
 block discarded – undo
494 494
  */
495 495
 function geodir_edit_post_link()
496 496
 {
497
-    global $post, $preview;
498
-    ob_start(); // Start buffering;
499
-    /**
500
-     * This is called before the edit post link html in the function geodir_edit_post_link()
501
-     *
502
-     * @since 1.0.0
503
-     */
504
-    do_action('geodir_before_edit_post_link');
505
-    if (!$preview) {
506
-        $is_current_user_owner = geodir_listing_belong_to_current_user();
497
+	global $post, $preview;
498
+	ob_start(); // Start buffering;
499
+	/**
500
+	 * This is called before the edit post link html in the function geodir_edit_post_link()
501
+	 *
502
+	 * @since 1.0.0
503
+	 */
504
+	do_action('geodir_before_edit_post_link');
505
+	if (!$preview) {
506
+		$is_current_user_owner = geodir_listing_belong_to_current_user();
507 507
         
508
-        if ($is_current_user_owner) {
509
-            $post_id = $post->ID;
508
+		if ($is_current_user_owner) {
509
+			$post_id = $post->ID;
510 510
             
511
-            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
512
-                $post_id = (int)$_REQUEST['pid'];
513
-            }
511
+			if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
512
+				$post_id = (int)$_REQUEST['pid'];
513
+			}
514 514
 
515
-            $postlink = get_permalink(geodir_add_listing_page_id());
516
-            $editlink = geodir_getlink($postlink, array('pid' => $post_id), false);
517
-            echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>';
518
-        }
519
-    }// end of if, if its a preview or not
520
-    /**
521
-     * This is called after the edit post link html in the function geodir_edit_post_link()
522
-     *
523
-     * @since 1.0.0
524
-     */
525
-    do_action('geodir_after_edit_post_link');
526
-    $content_html = ob_get_clean();
527
-    if (trim($content_html) != '')
528
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
529
-    if ((int)get_option('geodir_disable_user_links_section') != 1) {
530
-        /**
531
-         * Filter the geodir_edit_post_link() function content.
532
-         *
533
-         * @param string $content_html The output html of the geodir_edit_post_link() function.
534
-         */
535
-        echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html);
536
-    }
515
+			$postlink = get_permalink(geodir_add_listing_page_id());
516
+			$editlink = geodir_getlink($postlink, array('pid' => $post_id), false);
517
+			echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>';
518
+		}
519
+	}// end of if, if its a preview or not
520
+	/**
521
+	 * This is called after the edit post link html in the function geodir_edit_post_link()
522
+	 *
523
+	 * @since 1.0.0
524
+	 */
525
+	do_action('geodir_after_edit_post_link');
526
+	$content_html = ob_get_clean();
527
+	if (trim($content_html) != '')
528
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
529
+	if ((int)get_option('geodir_disable_user_links_section') != 1) {
530
+		/**
531
+		 * Filter the geodir_edit_post_link() function content.
532
+		 *
533
+		 * @param string $content_html The output html of the geodir_edit_post_link() function.
534
+		 */
535
+		echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html);
536
+	}
537 537
 }
538 538
 
539 539
 /**
@@ -547,41 +547,41 @@  discard block
 block discarded – undo
547 547
  */
548 548
 function geodir_detail_page_google_analytics()
549 549
 {
550
-    global $post;
551
-    $package_info = array();
552
-    $package_info = geodir_post_package_info($package_info, $post);
550
+	global $post;
551
+	$package_info = array();
552
+	$package_info = geodir_post_package_info($package_info, $post);
553 553
 
554
-    $id = trim(get_option('geodir_ga_id'));
554
+	$id = trim(get_option('geodir_ga_id'));
555 555
 
556
-    if (!$id) {
557
-        return; //if no Google Analytics ID then bail.
558
-    }
556
+	if (!$id) {
557
+		return; //if no Google Analytics ID then bail.
558
+	}
559 559
 
560
-    ob_start(); // Start buffering;
561
-    /**
562
-     * This is called before the edit post link html in the function geodir_detail_page_google_analytics()
563
-     *
564
-     * @since 1.0.0
565
-     */
566
-    do_action('geodir_before_google_analytics');
560
+	ob_start(); // Start buffering;
561
+	/**
562
+	 * This is called before the edit post link html in the function geodir_detail_page_google_analytics()
563
+	 *
564
+	 * @since 1.0.0
565
+	 */
566
+	do_action('geodir_before_google_analytics');
567 567
     
568
-    $refresh_time = get_option('geodir_ga_refresh_time', 5);
569
-    /**
570
-     * Filter the time interval to check & refresh new users results.
571
-     *
572
-     * @since 1.5.9
573
-     *
574
-     * @param int $refresh_time Time interval to check & refresh new users results.
575
-     */
576
-    $refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time);
577
-    $refresh_time = absint($refresh_time * 1000);
568
+	$refresh_time = get_option('geodir_ga_refresh_time', 5);
569
+	/**
570
+	 * Filter the time interval to check & refresh new users results.
571
+	 *
572
+	 * @since 1.5.9
573
+	 *
574
+	 * @param int $refresh_time Time interval to check & refresh new users results.
575
+	 */
576
+	$refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time);
577
+	$refresh_time = absint($refresh_time * 1000);
578 578
     
579
-    $hide_refresh = get_option('geodir_ga_auto_refresh');
579
+	$hide_refresh = get_option('geodir_ga_auto_refresh');
580 580
     
581
-    $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0;
582
-    if (get_option('geodir_ga_stats') && is_user_logged_in() &&  (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
583
-        $page_url = urlencode($_SERVER['REQUEST_URI']);
584
-        ?>
581
+	$auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0;
582
+	if (get_option('geodir_ga_stats') && is_user_logged_in() &&  (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
583
+		$page_url = urlencode($_SERVER['REQUEST_URI']);
584
+		?>
585 585
         <script type="text/javascript">
586 586
             var gd_gaTimeOut;
587 587
             var gd_gaTime = parseInt('<?php echo $refresh_time;?>');
@@ -833,15 +833,15 @@  discard block
 block discarded – undo
833 833
                     var labels = results[1].rows.map(function(row) { return +row[0]; });
834 834
 
835 835
                     <?php
836
-                    // Here we list the shorthand days of the week so it can be used in translation.
837
-                    __("Mon",'geodirectory');
838
-                    __("Tue",'geodirectory');
839
-                    __("Wed",'geodirectory');
840
-                    __("Thu",'geodirectory');
841
-                    __("Fri",'geodirectory');
842
-                    __("Sat",'geodirectory');
843
-                    __("Sun",'geodirectory');
844
-                    ?>
836
+					// Here we list the shorthand days of the week so it can be used in translation.
837
+					__("Mon",'geodirectory');
838
+					__("Tue",'geodirectory');
839
+					__("Wed",'geodirectory');
840
+					__("Thu",'geodirectory');
841
+					__("Fri",'geodirectory');
842
+					__("Sat",'geodirectory');
843
+					__("Sun",'geodirectory');
844
+					?>
845 845
 
846 846
                     labels = [
847 847
                         "<?php _e(date('D', strtotime("+1 day")),'geodirectory'); ?>",
@@ -1090,24 +1090,24 @@  discard block
 block discarded – undo
1090 1090
         </span>
1091 1091
 
1092 1092
     <?php
1093
-    }
1094
-    /**
1095
-     * This is called after the edit post link html in the function geodir_detail_page_google_analytics()
1096
-     *
1097
-     * @since 1.0.0
1098
-     */
1099
-    do_action('geodir_after_google_analytics');
1100
-    $content_html = ob_get_clean();
1101
-    if (trim($content_html) != '')
1102
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1103
-    if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
1104
-        /**
1105
-         * Filter the geodir_edit_post_link() function content.
1106
-         *
1107
-         * @param string $content_html The output html of the geodir_edit_post_link() function.
1108
-         */
1109
-        echo $content_html = apply_filters('geodir_google_analytic_html', $content_html);
1110
-    }
1093
+	}
1094
+	/**
1095
+	 * This is called after the edit post link html in the function geodir_detail_page_google_analytics()
1096
+	 *
1097
+	 * @since 1.0.0
1098
+	 */
1099
+	do_action('geodir_after_google_analytics');
1100
+	$content_html = ob_get_clean();
1101
+	if (trim($content_html) != '')
1102
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1103
+	if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
1104
+		/**
1105
+		 * Filter the geodir_edit_post_link() function content.
1106
+		 *
1107
+		 * @param string $content_html The output html of the geodir_edit_post_link() function.
1108
+		 */
1109
+		echo $content_html = apply_filters('geodir_google_analytic_html', $content_html);
1110
+	}
1111 1111
 }
1112 1112
 
1113 1113
 /**
@@ -1123,90 +1123,90 @@  discard block
 block discarded – undo
1123 1123
  */
1124 1124
 function geodir_detail_page_review_rating()
1125 1125
 {
1126
-    global $post, $preview, $post_images;
1127
-    ob_start(); // Start  buffering;
1128
-    /**
1129
-     * This is called before the rating html in the function geodir_detail_page_review_rating().
1130
-     *
1131
-     * This is called outside the check for an actual rating and the check for preview page.
1132
-     *
1133
-     * @since 1.0.0
1134
-     */
1135
-    do_action('geodir_before_detail_page_review_rating');
1136
-
1137
-    $comment_count = geodir_get_review_count_total($post->ID);
1138
-    $post_avgratings = geodir_get_post_rating($post->ID);
1139
-
1140
-    if ($post_avgratings != 0 && !$preview) {
1141
-        /**
1142
-         * This is called before the rating html in the function geodir_detail_page_review_rating().
1143
-         *
1144
-         * This is called inside the check for an actual rating and the check for preview page.
1145
-         *
1146
-         * @since 1.0.0
1147
-         * @param float $post_avgratings Average rating for the surrent post.
1148
-         * @param int $post->ID Current post ID.
1149
-         */
1150
-        do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1151
-
1152
-        $html = '<p style=" float:left;">';
1153
-        $html .= geodir_get_rating_stars($post_avgratings, $post->ID);
1154
-        $html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">';
1155
-        $post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings;
1126
+	global $post, $preview, $post_images;
1127
+	ob_start(); // Start  buffering;
1128
+	/**
1129
+	 * This is called before the rating html in the function geodir_detail_page_review_rating().
1130
+	 *
1131
+	 * This is called outside the check for an actual rating and the check for preview page.
1132
+	 *
1133
+	 * @since 1.0.0
1134
+	 */
1135
+	do_action('geodir_before_detail_page_review_rating');
1136
+
1137
+	$comment_count = geodir_get_review_count_total($post->ID);
1138
+	$post_avgratings = geodir_get_post_rating($post->ID);
1139
+
1140
+	if ($post_avgratings != 0 && !$preview) {
1141
+		/**
1142
+		 * This is called before the rating html in the function geodir_detail_page_review_rating().
1143
+		 *
1144
+		 * This is called inside the check for an actual rating and the check for preview page.
1145
+		 *
1146
+		 * @since 1.0.0
1147
+		 * @param float $post_avgratings Average rating for the surrent post.
1148
+		 * @param int $post->ID Current post ID.
1149
+		 */
1150
+		do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1151
+
1152
+		$html = '<p style=" float:left;">';
1153
+		$html .= geodir_get_rating_stars($post_avgratings, $post->ID);
1154
+		$html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">';
1155
+		$post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings;
1156 1156
        
1157 1157
 	   $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory');
1158 1158
 	   
1159 1159
 	   $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />';
1160 1160
 
1161
-        $html .= '<span class="item">';
1162
-        $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>';
1161
+		$html .= '<span class="item">';
1162
+		$html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>';
1163 1163
 
1164
-        if ($post_images) {
1165
-            foreach ($post_images as $img) {
1166
-                $post_img = $img->src;
1167
-                break;
1168
-            }
1169
-        }
1170
-
1171
-        if (isset($post_img) && $post_img) {
1172
-            $html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />';
1173
-        }
1174
-
1175
-        $html .= '</span>';
1176
-
1177
-        echo $html .= '</div>';
1178
-        /**
1179
-         * This is called after the rating html in the function geodir_detail_page_review_rating().
1180
-         *
1181
-         * This is called inside the check for an actual rating and the check for preview page.
1182
-         *
1183
-         * @since 1.0.0
1184
-         * @param float $post_avgratings Average rating for the surrent post.
1185
-         * @param int $post->ID Current post ID.
1186
-         */
1187
-        do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1188
-    }
1189
-    /**
1190
-     * This is called before the rating html in the function geodir_detail_page_review_rating().
1191
-     *
1192
-     * This is called outside the check for an actual rating and the check for preview page.
1193
-     *
1194
-     * @since 1.0.0
1195
-     */
1196
-    do_action('geodir_after_detail_page_review_rating');
1197
-    $content_html = ob_get_clean();
1198
-    if (trim($content_html) != '') {
1199
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>';
1200
-    }
1201
-    if ((int)get_option('geodir_disable_rating_info_section') != 1) {
1202
-        /**
1203
-         * Filter the geodir_detail_page_review_rating() function content.
1204
-         *
1205
-         * @since 1.0.0
1206
-         * @param string $content_html The output html of the geodir_detail_page_review_rating() function.
1207
-         */
1208
-        echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html);
1209
-    }
1164
+		if ($post_images) {
1165
+			foreach ($post_images as $img) {
1166
+				$post_img = $img->src;
1167
+				break;
1168
+			}
1169
+		}
1170
+
1171
+		if (isset($post_img) && $post_img) {
1172
+			$html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />';
1173
+		}
1174
+
1175
+		$html .= '</span>';
1176
+
1177
+		echo $html .= '</div>';
1178
+		/**
1179
+		 * This is called after the rating html in the function geodir_detail_page_review_rating().
1180
+		 *
1181
+		 * This is called inside the check for an actual rating and the check for preview page.
1182
+		 *
1183
+		 * @since 1.0.0
1184
+		 * @param float $post_avgratings Average rating for the surrent post.
1185
+		 * @param int $post->ID Current post ID.
1186
+		 */
1187
+		do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1188
+	}
1189
+	/**
1190
+	 * This is called before the rating html in the function geodir_detail_page_review_rating().
1191
+	 *
1192
+	 * This is called outside the check for an actual rating and the check for preview page.
1193
+	 *
1194
+	 * @since 1.0.0
1195
+	 */
1196
+	do_action('geodir_after_detail_page_review_rating');
1197
+	$content_html = ob_get_clean();
1198
+	if (trim($content_html) != '') {
1199
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>';
1200
+	}
1201
+	if ((int)get_option('geodir_disable_rating_info_section') != 1) {
1202
+		/**
1203
+		 * Filter the geodir_detail_page_review_rating() function content.
1204
+		 *
1205
+		 * @since 1.0.0
1206
+		 * @param string $content_html The output html of the geodir_detail_page_review_rating() function.
1207
+		 */
1208
+		echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html);
1209
+	}
1210 1210
 }
1211 1211
 
1212 1212
 /**
@@ -1218,35 +1218,35 @@  discard block
 block discarded – undo
1218 1218
  */
1219 1219
 function geodir_detail_page_more_info()
1220 1220
 {
1221
-    ob_start(); // Start  buffering;
1222
-    /**
1223
-     * This is called before the info section html.
1224
-     *
1225
-     * @since 1.0.0
1226
-     */
1227
-    do_action('geodir_before_detail_page_more_info');
1228
-    if ($geodir_post_detail_fields = geodir_show_listing_info('detail')) {
1229
-        echo $geodir_post_detail_fields;
1230
-    }
1231
-    /**
1232
-     * This is called after the info section html.
1233
-     *
1234
-     * @since 1.0.0
1235
-     */
1236
-    do_action('geodir_after_detail_page_more_info');
1237
-
1238
-    $content_html = ob_get_clean();
1239
-    if (trim($content_html) != '')
1240
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1241
-    if ((int)get_option('geodir_disable_listing_info_section') != 1) {
1242
-        /**
1243
-         * Filter the output html for function geodir_detail_page_more_info().
1244
-         *
1245
-         * @since 1.0.0
1246
-         * @param string $content_html The output html of the geodir_detail_page_more_info() function.
1247
-         */
1248
-        echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html);
1249
-    }
1221
+	ob_start(); // Start  buffering;
1222
+	/**
1223
+	 * This is called before the info section html.
1224
+	 *
1225
+	 * @since 1.0.0
1226
+	 */
1227
+	do_action('geodir_before_detail_page_more_info');
1228
+	if ($geodir_post_detail_fields = geodir_show_listing_info('detail')) {
1229
+		echo $geodir_post_detail_fields;
1230
+	}
1231
+	/**
1232
+	 * This is called after the info section html.
1233
+	 *
1234
+	 * @since 1.0.0
1235
+	 */
1236
+	do_action('geodir_after_detail_page_more_info');
1237
+
1238
+	$content_html = ob_get_clean();
1239
+	if (trim($content_html) != '')
1240
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1241
+	if ((int)get_option('geodir_disable_listing_info_section') != 1) {
1242
+		/**
1243
+		 * Filter the output html for function geodir_detail_page_more_info().
1244
+		 *
1245
+		 * @since 1.0.0
1246
+		 * @param string $content_html The output html of the geodir_detail_page_more_info() function.
1247
+		 */
1248
+		echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html);
1249
+	}
1250 1250
 }
1251 1251
 
1252 1252
 
@@ -1260,15 +1260,15 @@  discard block
 block discarded – undo
1260 1260
  */
1261 1261
 function geodir_localize_all_js_msg()
1262 1262
 {// check_ajax_referer function is used to make sure no files are uplaoded remotly but it will fail if used between https and non https so we do the check below of the urls
1263
-    if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1264
-        $ajax_url = admin_url('admin-ajax.php');
1265
-    } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1266
-        $ajax_url = admin_url('admin-ajax.php');
1267
-    } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1268
-        $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
1269
-    } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1270
-        $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
1271
-    }
1263
+	if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1264
+		$ajax_url = admin_url('admin-ajax.php');
1265
+	} elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1266
+		$ajax_url = admin_url('admin-ajax.php');
1267
+	} elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1268
+		$ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
1269
+	} elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1270
+		$ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
1271
+	}
1272 1272
 	
1273 1273
 	/**
1274 1274
 	 * Filter the allowed image type extensions for post images.
@@ -1278,60 +1278,60 @@  discard block
 block discarded – undo
1278 1278
 	 */
1279 1279
 	$allowed_img_types = apply_filters('geodir_allowed_post_image_exts', array('jpg', 'jpeg', 'jpe', 'gif', 'png'));
1280 1280
 	
1281
-    $default_marker_icon = get_option('geodir_default_marker_icon');
1282
-    $default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34));
1283
-    $default_marker_width = $default_marker_size['w'];
1284
-    $default_marker_height = $default_marker_size['h'];
1281
+	$default_marker_icon = get_option('geodir_default_marker_icon');
1282
+	$default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34));
1283
+	$default_marker_width = $default_marker_size['w'];
1284
+	$default_marker_height = $default_marker_size['h'];
1285 1285
     
1286
-    $arr_alert_msg = array(
1287
-        'geodir_plugin_url' => geodir_plugin_url(),
1288
-        'geodir_admin_ajax_url' => $ajax_url,
1289
-        'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'),
1290
-        'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'),
1291
-        'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'),
1292
-        'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'),
1293
-        //start not show alert msg
1294
-        'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'),
1295
-        'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'),
1296
-        'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'),
1297
-        'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'),
1298
-        'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'),
1299
-        // end not show alert msg
1300
-        'my_place_listing_del' => __('Are you wish to delete this listing?', 'geodirectory'),
1301
-        'my_main_listing_del' => __('Deleting the main listing of a franchise will turn all franchises in regular listings. Are you sure wish to delete this main listing?', 'geodirectory'),
1302
-        //start not show alert msg
1303
-        'rating_error_msg' => __('Error : please retry', 'geodirectory'),
1304
-        'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'),
1305
-        'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'),
1306
-        'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'),
1307
-        'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'),
1308
-        'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'),
1309
-        'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'),
1310
-        'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'),
1311
-        'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'),
1312
-        'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'),
1313
-        'geodir_field_id_required' => __('This field is required.', 'geodirectory'),
1314
-        'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'),
1315
-        'geodir_default_marker_icon' => $default_marker_icon,
1316
-        'geodir_default_marker_w' => $default_marker_width,
1317
-        'geodir_default_marker_h' => $default_marker_height,
1318
-        'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG,
1319
-        'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG,
1320
-        'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'),
1321
-        'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'),
1322
-        'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'),
1323
-        'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'),
1324
-        'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'),
1325
-        'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'),
1326
-        /* on/off dragging for phone devices */
1327
-        'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false,
1328
-        'geodir_is_mobile' => wp_is_mobile() ? true : false,
1329
-        'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'),
1330
-        'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'),
1331
-        'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'),
1332
-        'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'),
1333
-        'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'),
1334
-        'geodir_action_remove' => __('Remove', 'geodirectory'),
1286
+	$arr_alert_msg = array(
1287
+		'geodir_plugin_url' => geodir_plugin_url(),
1288
+		'geodir_admin_ajax_url' => $ajax_url,
1289
+		'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'),
1290
+		'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'),
1291
+		'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'),
1292
+		'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'),
1293
+		//start not show alert msg
1294
+		'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'),
1295
+		'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'),
1296
+		'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'),
1297
+		'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'),
1298
+		'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'),
1299
+		// end not show alert msg
1300
+		'my_place_listing_del' => __('Are you wish to delete this listing?', 'geodirectory'),
1301
+		'my_main_listing_del' => __('Deleting the main listing of a franchise will turn all franchises in regular listings. Are you sure wish to delete this main listing?', 'geodirectory'),
1302
+		//start not show alert msg
1303
+		'rating_error_msg' => __('Error : please retry', 'geodirectory'),
1304
+		'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'),
1305
+		'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'),
1306
+		'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'),
1307
+		'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'),
1308
+		'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'),
1309
+		'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'),
1310
+		'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'),
1311
+		'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'),
1312
+		'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'),
1313
+		'geodir_field_id_required' => __('This field is required.', 'geodirectory'),
1314
+		'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'),
1315
+		'geodir_default_marker_icon' => $default_marker_icon,
1316
+		'geodir_default_marker_w' => $default_marker_width,
1317
+		'geodir_default_marker_h' => $default_marker_height,
1318
+		'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG,
1319
+		'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG,
1320
+		'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'),
1321
+		'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'),
1322
+		'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'),
1323
+		'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'),
1324
+		'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'),
1325
+		'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'),
1326
+		/* on/off dragging for phone devices */
1327
+		'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false,
1328
+		'geodir_is_mobile' => wp_is_mobile() ? true : false,
1329
+		'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'),
1330
+		'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'),
1331
+		'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'),
1332
+		'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'),
1333
+		'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'),
1334
+		'geodir_action_remove' => __('Remove', 'geodirectory'),
1335 1335
 		'geodir_txt_all_files' => __('Allowed files', 'geodirectory'),
1336 1336
 		'geodir_err_file_type' => __('File type error. Allowed file types: %s', 'geodirectory'),
1337 1337
 		'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '',
@@ -1339,29 +1339,29 @@  discard block
 block discarded – undo
1339 1339
 		'geodir_txt_form_searching' => __('Searching...', 'geodirectory'),
1340 1340
 		'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '',
1341 1341
 		'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '',
1342
-        'geodir_map_name' => geodir_map_name(),
1343
-    );
1344
-
1345
-    /**
1346
-     * Filters the translated JS strings from function geodir_localize_all_js_msg().
1347
-     *
1348
-     * With this filter you can add, remove or change translated JS strings.
1349
-     * You should add your own translations to this if you are building an addon rather than adding another script block.
1350
-     *
1351
-     * @since 1.0.0
1352
-     */
1353
-    $arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg);
1354
-
1355
-    foreach ($arr_alert_msg as $key => $value) {
1356
-        if (!is_scalar($value))
1357
-            continue;
1358
-        $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
1359
-    }
1342
+		'geodir_map_name' => geodir_map_name(),
1343
+	);
1344
+
1345
+	/**
1346
+	 * Filters the translated JS strings from function geodir_localize_all_js_msg().
1347
+	 *
1348
+	 * With this filter you can add, remove or change translated JS strings.
1349
+	 * You should add your own translations to this if you are building an addon rather than adding another script block.
1350
+	 *
1351
+	 * @since 1.0.0
1352
+	 */
1353
+	$arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg);
1354
+
1355
+	foreach ($arr_alert_msg as $key => $value) {
1356
+		if (!is_scalar($value))
1357
+			continue;
1358
+		$arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
1359
+	}
1360 1360
 
1361
-    $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';';
1362
-    echo '<script>';
1363
-    echo $script;
1364
-    echo '</script>';
1361
+	$script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';';
1362
+	echo '<script>';
1363
+	echo $script;
1364
+	echo '</script>';
1365 1365
 }
1366 1366
 
1367 1367
 add_action('admin_bar_menu', 'geodir_admin_bar_site_menu', 31);
@@ -1377,11 +1377,11 @@  discard block
 block discarded – undo
1377 1377
  */
1378 1378
 function geodir_admin_bar_site_menu($wp_admin_bar)
1379 1379
 {
1380
-    if (get_option("geodir_installed")) {
1381
-        if (current_user_can('manage_options')) {
1382
-            $wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory')));
1383
-        }
1384
-    }
1380
+	if (get_option("geodir_installed")) {
1381
+		if (current_user_can('manage_options')) {
1382
+			$wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory')));
1383
+		}
1384
+	}
1385 1385
 }
1386 1386
 
1387 1387
 add_action('geodir_before_listing', 'geodir_display_sort_options'); /*function in custom_functions.php*/
@@ -1407,25 +1407,25 @@  discard block
 block discarded – undo
1407 1407
  */
1408 1408
 function geodir_store_sidebars()
1409 1409
 {
1410
-    global $geodir_sidebars;
1411
-    global $sidebars_widgets;
1412
-
1413
-    if (!is_array($sidebars_widgets))
1414
-        $sidebars_widgets = wp_get_sidebars_widgets();
1415
-    $geodir_old_sidebars = array();
1416
-
1417
-    if (is_array($geodir_sidebars)) {
1418
-        foreach ($geodir_sidebars as $val) {
1419
-            if (is_array($sidebars_widgets)) {
1420
-                if (array_key_exists($val, $sidebars_widgets))
1421
-                    $geodir_old_sidebars[$val] = $sidebars_widgets[$val];
1422
-                else
1423
-                    $geodir_old_sidebars[$val] = array();
1424
-            }
1425
-        }
1426
-    }
1427
-    update_option('geodir_sidebars', $geodir_old_sidebars);
1428
-    geodir_option_version_backup('geodir_sidebars');
1410
+	global $geodir_sidebars;
1411
+	global $sidebars_widgets;
1412
+
1413
+	if (!is_array($sidebars_widgets))
1414
+		$sidebars_widgets = wp_get_sidebars_widgets();
1415
+	$geodir_old_sidebars = array();
1416
+
1417
+	if (is_array($geodir_sidebars)) {
1418
+		foreach ($geodir_sidebars as $val) {
1419
+			if (is_array($sidebars_widgets)) {
1420
+				if (array_key_exists($val, $sidebars_widgets))
1421
+					$geodir_old_sidebars[$val] = $sidebars_widgets[$val];
1422
+				else
1423
+					$geodir_old_sidebars[$val] = array();
1424
+			}
1425
+		}
1426
+	}
1427
+	update_option('geodir_sidebars', $geodir_old_sidebars);
1428
+	geodir_option_version_backup('geodir_sidebars');
1429 1429
 
1430 1430
 }
1431 1431
 
@@ -1439,28 +1439,28 @@  discard block
 block discarded – undo
1439 1439
  */
1440 1440
 function geodir_restore_sidebars()
1441 1441
 {
1442
-    global $sidebars_widgets;
1443
-
1444
-    if (!is_array($sidebars_widgets))
1445
-        $sidebars_widgets = wp_get_sidebars_widgets();
1446
-
1447
-    if (is_array($sidebars_widgets)) {
1448
-        $geodir_old_sidebars = get_option('geodir_sidebars');
1449
-        if (is_array($geodir_old_sidebars)) {
1450
-            foreach ($geodir_old_sidebars as $key => $val) {
1451
-                if(0 === strpos($key, 'geodir_'))// if gd widget
1452
-                {
1453
-                    $sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1454
-                }
1442
+	global $sidebars_widgets;
1455 1443
 
1444
+	if (!is_array($sidebars_widgets))
1445
+		$sidebars_widgets = wp_get_sidebars_widgets();
1456 1446
 
1457
-            }
1458
-        }
1447
+	if (is_array($sidebars_widgets)) {
1448
+		$geodir_old_sidebars = get_option('geodir_sidebars');
1449
+		if (is_array($geodir_old_sidebars)) {
1450
+			foreach ($geodir_old_sidebars as $key => $val) {
1451
+				if(0 === strpos($key, 'geodir_'))// if gd widget
1452
+				{
1453
+					$sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1454
+				}
1459 1455
 
1460
-    }
1461 1456
 
1462
-    update_option('sidebars_widgets', $sidebars_widgets);
1463
-    update_option('geodir_sidebars', '');
1457
+			}
1458
+		}
1459
+
1460
+	}
1461
+
1462
+	update_option('sidebars_widgets', $sidebars_widgets);
1463
+	update_option('geodir_sidebars', '');
1464 1464
 }
1465 1465
 
1466 1466
 add_action('geodir_after_listing_post_gridview', 'geodir_after_listing_post_gridview');
@@ -1473,9 +1473,9 @@  discard block
 block discarded – undo
1473 1473
  */
1474 1474
 function geodir_after_listing_post_gridview()
1475 1475
 {
1476
-    global $gridview_columns;
1476
+	global $gridview_columns;
1477 1477
 
1478
-    $gridview_columns = '';
1478
+	$gridview_columns = '';
1479 1479
 
1480 1480
 }
1481 1481
 
@@ -1503,11 +1503,11 @@  discard block
 block discarded – undo
1503 1503
  */
1504 1504
 function so_handle_038($url, $original_url, $_context)
1505 1505
 {
1506
-    if (strstr($url, "maps.google.com/maps/api/js") !== false) {
1507
-        $url = str_replace("&#038;", "&amp;", $url); // or $url = $original_url
1508
-    }
1506
+	if (strstr($url, "maps.google.com/maps/api/js") !== false) {
1507
+		$url = str_replace("&#038;", "&amp;", $url); // or $url = $original_url
1508
+	}
1509 1509
 
1510
-    return $url;
1510
+	return $url;
1511 1511
 }
1512 1512
 
1513 1513
 
@@ -1523,34 +1523,34 @@  discard block
 block discarded – undo
1523 1523
 function geodir_after_main_form_fields() {
1524 1524
 	global $gd_session;
1525 1525
 	
1526
-    if (get_option('geodir_accept_term_condition')) {
1527
-        global $post;
1528
-        $term_condition = '';
1529
-        if (isset($_REQUEST['backandedit'])) {
1530
-            $post = (object)$gd_session->get('listing');
1531
-            $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : '';
1532
-        }
1533
-
1534
-        ?>
1526
+	if (get_option('geodir_accept_term_condition')) {
1527
+		global $post;
1528
+		$term_condition = '';
1529
+		if (isset($_REQUEST['backandedit'])) {
1530
+			$post = (object)$gd_session->get('listing');
1531
+			$term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : '';
1532
+		}
1533
+
1534
+		?>
1535 1535
         <div id="geodir_accept_term_condition_row" class="required_field geodir_form_row clearfix">
1536 1536
             <label>&nbsp;</label>
1537 1537
 
1538 1538
             <div class="geodir_taxonomy_field" style="float:left; width:70%;">
1539 1539
 				<span style="display:block"> 
1540 1540
 				<input class="main_list_selecter" type="checkbox" <?php if ($term_condition == '1') {
1541
-                    echo 'checked="checked"';
1542
-                } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition"
1541
+					echo 'checked="checked"';
1542
+				} ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition"
1543 1543
                        class="geodir_textfield" value="1"
1544 1544
                        style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if($terms_page){ echo get_permalink($terms_page);}?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a>
1545 1545
 				</span>
1546 1546
             </div>
1547 1547
             <span class="geodir_message_error"><?php if (isset($required_msg)) {
1548
-                    _e($required_msg, 'geodirectory');
1549
-                } ?></span>
1548
+					_e($required_msg, 'geodirectory');
1549
+				} ?></span>
1550 1550
         </div>
1551 1551
     <?php
1552 1552
 
1553
-    }
1553
+	}
1554 1554
 }
1555 1555
 
1556 1556
 
@@ -1575,42 +1575,42 @@  discard block
 block discarded – undo
1575 1575
  */
1576 1576
 function geodir_detail_page_tab_is_display($is_display, $tab)
1577 1577
 {
1578
-    global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1578
+	global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1579 1579
 
1580
-    if ($tab == 'post_profile') {
1581
-        /** This action is documented in geodirectory_template_actions.php */
1582
-        $desc_limit = apply_filters('geodir_description_field_desc_limit', '');
1580
+	if ($tab == 'post_profile') {
1581
+		/** This action is documented in geodirectory_template_actions.php */
1582
+		$desc_limit = apply_filters('geodir_description_field_desc_limit', '');
1583 1583
         
1584
-        if (!($desc_limit === '' || (int)$desc_limit > 0)) {
1585
-            $is_display = false;
1586
-        }
1587
-    }
1584
+		if (!($desc_limit === '' || (int)$desc_limit > 0)) {
1585
+			$is_display = false;
1586
+		}
1587
+	}
1588 1588
     
1589
-    if ($tab == 'post_info')
1590
-        $is_display = (!empty($geodir_post_detail_fields)) ? true : false;
1589
+	if ($tab == 'post_info')
1590
+		$is_display = (!empty($geodir_post_detail_fields)) ? true : false;
1591 1591
     
1592
-    if ($tab == 'post_images')
1593
-        $is_display = (!empty($post_images)) ? true : false;
1592
+	if ($tab == 'post_images')
1593
+		$is_display = (!empty($post_images)) ? true : false;
1594 1594
 
1595
-    if ($tab == 'post_video')
1596
-        $is_display = (!empty($video)) ? true : false;
1595
+	if ($tab == 'post_video')
1596
+		$is_display = (!empty($video)) ? true : false;
1597 1597
 
1598
-    if ($tab == 'special_offers')
1599
-        $is_display = (!empty($special_offers)) ? true : false;
1598
+	if ($tab == 'special_offers')
1599
+		$is_display = (!empty($special_offers)) ? true : false;
1600 1600
 
1601
-    if ($tab == 'reviews')
1602
-        $is_display = (geodir_is_page('detail')) ? true : false;
1601
+	if ($tab == 'reviews')
1602
+		$is_display = (geodir_is_page('detail')) ? true : false;
1603 1603
 
1604
-    if ($tab == 'related_listing') {
1605
-       $message = __('No listings found which match your selection.', 'geodirectory');
1604
+	if ($tab == 'related_listing') {
1605
+	   $message = __('No listings found which match your selection.', 'geodirectory');
1606 1606
        
1607
-       /** This action is documented in geodirectory-functions/template_functions.php */
1608
-       $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false);
1607
+	   /** This action is documented in geodirectory-functions/template_functions.php */
1608
+	   $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false);
1609 1609
        
1610
-       $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true;
1611
-    }
1610
+	   $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true;
1611
+	}
1612 1612
 
1613
-    return $is_display;
1613
+	return $is_display;
1614 1614
 }
1615 1615
 
1616 1616
 
@@ -1626,69 +1626,69 @@  discard block
 block discarded – undo
1626 1626
  * @global string $plugin_prefix Geodirectory plugin table prefix.
1627 1627
  */
1628 1628
 function geodir_changes_in_custom_fields_table() {
1629
-    global $wpdb, $plugin_prefix;
1629
+	global $wpdb, $plugin_prefix;
1630 1630
 	
1631 1631
 	// Remove unused virtual page
1632 1632
 	$listings_page_id = (int)get_option('geodir_listing_page');
1633 1633
 	if ($listings_page_id) {
1634 1634
 		$wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page')));
1635
-        delete_option('geodir_listing_page');
1635
+		delete_option('geodir_listing_page');
1636 1636
 	}
1637 1637
 
1638
-    if (!get_option('geodir_changes_in_custom_fields_table')) {
1639
-        $wpdb->query(
1640
-            $wpdb->prepare(
1641
-                "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s",
1642
-                array('1', '1', 'admin')
1643
-            )
1644
-        );
1638
+	if (!get_option('geodir_changes_in_custom_fields_table')) {
1639
+		$wpdb->query(
1640
+			$wpdb->prepare(
1641
+				"UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s",
1642
+				array('1', '1', 'admin')
1643
+			)
1644
+		);
1645 1645
 
1646 1646
 
1647
-        /* --- terms meta value set --- */
1647
+		/* --- terms meta value set --- */
1648 1648
 
1649
-        update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png');
1649
+		update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png');
1650 1650
 
1651
-        $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%')));
1651
+		$options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%')));
1652 1652
 
1653
-        if (!empty($options_data)) {
1653
+		if (!empty($options_data)) {
1654 1654
 
1655
-            foreach ($options_data as $optobj) {
1655
+			foreach ($options_data as $optobj) {
1656 1656
 
1657
-                $option_val = str_replace('tax_meta_', '', $optobj->option_name);
1657
+				$option_val = str_replace('tax_meta_', '', $optobj->option_name);
1658 1658
 
1659
-                $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
1659
+				$taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
1660 1660
 
1661
-                if (!empty($taxonomies_data)) {
1661
+				if (!empty($taxonomies_data)) {
1662 1662
 
1663
-                    foreach ($taxonomies_data as $taxobj) {
1663
+					foreach ($taxonomies_data as $taxobj) {
1664 1664
 
1665
-                        $taxObject = get_taxonomy($taxobj->taxonomy);
1666
-                        $post_type = $taxObject->object_type[0];
1665
+						$taxObject = get_taxonomy($taxobj->taxonomy);
1666
+						$post_type = $taxObject->object_type[0];
1667 1667
 
1668
-                        $opt_value = 'tax_meta_' . $post_type . '_' . $option_val;
1668
+						$opt_value = 'tax_meta_' . $post_type . '_' . $option_val;
1669 1669
 
1670
-                        $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val)));
1670
+						$duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val)));
1671 1671
 
1672
-                        if ($duplicate_data) {
1672
+						if ($duplicate_data) {
1673 1673
 
1674
-                            $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET	option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
1674
+							$wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET	option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
1675 1675
 
1676
-                        } else {
1676
+						} else {
1677 1677
 
1678
-                            $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
1678
+							$wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
1679 1679
 
1680
-                        }
1680
+						}
1681 1681
 
1682
-                    }
1682
+					}
1683 1683
 
1684
-                }
1684
+				}
1685 1685
 
1686
-            }
1687
-        }
1686
+			}
1687
+		}
1688 1688
 
1689
-        update_option('geodir_changes_in_custom_fields_table', '1');
1689
+		update_option('geodir_changes_in_custom_fields_table', '1');
1690 1690
 
1691
-    }
1691
+	}
1692 1692
 
1693 1693
 }
1694 1694
 
@@ -1707,24 +1707,24 @@  discard block
 block discarded – undo
1707 1707
 function geodir_location_slug_check($slug)
1708 1708
 {
1709 1709
 
1710
-    global $wpdb, $table_prefix;
1710
+	global $wpdb, $table_prefix;
1711 1711
 
1712
-    $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug)));
1712
+	$slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug)));
1713 1713
 
1714
-    if ($slug_exists) {
1714
+	if ($slug_exists) {
1715 1715
 
1716
-        $suffix = 1;
1717
-        do {
1718
-            $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1719
-            $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name)));
1720
-            $suffix++;
1721
-        } while ($location_slug_check && $suffix < 100);
1716
+		$suffix = 1;
1717
+		do {
1718
+			$alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1719
+			$location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name)));
1720
+			$suffix++;
1721
+		} while ($location_slug_check && $suffix < 100);
1722 1722
 
1723
-        $slug = $alt_location_name;
1723
+		$slug = $alt_location_name;
1724 1724
 
1725
-    }
1725
+	}
1726 1726
 
1727
-    return $slug;
1727
+	return $slug;
1728 1728
 
1729 1729
 }
1730 1730
 
@@ -1749,42 +1749,42 @@  discard block
 block discarded – undo
1749 1749
 function geodir_update_term_slug($term_id, $tt_id, $taxonomy)
1750 1750
 {
1751 1751
 
1752
-    global $wpdb, $plugin_prefix, $table_prefix;
1752
+	global $wpdb, $plugin_prefix, $table_prefix;
1753 1753
 
1754
-    $tern_data = get_term_by('id', $term_id, $taxonomy);
1754
+	$tern_data = get_term_by('id', $term_id, $taxonomy);
1755 1755
 
1756
-    $slug = $tern_data->slug;
1756
+	$slug = $tern_data->slug;
1757 1757
 
1758
-    /**
1759
-     * Filter if a term slug exists.
1760
-     *
1761
-     * @since 1.0.0
1762
-     * @package GeoDirectory
1763
-     * @param bool $bool Default: false.
1764
-     * @param string $slug The term slug.
1765
-     * @param int $term_id The term ID.
1766
-     */
1767
-    $slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id);
1758
+	/**
1759
+	 * Filter if a term slug exists.
1760
+	 *
1761
+	 * @since 1.0.0
1762
+	 * @package GeoDirectory
1763
+	 * @param bool $bool Default: false.
1764
+	 * @param string $slug The term slug.
1765
+	 * @param int $term_id The term ID.
1766
+	 */
1767
+	$slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id);
1768 1768
 
1769
-    if ($slug_exists) {
1769
+	if ($slug_exists) {
1770 1770
 
1771
-        $suffix = 1;
1772
-        do {
1773
-            $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1771
+		$suffix = 1;
1772
+		do {
1773
+			$new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1774 1774
 
1775
-            /** This action is documented in geodirectory_hooks_actions.php */
1776
-            $term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id);
1775
+			/** This action is documented in geodirectory_hooks_actions.php */
1776
+			$term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id);
1777 1777
 
1778
-            $suffix++;
1779
-        } while ($term_slug_check && $suffix < 100);
1778
+			$suffix++;
1779
+		} while ($term_slug_check && $suffix < 100);
1780 1780
 
1781
-        $slug = $new_slug;
1781
+		$slug = $new_slug;
1782 1782
 
1783
-        //wp_update_term( $term_id, $taxonomy, array('slug' => $slug) );
1783
+		//wp_update_term( $term_id, $taxonomy, array('slug' => $slug) );
1784 1784
 
1785
-        $wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
1785
+		$wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
1786 1786
 
1787
-    }
1787
+	}
1788 1788
 	
1789 1789
 	// Update tag in detail table.
1790 1790
 	$taxonomy_obj = get_taxonomy($taxonomy);
@@ -1825,21 +1825,21 @@  discard block
 block discarded – undo
1825 1825
 function geodir_term_slug_is_exists($slug_exists, $slug, $term_id)
1826 1826
 {
1827 1827
 
1828
-    global $wpdb, $table_prefix;
1828
+	global $wpdb, $table_prefix;
1829 1829
 
1830
-    $default_location = geodir_get_default_location();
1830
+	$default_location = geodir_get_default_location();
1831 1831
 
1832
-    $country_slug = $default_location->country_slug;
1833
-    $region_slug = $default_location->region_slug;
1834
-    $city_slug = $default_location->city_slug;
1832
+	$country_slug = $default_location->country_slug;
1833
+	$region_slug = $default_location->region_slug;
1834
+	$city_slug = $default_location->city_slug;
1835 1835
 
1836
-    if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug)
1837
-        return $slug_exists = true;
1836
+	if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug)
1837
+		return $slug_exists = true;
1838 1838
 
1839
-    if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1840
-        return $slug_exists = true;
1839
+	if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1840
+		return $slug_exists = true;
1841 1841
 
1842
-    return $slug_exists;
1842
+	return $slug_exists;
1843 1843
 }
1844 1844
 
1845 1845
 
@@ -1858,75 +1858,75 @@  discard block
 block discarded – undo
1858 1858
  */
1859 1859
 function geodir_custom_page_title($title = '', $sep = '')
1860 1860
 {
1861
-    global $wp;
1862
-    if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) {
1863
-        return $title;
1864
-    }
1861
+	global $wp;
1862
+	if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) {
1863
+		return $title;
1864
+	}
1865 1865
 
1866
-    if ($sep == '') {
1867
-        /**
1868
-         * Filter the page title separator.
1869
-         *
1870
-         * @since 1.0.0
1871
-         * @package GeoDirectory
1872
-         * @param string $sep The separator, default: `|`.
1873
-         */
1874
-        $sep = apply_filters('geodir_page_title_separator', '|');
1875
-    }
1866
+	if ($sep == '') {
1867
+		/**
1868
+		 * Filter the page title separator.
1869
+		 *
1870
+		 * @since 1.0.0
1871
+		 * @package GeoDirectory
1872
+		 * @param string $sep The separator, default: `|`.
1873
+		 */
1874
+		$sep = apply_filters('geodir_page_title_separator', '|');
1875
+	}
1876 1876
 
1877 1877
 
1878
-    $gd_page = '';
1879
-    if(geodir_is_page('home')){
1880
-        $gd_page = 'home';
1881
-        $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
1882
-    }
1883
-    elseif(geodir_is_page('detail')){
1884
-        $gd_page = 'detail';
1885
-        $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
1886
-    }
1887
-    elseif(geodir_is_page('pt')){
1888
-        $gd_page = 'pt';
1889
-        $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
1890
-    }
1891
-    elseif(geodir_is_page('listing')){
1892
-        $gd_page = 'listing';
1893
-        $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
1894
-    }
1895
-    elseif(geodir_is_page('location')){
1896
-        $gd_page = 'location';
1897
-        $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
1898
-    }
1899
-    elseif(geodir_is_page('search')){
1900
-        $gd_page = 'search';
1901
-        $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
1902
-    }
1903
-    elseif(geodir_is_page('add-listing')){
1904
-        $gd_page = 'add-listing';
1905
-        $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
1906
-    }
1907
-    elseif(geodir_is_page('author')){
1908
-        $gd_page = 'author';
1909
-        $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
1910
-    }
1911
-    elseif(geodir_is_page('login')){
1912
-        $gd_page = 'login';
1913
-        $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
1914
-    }
1915
-    elseif(geodir_is_page('listing-success')){
1916
-        $gd_page = 'listing-success';
1917
-        $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
1918
-    }
1878
+	$gd_page = '';
1879
+	if(geodir_is_page('home')){
1880
+		$gd_page = 'home';
1881
+		$title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
1882
+	}
1883
+	elseif(geodir_is_page('detail')){
1884
+		$gd_page = 'detail';
1885
+		$title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
1886
+	}
1887
+	elseif(geodir_is_page('pt')){
1888
+		$gd_page = 'pt';
1889
+		$title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
1890
+	}
1891
+	elseif(geodir_is_page('listing')){
1892
+		$gd_page = 'listing';
1893
+		$title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
1894
+	}
1895
+	elseif(geodir_is_page('location')){
1896
+		$gd_page = 'location';
1897
+		$title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
1898
+	}
1899
+	elseif(geodir_is_page('search')){
1900
+		$gd_page = 'search';
1901
+		$title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
1902
+	}
1903
+	elseif(geodir_is_page('add-listing')){
1904
+		$gd_page = 'add-listing';
1905
+		$title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
1906
+	}
1907
+	elseif(geodir_is_page('author')){
1908
+		$gd_page = 'author';
1909
+		$title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
1910
+	}
1911
+	elseif(geodir_is_page('login')){
1912
+		$gd_page = 'login';
1913
+		$title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
1914
+	}
1915
+	elseif(geodir_is_page('listing-success')){
1916
+		$gd_page = 'listing-success';
1917
+		$title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
1918
+	}
1919 1919
 
1920 1920
 
1921
-    /**
1922
-     * Filter page meta title to replace variables.
1923
-     *
1924
-     * @since 1.5.4
1925
-     * @param string $title The page title including variables.
1926
-     * @param string $gd_page The GeoDirectory page type if any.
1927
-     * @param string $sep The title separator symbol.
1928
-     */
1929
-    return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep);
1921
+	/**
1922
+	 * Filter page meta title to replace variables.
1923
+	 *
1924
+	 * @since 1.5.4
1925
+	 * @param string $title The page title including variables.
1926
+	 * @param string $gd_page The GeoDirectory page type if any.
1927
+	 * @param string $sep The title separator symbol.
1928
+	 */
1929
+	return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep);
1930 1930
 
1931 1931
 }
1932 1932
 
@@ -1942,36 +1942,36 @@  discard block
 block discarded – undo
1942 1942
 function geodir_set_post_attachment()
1943 1943
 {
1944 1944
 
1945
-    if (!get_option('geodir_set_post_attachments')) {
1945
+	if (!get_option('geodir_set_post_attachments')) {
1946 1946
 
1947
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1948
-        require_once(ABSPATH . 'wp-admin/includes/file.php');
1947
+		require_once(ABSPATH . 'wp-admin/includes/image.php');
1948
+		require_once(ABSPATH . 'wp-admin/includes/file.php');
1949 1949
 
1950
-        $all_postypes = geodir_get_posttypes();
1950
+		$all_postypes = geodir_get_posttypes();
1951 1951
 
1952
-        foreach($all_postypes as $post_type){
1953
-            $args = array(
1954
-                'posts_per_page' => -1,
1955
-                'post_type' => $post_type,
1956
-                'post_status' => 'publish');
1952
+		foreach($all_postypes as $post_type){
1953
+			$args = array(
1954
+				'posts_per_page' => -1,
1955
+				'post_type' => $post_type,
1956
+				'post_status' => 'publish');
1957 1957
 
1958
-            $posts_array = get_posts($args);
1958
+			$posts_array = get_posts($args);
1959 1959
 
1960
-            if (!empty($posts_array)) {
1960
+			if (!empty($posts_array)) {
1961 1961
 
1962
-                foreach ($posts_array as $post) {
1962
+				foreach ($posts_array as $post) {
1963 1963
 
1964
-                    geodir_set_wp_featured_image($post->ID);
1964
+					geodir_set_wp_featured_image($post->ID);
1965 1965
 
1966
-                }
1966
+				}
1967 1967
 
1968
-            }
1969
-        }
1968
+			}
1969
+		}
1970 1970
 
1971 1971
 
1972
-        update_option('geodir_set_post_attachments', '1');
1972
+		update_option('geodir_set_post_attachments', '1');
1973 1973
 
1974
-    }
1974
+	}
1975 1975
 
1976 1976
 }
1977 1977
 
@@ -1988,19 +1988,19 @@  discard block
 block discarded – undo
1988 1988
 function geodir_remove_url_seperator()
1989 1989
 {
1990 1990
 
1991
-    if (!get_option('geodir_remove_url_seperator')) {
1991
+	if (!get_option('geodir_remove_url_seperator')) {
1992 1992
 
1993
-        if (get_option('geodir_listingurl_separator'))
1994
-            delete_option('geodir_listingurl_separator');
1993
+		if (get_option('geodir_listingurl_separator'))
1994
+			delete_option('geodir_listingurl_separator');
1995 1995
 
1996
-        if (get_option('geodir_detailurl_separator'))
1997
-            delete_option('geodir_detailurl_separator');
1996
+		if (get_option('geodir_detailurl_separator'))
1997
+			delete_option('geodir_detailurl_separator');
1998 1998
 
1999
-        flush_rewrite_rules(false);
1999
+		flush_rewrite_rules(false);
2000 2000
 
2001
-        update_option('geodir_remove_url_seperator', '1');
2001
+		update_option('geodir_remove_url_seperator', '1');
2002 2002
 
2003
-    }
2003
+	}
2004 2004
 
2005 2005
 }
2006 2006
 
@@ -2016,19 +2016,19 @@  discard block
 block discarded – undo
2016 2016
  */
2017 2017
 function geodir_remove_url_seperator_form_permalink_settings($permalink_arr)
2018 2018
 {
2019
-    foreach ($permalink_arr as $key => $value) {
2019
+	foreach ($permalink_arr as $key => $value) {
2020 2020
 
2021
-        if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator')
2022
-            unset($permalink_arr[$key]);
2021
+		if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator')
2022
+			unset($permalink_arr[$key]);
2023 2023
 
2024
-    }
2024
+	}
2025 2025
 
2026
-    return $permalink_arr;
2026
+	return $permalink_arr;
2027 2027
 
2028 2028
 }
2029 2029
 
2030 2030
 if (!is_admin()) {
2031
-    add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post');
2031
+	add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post');
2032 2032
 }
2033 2033
 /**
2034 2034
  * Set status from draft to publish.
@@ -2041,16 +2041,16 @@  discard block
 block discarded – undo
2041 2041
  */
2042 2042
 function geodir_set_status_draft_to_publish_for_own_post($post)
2043 2043
 {
2044
-    $user_id = get_current_user_id();
2044
+	$user_id = get_current_user_id();
2045 2045
 
2046
-    if(!$user_id){return $post;}
2046
+	if(!$user_id){return $post;}
2047 2047
 
2048
-    $gd_post_types = geodir_get_posttypes();
2048
+	$gd_post_types = geodir_get_posttypes();
2049 2049
 
2050
-    if (!empty($post) && $post[0]->post_author == $user_id && in_array($post[0]->post_type, $gd_post_types) && !isset($_REQUEST['fl_builder'])) {
2051
-        $post[0]->post_status = 'publish';
2052
-    }
2053
-    return $post;
2050
+	if (!empty($post) && $post[0]->post_author == $user_id && in_array($post[0]->post_type, $gd_post_types) && !isset($_REQUEST['fl_builder'])) {
2051
+		$post[0]->post_status = 'publish';
2052
+	}
2053
+	return $post;
2054 2054
 }
2055 2055
 
2056 2056
 
@@ -2142,33 +2142,33 @@  discard block
 block discarded – undo
2142 2142
  */
2143 2143
 function geodir_detail_page_tab_headings_change($tabs_arr)
2144 2144
 {
2145
-    global $wpdb;
2145
+	global $wpdb;
2146 2146
 
2147
-    $post_type = geodir_get_current_posttype();
2147
+	$post_type = geodir_get_current_posttype();
2148 2148
 
2149
-    $all_postypes = geodir_get_posttypes();
2149
+	$all_postypes = geodir_get_posttypes();
2150 2150
 
2151
-    if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) {
2151
+	if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) {
2152 2152
 
2153
-        if (array_key_exists('post_video', $tabs_arr)) {
2153
+		if (array_key_exists('post_video', $tabs_arr)) {
2154 2154
 
2155
-            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2155
+			$field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2156 2156
 
2157
-            if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '')
2158
-                $tabs_arr['post_video']['heading_text'] = $field_title;
2159
-        }
2157
+			if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '')
2158
+				$tabs_arr['post_video']['heading_text'] = $field_title;
2159
+		}
2160 2160
 
2161
-        if (array_key_exists('special_offers', $tabs_arr)) {
2161
+		if (array_key_exists('special_offers', $tabs_arr)) {
2162 2162
 
2163
-            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2163
+			$field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2164 2164
 
2165
-            if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '')
2166
-                $tabs_arr['special_offers']['heading_text'] = $field_title;
2167
-        }
2165
+			if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '')
2166
+				$tabs_arr['special_offers']['heading_text'] = $field_title;
2167
+		}
2168 2168
 
2169
-    }
2169
+	}
2170 2170
 
2171
-    return $tabs_arr;
2171
+	return $tabs_arr;
2172 2172
 
2173 2173
 }
2174 2174
 
@@ -2181,10 +2181,10 @@  discard block
 block discarded – undo
2181 2181
  */
2182 2182
 function geodir_remove_template_redirect_actions()
2183 2183
 {
2184
-    if (geodir_is_page('login')){
2185
-        remove_all_actions('template_redirect');
2186
-        remove_action('init', 'avia_modify_front', 10);
2187
-    }
2184
+	if (geodir_is_page('login')){
2185
+		remove_all_actions('template_redirect');
2186
+		remove_action('init', 'avia_modify_front', 10);
2187
+	}
2188 2188
 }
2189 2189
 
2190 2190
 
@@ -2206,51 +2206,51 @@  discard block
 block discarded – undo
2206 2206
 function geodirectory_before_featured_image_delete($attachment_id)
2207 2207
 {
2208 2208
 
2209
-    global $wpdb, $plugin_prefix;
2209
+	global $wpdb, $plugin_prefix;
2210 2210
 
2211
-    $post_id = get_post_field('post_parent', $attachment_id);
2211
+	$post_id = get_post_field('post_parent', $attachment_id);
2212 2212
 
2213
-    $attachment_url = wp_get_attachment_url($attachment_id);
2213
+	$attachment_url = wp_get_attachment_url($attachment_id);
2214 2214
 
2215
-    if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) {
2215
+	if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) {
2216 2216
 
2217
-        $post_type = get_post_type($post_id);
2217
+		$post_type = get_post_type($post_id);
2218 2218
 
2219
-        $all_postypes = geodir_get_posttypes();
2219
+		$all_postypes = geodir_get_posttypes();
2220 2220
 
2221
-        if (!in_array($post_type, $all_postypes) || !is_admin())
2222
-            return false;
2221
+		if (!in_array($post_type, $all_postypes) || !is_admin())
2222
+			return false;
2223 2223
 
2224
-        $uploads = wp_upload_dir();
2224
+		$uploads = wp_upload_dir();
2225 2225
 
2226
-        $split_img_path = explode($uploads['baseurl'], $attachment_url);
2226
+		$split_img_path = explode($uploads['baseurl'], $attachment_url);
2227 2227
 
2228
-        $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
2228
+		$split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
2229 2229
 
2230
-        $wpdb->query(
2231
-            $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ",
2232
-                array($post_id, $split_img_file_path)
2233
-            )
2234
-        );
2230
+		$wpdb->query(
2231
+			$wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ",
2232
+				array($post_id, $split_img_file_path)
2233
+			)
2234
+		);
2235 2235
 
2236
-        $attachment_data = $wpdb->get_row(
2237
-            $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d",
2238
-                array($post_id)
2239
-            )
2240
-        );
2236
+		$attachment_data = $wpdb->get_row(
2237
+			$wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d",
2238
+				array($post_id)
2239
+			)
2240
+		);
2241 2241
 
2242
-        if (!empty($attachment_data)) {
2243
-            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2244
-        }
2242
+		if (!empty($attachment_data)) {
2243
+			$wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2244
+		}
2245 2245
 
2246 2246
 
2247
-        $table_name = $plugin_prefix . $post_type . '_detail';
2247
+		$table_name = $plugin_prefix . $post_type . '_detail';
2248 2248
 
2249
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id);
2249
+		$wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id);
2250 2250
 
2251
-        geodir_set_wp_featured_image($post_id);
2251
+		geodir_set_wp_featured_image($post_id);
2252 2252
 
2253
-    }
2253
+	}
2254 2254
 
2255 2255
 }
2256 2256
 
@@ -2268,79 +2268,79 @@  discard block
 block discarded – undo
2268 2268
 function geodir_temp_set_post_attachment()
2269 2269
 {
2270 2270
 
2271
-    global $wpdb, $plugin_prefix;
2271
+	global $wpdb, $plugin_prefix;
2272 2272
 
2273
-    $all_postypes = geodir_get_posttypes();
2273
+	$all_postypes = geodir_get_posttypes();
2274 2274
 
2275
-    foreach ($all_postypes as $posttype) {
2275
+	foreach ($all_postypes as $posttype) {
2276 2276
 
2277
-        $tablename = $plugin_prefix . $posttype . '_detail';
2277
+		$tablename = $plugin_prefix . $posttype . '_detail';
2278 2278
 
2279
-        $get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename);
2279
+		$get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename);
2280 2280
 
2281
-        if (!empty($get_post_data)) {
2281
+		if (!empty($get_post_data)) {
2282 2282
 
2283
-            foreach ($get_post_data as $data) {
2283
+			foreach ($get_post_data as $data) {
2284 2284
 
2285
-                $post_id = $data->post_id;
2285
+				$post_id = $data->post_id;
2286 2286
 
2287
-                $attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''");
2287
+				$attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''");
2288 2288
 
2289
-                if (!empty($attachment_data)) {
2289
+				if (!empty($attachment_data)) {
2290 2290
 
2291
-                    foreach ($attachment_data as $attach) {
2291
+					foreach ($attachment_data as $attach) {
2292 2292
 
2293
-                        $file_info = pathinfo($attach->file);
2293
+						$file_info = pathinfo($attach->file);
2294 2294
 
2295
-                        $sub_dir = '';
2296
-                        if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
2297
-                            $sub_dir = stripslashes_deep($file_info['dirname']);
2295
+						$sub_dir = '';
2296
+						if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
2297
+							$sub_dir = stripslashes_deep($file_info['dirname']);
2298 2298
 
2299
-                        $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
2300
-                        $uploads_path = $uploads['basedir'];
2299
+						$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
2300
+						$uploads_path = $uploads['basedir'];
2301 2301
 
2302
-                        $file_name = $file_info['basename'];
2302
+						$file_name = $file_info['basename'];
2303 2303
 
2304
-                        $img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name;
2304
+						$img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name;
2305 2305
 
2306
-                        if (!file_exists($img_arr['path'])) {
2306
+						if (!file_exists($img_arr['path'])) {
2307 2307
 
2308
-                            $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID);
2308
+							$wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID);
2309 2309
 
2310
-                        }
2310
+						}
2311 2311
 
2312
-                    }
2312
+					}
2313 2313
 
2314
-                    $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id");
2314
+					$attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id");
2315 2315
 
2316
-                    if (!empty($attachment_data)) {
2316
+					if (!empty($attachment_data)) {
2317 2317
 
2318
-                        if ($attachment_data->ID)
2319
-                            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2318
+						if ($attachment_data->ID)
2319
+							$wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2320 2320
 
2321
-                    } else {
2321
+					} else {
2322 2322
 
2323
-                        if (has_post_thumbnail($post_id)) {
2323
+						if (has_post_thumbnail($post_id)) {
2324 2324
 
2325
-                            $post_thumbnail_id = get_post_thumbnail_id($post_id);
2325
+							$post_thumbnail_id = get_post_thumbnail_id($post_id);
2326 2326
 
2327
-                            wp_delete_attachment($post_thumbnail_id);
2327
+							wp_delete_attachment($post_thumbnail_id);
2328 2328
 
2329
-                        }
2329
+						}
2330 2330
 
2331
-                    }
2331
+					}
2332 2332
 
2333
-                    $wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id);
2333
+					$wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id);
2334 2334
 
2335
-                    geodir_set_wp_featured_image($post_id);
2335
+					geodir_set_wp_featured_image($post_id);
2336 2336
 
2337
-                }
2337
+				}
2338 2338
 
2339
-            }
2339
+			}
2340 2340
 
2341
-        }
2341
+		}
2342 2342
 
2343
-    }
2343
+	}
2344 2344
 
2345 2345
 }
2346 2346
 
@@ -2358,9 +2358,9 @@  discard block
 block discarded – undo
2358 2358
 function geodir_default_rating_star_icon()
2359 2359
 {
2360 2360
 
2361
-    if (!get_option('geodir_default_rating_star_icon')) {
2362
-        update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png');
2363
-    }
2361
+	if (!get_option('geodir_default_rating_star_icon')) {
2362
+		update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png');
2363
+	}
2364 2364
 
2365 2365
 }
2366 2366
 
@@ -2378,27 +2378,27 @@  discard block
 block discarded – undo
2378 2378
  */
2379 2379
 function geodir_user_post_listing_count($user_id=null)
2380 2380
 {
2381
-    global $wpdb, $plugin_prefix, $current_user;
2382
-    if(!$user_id){
2383
-        $user_id = $current_user->ID;
2384
-    }
2381
+	global $wpdb, $plugin_prefix, $current_user;
2382
+	if(!$user_id){
2383
+		$user_id = $current_user->ID;
2384
+	}
2385 2385
 
2386
-    $user_id = $current_user->ID;
2387
-    $all_postypes = geodir_get_posttypes();
2388
-    $all_posts = get_option('geodir_listing_link_user_dashboard');
2386
+	$user_id = $current_user->ID;
2387
+	$all_postypes = geodir_get_posttypes();
2388
+	$all_posts = get_option('geodir_listing_link_user_dashboard');
2389 2389
 
2390
-    $user_listing = array();
2391
-    if (is_array($all_posts) && !empty($all_posts)) {
2392
-        foreach ($all_posts as $ptype) {
2393
-            $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' )");
2390
+	$user_listing = array();
2391
+	if (is_array($all_posts) && !empty($all_posts)) {
2392
+		foreach ($all_posts as $ptype) {
2393
+			$total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' )");
2394 2394
 
2395
-            if ($total_posts > 0) {
2396
-                $user_listing[$ptype] = $total_posts;
2397
-            }
2398
-        }
2399
-    }
2395
+			if ($total_posts > 0) {
2396
+				$user_listing[$ptype] = $total_posts;
2397
+			}
2398
+		}
2399
+	}
2400 2400
 
2401
-    return $user_listing;
2401
+	return $user_listing;
2402 2402
 }
2403 2403
 
2404 2404
 
@@ -2418,158 +2418,158 @@  discard block
 block discarded – undo
2418 2418
  */
2419 2419
 function geodir_detail_page_custom_field_tab($tabs_arr)
2420 2420
 {
2421
-    global $post;
2422
-
2423
-    $post_type = geodir_get_current_posttype();
2424
-    $all_postypes = geodir_get_posttypes();
2425
-
2426
-    if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) {
2427
-        $package_info = array();
2428
-        $package_info = geodir_post_package_info($package_info, $post);
2429
-        $post_package_id = $package_info->pid;
2430
-        $fields_location = 'owntab';
2431
-
2432
-        $custom_fields = geodir_post_custom_fields($post_package_id, 'custom', $post_type, $fields_location);
2433
-        if (!empty($custom_fields)) {
2434
-            $parse_custom_fields = array();
2435
-            foreach ($custom_fields as $field) {
2436
-                $field = stripslashes_deep($field); // strip slashes
2421
+	global $post;
2422
+
2423
+	$post_type = geodir_get_current_posttype();
2424
+	$all_postypes = geodir_get_posttypes();
2425
+
2426
+	if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) {
2427
+		$package_info = array();
2428
+		$package_info = geodir_post_package_info($package_info, $post);
2429
+		$post_package_id = $package_info->pid;
2430
+		$fields_location = 'owntab';
2431
+
2432
+		$custom_fields = geodir_post_custom_fields($post_package_id, 'custom', $post_type, $fields_location);
2433
+		if (!empty($custom_fields)) {
2434
+			$parse_custom_fields = array();
2435
+			foreach ($custom_fields as $field) {
2436
+				$field = stripslashes_deep($field); // strip slashes
2437 2437
                 
2438
-                $type = $field;
2439
-                $field_name = $field['htmlvar_name'];
2440
-                if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2441
-                    $post->{$field_name} = $_REQUEST[$field_name];
2442
-                }
2443
-
2444
-                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false  && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
2445
-                    if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2446
-                        continue;
2447
-                    }
2448
-
2449
-                    $parse_custom_fields[] = $field;
2450
-                }
2451
-            }
2452
-            $custom_fields = $parse_custom_fields;
2453
-        }
2438
+				$type = $field;
2439
+				$field_name = $field['htmlvar_name'];
2440
+				if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2441
+					$post->{$field_name} = $_REQUEST[$field_name];
2442
+				}
2443
+
2444
+				if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false  && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
2445
+					if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2446
+						continue;
2447
+					}
2448
+
2449
+					$parse_custom_fields[] = $field;
2450
+				}
2451
+			}
2452
+			$custom_fields = $parse_custom_fields;
2453
+		}
2454 2454
 
2455
-        if (!empty($custom_fields)) {
2456
-            $post = stripslashes_deep($post); // strip slashes
2455
+		if (!empty($custom_fields)) {
2456
+			$post = stripslashes_deep($post); // strip slashes
2457 2457
             
2458
-            $field_set_start = 0;
2459
-            $fieldset_count = 0;
2460
-            $fieldset = '';
2461
-            $total_fields = count($custom_fields);
2462
-            $count_field = 0;
2463
-            $fieldset_arr = array();
2464
-            $i = 0;
2465
-            $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL;
2466
-
2467
-            foreach ($custom_fields as $field) {
2468
-                $count_field++;
2469
-                $field_name = $field['htmlvar_name'];
2470
-                if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2471
-                    $post->{$field_name} = $_REQUEST[$field_name];
2472
-                }
2473
-
2474
-                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
2475
-                    $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title'];
2476
-                    $site_title = trim($field['site_title']);
2477
-                    $type = $field;
2478
-                    $variables_array = array();
2479
-
2480
-                    if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2481
-                        continue;
2482
-                    }
2483
-
2484
-                    if ($type['type'] != 'fieldset') {
2485
-                        $i++;
2486
-                        $variables_array['post_id'] = $post->ID;
2487
-                        $variables_array['label'] = __($type['site_title'], 'geodirectory');
2488
-                        $variables_array['value'] = '';
2489
-                        $variables_array['value'] = $post->{$type['htmlvar_name']};
2490
-                    }
2491
-
2492
-
2493
-                    $type = stripslashes_deep($type); // strip slashes
2494
-                    $html = '';
2495
-                    $html_var = '';
2496
-                    $field_icon = geodir_field_icon_proccess($type);
2497
-                    $filed_type = $type['type'];
2498
-
2499
-                    /**
2500
-                     * Filter the output for custom fields.
2501
-                     *
2502
-                     * Here we can remove or add new functions depending on the field type.
2503
-                     *
2504
-                     * @param string $html The html to be filtered (blank).
2505
-                     * @param string $fields_location The location the field is to be show.
2506
-                     * @param array $type The array of field values.
2507
-                     */
2508
-                    $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
2509
-
2510
-
2511
-                    /**
2512
-                     * Filter custom field output in tab.
2513
-                     *
2514
-                     * @since 1.5.6
2515
-                     *
2516
-                     * @param string $html_var The HTML variable name for the field.
2517
-                     * @param string $html Custom field unfiltered HTML.
2518
-                     * @param array $variables_array Custom field variables array.
2519
-                     */
2520
-                    $html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array);
2521
-
2522
-                    $fieldset_html = '';
2523
-                    if ($field_set_start == 1) {
2524
-                        $add_html = false;
2525
-                        if ($type['type'] == 'fieldset' && $fieldset_count > 1) {
2526
-                            if ($fieldset != '') {
2527
-                                $add_html = true;
2528
-                                $label = $fieldset_arr[$fieldset_count - 1]['label'];
2529
-                                $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name'];
2530
-                            }
2531
-                            $fieldset_html = $fieldset;
2532
-                            $fieldset = '';
2533
-                        } else {
2534
-                            $fieldset .= $html;
2535
-                            if ($total_fields == $count_field && $fieldset != '') {
2536
-                                $add_html = true;
2537
-                                $label = $fieldset_arr[$fieldset_count]['label'];
2538
-                                $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name'];
2539
-                                $fieldset_html = $fieldset;
2540
-                            }
2541
-                        }
2542
-
2543
-                        if ($add_html) {
2544
-                            $tabs_arr[$htmlvar_name] = array(
2545
-                                'heading_text' => __($label, 'geodirectory'),
2546
-                                'is_active_tab' => false,
2547
-                                /**
2548
-                                 * Filter if a custom field should be displayed on the details page tab.
2549
-                                 *
2550
-                                 * @since 1.0.0
2551
-                                 * @param string $htmlvar_name The field HTML var name.
2552
-                                 */
2553
-                                'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name),
2554
-                                'tab_content' => '<div class="geodir-company_info field-group">' . $fieldset_html . '</html>'
2555
-                            );
2556
-                        }
2557
-                    } else {
2558
-                        if ($html != '') {
2559
-                            $tabs_arr[$field['htmlvar_name']] = array(
2560
-                                'heading_text' => __($label, 'geodirectory'),
2561
-                                'is_active_tab' => false,
2562
-                                /** This action is documented in geodirectory_hooks_actions.php */
2563
-                                'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']),
2564
-                                'tab_content' => $html
2565
-                            );
2566
-                        }
2567
-                    }
2568
-                }
2569
-            }
2570
-        }
2571
-    }
2572
-    return $tabs_arr;
2458
+			$field_set_start = 0;
2459
+			$fieldset_count = 0;
2460
+			$fieldset = '';
2461
+			$total_fields = count($custom_fields);
2462
+			$count_field = 0;
2463
+			$fieldset_arr = array();
2464
+			$i = 0;
2465
+			$geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL;
2466
+
2467
+			foreach ($custom_fields as $field) {
2468
+				$count_field++;
2469
+				$field_name = $field['htmlvar_name'];
2470
+				if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2471
+					$post->{$field_name} = $_REQUEST[$field_name];
2472
+				}
2473
+
2474
+				if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
2475
+					$label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title'];
2476
+					$site_title = trim($field['site_title']);
2477
+					$type = $field;
2478
+					$variables_array = array();
2479
+
2480
+					if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2481
+						continue;
2482
+					}
2483
+
2484
+					if ($type['type'] != 'fieldset') {
2485
+						$i++;
2486
+						$variables_array['post_id'] = $post->ID;
2487
+						$variables_array['label'] = __($type['site_title'], 'geodirectory');
2488
+						$variables_array['value'] = '';
2489
+						$variables_array['value'] = $post->{$type['htmlvar_name']};
2490
+					}
2491
+
2492
+
2493
+					$type = stripslashes_deep($type); // strip slashes
2494
+					$html = '';
2495
+					$html_var = '';
2496
+					$field_icon = geodir_field_icon_proccess($type);
2497
+					$filed_type = $type['type'];
2498
+
2499
+					/**
2500
+					 * Filter the output for custom fields.
2501
+					 *
2502
+					 * Here we can remove or add new functions depending on the field type.
2503
+					 *
2504
+					 * @param string $html The html to be filtered (blank).
2505
+					 * @param string $fields_location The location the field is to be show.
2506
+					 * @param array $type The array of field values.
2507
+					 */
2508
+					$html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
2509
+
2510
+
2511
+					/**
2512
+					 * Filter custom field output in tab.
2513
+					 *
2514
+					 * @since 1.5.6
2515
+					 *
2516
+					 * @param string $html_var The HTML variable name for the field.
2517
+					 * @param string $html Custom field unfiltered HTML.
2518
+					 * @param array $variables_array Custom field variables array.
2519
+					 */
2520
+					$html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array);
2521
+
2522
+					$fieldset_html = '';
2523
+					if ($field_set_start == 1) {
2524
+						$add_html = false;
2525
+						if ($type['type'] == 'fieldset' && $fieldset_count > 1) {
2526
+							if ($fieldset != '') {
2527
+								$add_html = true;
2528
+								$label = $fieldset_arr[$fieldset_count - 1]['label'];
2529
+								$htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name'];
2530
+							}
2531
+							$fieldset_html = $fieldset;
2532
+							$fieldset = '';
2533
+						} else {
2534
+							$fieldset .= $html;
2535
+							if ($total_fields == $count_field && $fieldset != '') {
2536
+								$add_html = true;
2537
+								$label = $fieldset_arr[$fieldset_count]['label'];
2538
+								$htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name'];
2539
+								$fieldset_html = $fieldset;
2540
+							}
2541
+						}
2542
+
2543
+						if ($add_html) {
2544
+							$tabs_arr[$htmlvar_name] = array(
2545
+								'heading_text' => __($label, 'geodirectory'),
2546
+								'is_active_tab' => false,
2547
+								/**
2548
+								 * Filter if a custom field should be displayed on the details page tab.
2549
+								 *
2550
+								 * @since 1.0.0
2551
+								 * @param string $htmlvar_name The field HTML var name.
2552
+								 */
2553
+								'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name),
2554
+								'tab_content' => '<div class="geodir-company_info field-group">' . $fieldset_html . '</html>'
2555
+							);
2556
+						}
2557
+					} else {
2558
+						if ($html != '') {
2559
+							$tabs_arr[$field['htmlvar_name']] = array(
2560
+								'heading_text' => __($label, 'geodirectory'),
2561
+								'is_active_tab' => false,
2562
+								/** This action is documented in geodirectory_hooks_actions.php */
2563
+								'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']),
2564
+								'tab_content' => $html
2565
+							);
2566
+						}
2567
+					}
2568
+				}
2569
+			}
2570
+		}
2571
+	}
2572
+	return $tabs_arr;
2573 2573
 }
2574 2574
 
2575 2575
 /* display add listing page for wpml */
@@ -2593,37 +2593,37 @@  discard block
 block discarded – undo
2593 2593
  */
2594 2594
 function geodir_add_post_status_author_page()
2595 2595
 {
2596
-    global $wpdb, $post;
2597
-
2598
-    $html = '';
2599
-    if (get_current_user_id()) {
2600
-        if (geodir_is_page('author') && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) {
2601
-
2602
-            // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them.
2603
-            $real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID");
2604
-            $status = "<strong>(";
2605
-            $status_icon = '<i class="fa fa-play"></i>';
2606
-            if ($real_status == 'publish') {
2607
-                $status .= __('Published', 'geodirectory');
2608
-            } else {
2609
-                $status .= __('Not published', 'geodirectory');
2610
-                $status_icon = '<i class="fa fa-pause"></i>';
2611
-            }
2612
-            $status .= ")</strong>";
2596
+	global $wpdb, $post;
2597
+
2598
+	$html = '';
2599
+	if (get_current_user_id()) {
2600
+		if (geodir_is_page('author') && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) {
2601
+
2602
+			// we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them.
2603
+			$real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID");
2604
+			$status = "<strong>(";
2605
+			$status_icon = '<i class="fa fa-play"></i>';
2606
+			if ($real_status == 'publish') {
2607
+				$status .= __('Published', 'geodirectory');
2608
+			} else {
2609
+				$status .= __('Not published', 'geodirectory');
2610
+				$status_icon = '<i class="fa fa-pause"></i>';
2611
+			}
2612
+			$status .= ")</strong>";
2613 2613
 
2614
-            $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>';
2615
-        }
2616
-    }
2614
+			$html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>';
2615
+		}
2616
+	}
2617 2617
 
2618
-    if ($html != '') {
2619
-        /**
2620
-         * Filter the post status text on the author page.
2621
-         *
2622
-         * @since 1.0.0
2623
-         * @param string $html The HTML of the status.
2624
-         */
2625
-        echo apply_filters('geodir_filter_status_text_on_author_page', $html);
2626
-    }
2618
+	if ($html != '') {
2619
+		/**
2620
+		 * Filter the post status text on the author page.
2621
+		 *
2622
+		 * @since 1.0.0
2623
+		 * @param string $html The HTML of the status.
2624
+		 */
2625
+		echo apply_filters('geodir_filter_status_text_on_author_page', $html);
2626
+	}
2627 2627
 
2628 2628
 
2629 2629
 }
@@ -2637,21 +2637,21 @@  discard block
 block discarded – undo
2637 2637
  */
2638 2638
 function geodir_init_no_rating()
2639 2639
 {
2640
-    if (get_option('geodir_disable_rating')) {
2641
-        remove_action('comment_form_logged_in_after', 'geodir_comment_rating_fields');
2642
-        remove_action('comment_form_before_fields', 'geodir_comment_rating_fields');
2643
-        remove_action('comment_form_logged_in_after', 'geodir_reviewrating_comment_rating_fields');
2644
-        remove_action('comment_form_before_fields', 'geodir_reviewrating_comment_rating_fields');
2645
-        remove_action('add_meta_boxes_comment', 'geodir_comment_add_meta_box');
2646
-        remove_action('add_meta_boxes', 'geodir_reviewrating_comment_metabox', 13);
2647
-        remove_filter('comment_text', 'geodir_wrap_comment_text', 40);
2648
-
2649
-        add_action('comment_form_logged_in_after', 'geodir_no_rating_rating_fields');
2650
-        add_action('comment_form_before_fields', 'geodir_no_rating_rating_fields');
2651
-        add_filter('comment_text', 'geodir_no_rating_comment_text', 100, 2);
2652
-        add_filter('geodir_detail_page_review_rating_html', 'geodir_no_rating_review_rating_html', 100);
2653
-        add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2);
2654
-    }
2640
+	if (get_option('geodir_disable_rating')) {
2641
+		remove_action('comment_form_logged_in_after', 'geodir_comment_rating_fields');
2642
+		remove_action('comment_form_before_fields', 'geodir_comment_rating_fields');
2643
+		remove_action('comment_form_logged_in_after', 'geodir_reviewrating_comment_rating_fields');
2644
+		remove_action('comment_form_before_fields', 'geodir_reviewrating_comment_rating_fields');
2645
+		remove_action('add_meta_boxes_comment', 'geodir_comment_add_meta_box');
2646
+		remove_action('add_meta_boxes', 'geodir_reviewrating_comment_metabox', 13);
2647
+		remove_filter('comment_text', 'geodir_wrap_comment_text', 40);
2648
+
2649
+		add_action('comment_form_logged_in_after', 'geodir_no_rating_rating_fields');
2650
+		add_action('comment_form_before_fields', 'geodir_no_rating_rating_fields');
2651
+		add_filter('comment_text', 'geodir_no_rating_comment_text', 100, 2);
2652
+		add_filter('geodir_detail_page_review_rating_html', 'geodir_no_rating_review_rating_html', 100);
2653
+		add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2);
2654
+	}
2655 2655
 }
2656 2656
 
2657 2657
 /**
@@ -2663,20 +2663,20 @@  discard block
 block discarded – undo
2663 2663
  */
2664 2664
 function geodir_no_rating_rating_fields()
2665 2665
 {
2666
-    global $post;
2666
+	global $post;
2667 2667
 
2668
-    $post_types = geodir_get_posttypes();
2668
+	$post_types = geodir_get_posttypes();
2669 2669
 
2670
-    if (!empty($post) && isset($post->post_type) && in_array($post->post_type, $post_types)) {
2671
-        if (is_plugin_active('geodir_review_rating_manager/geodir_review_rating_manager.php')) {
2672
-            echo '<input type="hidden" value="1" name="geodir_rating[overall]" />';
2673
-            if (get_option('geodir_reviewrating_enable_images')) {
2674
-                geodir_reviewrating_rating_img_html();
2675
-            }
2676
-        } else {
2677
-            echo '<input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="1" />';
2678
-        }
2679
-    }
2670
+	if (!empty($post) && isset($post->post_type) && in_array($post->post_type, $post_types)) {
2671
+		if (is_plugin_active('geodir_review_rating_manager/geodir_review_rating_manager.php')) {
2672
+			echo '<input type="hidden" value="1" name="geodir_rating[overall]" />';
2673
+			if (get_option('geodir_reviewrating_enable_images')) {
2674
+				geodir_reviewrating_rating_img_html();
2675
+			}
2676
+		} else {
2677
+			echo '<input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="1" />';
2678
+		}
2679
+	}
2680 2680
 }
2681 2681
 
2682 2682
 /**
@@ -2690,11 +2690,11 @@  discard block
 block discarded – undo
2690 2690
  */
2691 2691
 function geodir_no_rating_comment_text($content, $comment = '')
2692 2692
 {
2693
-    if (!is_admin()) {
2694
-        return '<div class="description">' . $content . '</div>';
2695
-    } else {
2696
-        return $content;
2697
-    }
2693
+	if (!is_admin()) {
2694
+		return '<div class="description">' . $content . '</div>';
2695
+	} else {
2696
+		return $content;
2697
+	}
2698 2698
 }
2699 2699
 
2700 2700
 /**
@@ -2707,7 +2707,7 @@  discard block
 block discarded – undo
2707 2707
  */
2708 2708
 function geodir_no_rating_review_rating_html($content = '')
2709 2709
 {
2710
-    return NULL;
2710
+	return NULL;
2711 2711
 }
2712 2712
 
2713 2713
 /**
@@ -2721,19 +2721,19 @@  discard block
 block discarded – undo
2721 2721
  */
2722 2722
 function geodir_no_rating_get_sort_options($options, $post_type = '')
2723 2723
 {
2724
-    $new_options = array();
2725
-    if (!empty($options)) {
2726
-        foreach ($options as $option) {
2727
-            if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') {
2728
-                continue;
2729
-            }
2730
-            $new_options[] = $option;
2731
-        }
2724
+	$new_options = array();
2725
+	if (!empty($options)) {
2726
+		foreach ($options as $option) {
2727
+			if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') {
2728
+				continue;
2729
+			}
2730
+			$new_options[] = $option;
2731
+		}
2732 2732
 
2733
-        $options = $new_options;
2734
-    }
2733
+		$options = $new_options;
2734
+	}
2735 2735
 
2736
-    return $options;
2736
+	return $options;
2737 2737
 }
2738 2738
 
2739 2739
 add_filter('geodir_all_js_msg', 'geodir_all_js_msg_no_rating', 100);
@@ -2747,11 +2747,11 @@  discard block
 block discarded – undo
2747 2747
  */
2748 2748
 function geodir_all_js_msg_no_rating($msg = array())
2749 2749
 {
2750
-    if (get_option('geodir_disable_rating')) {
2751
-        $msg['gd_cmt_no_rating'] = true;
2752
-    }
2750
+	if (get_option('geodir_disable_rating')) {
2751
+		$msg['gd_cmt_no_rating'] = true;
2752
+	}
2753 2753
 
2754
-    return $msg;
2754
+	return $msg;
2755 2755
 }
2756 2756
 
2757 2757
 add_filter('body_class', 'geodir_body_class_no_rating', 100);
@@ -2765,13 +2765,13 @@  discard block
 block discarded – undo
2765 2765
  */
2766 2766
 function geodir_body_class_no_rating($classes = array())
2767 2767
 {
2768
-    if (get_option('geodir_disable_rating')) {
2769
-        $classes[] = 'gd-no-rating';
2770
-    }
2768
+	if (get_option('geodir_disable_rating')) {
2769
+		$classes[] = 'gd-no-rating';
2770
+	}
2771 2771
     
2772
-    $classes[] = 'gd-map-' . geodir_map_name();
2772
+	$classes[] = 'gd-map-' . geodir_map_name();
2773 2773
 
2774
-    return $classes;
2774
+	return $classes;
2775 2775
 }
2776 2776
 
2777 2777
 add_filter('admin_body_class', 'geodir_admin_body_class_no_rating', 100);
@@ -2785,13 +2785,13 @@  discard block
 block discarded – undo
2785 2785
  */
2786 2786
 function geodir_admin_body_class_no_rating($class = '')
2787 2787
 {
2788
-    if (get_option('geodir_disable_rating')) {
2789
-        $class .= ' gd-no-rating';
2790
-    }
2788
+	if (get_option('geodir_disable_rating')) {
2789
+		$class .= ' gd-no-rating';
2790
+	}
2791 2791
     
2792
-    $class .= ' gd-map-' . geodir_map_name();
2792
+	$class .= ' gd-map-' . geodir_map_name();
2793 2793
 
2794
-    return $class;
2794
+	return $class;
2795 2795
 }
2796 2796
 
2797 2797
 add_action('wp_head', 'geodir_wp_head_no_rating');
@@ -2804,10 +2804,10 @@  discard block
 block discarded – undo
2804 2804
  */
2805 2805
 function geodir_wp_head_no_rating()
2806 2806
 {
2807
-    if (get_option('geodir_disable_rating')) {
2808
-        echo '<style>body .geodir-rating, body .geodir-bubble-rating, body .gd_ratings_module_box{display:none!important;}</style>';
2809
-        echo '<script type="text/javascript">jQuery(function(){jQuery(".gd_rating_show").parent(".geodir-rating").remove();});</script>';
2810
-    }
2807
+	if (get_option('geodir_disable_rating')) {
2808
+		echo '<style>body .geodir-rating, body .geodir-bubble-rating, body .gd_ratings_module_box{display:none!important;}</style>';
2809
+		echo '<script type="text/javascript">jQuery(function(){jQuery(".gd_rating_show").parent(".geodir-rating").remove();});</script>';
2810
+	}
2811 2811
 }
2812 2812
 
2813 2813
 add_filter('geodir_load_db_language', 'geodir_load_custom_field_translation');
@@ -2824,36 +2824,36 @@  discard block
 block discarded – undo
2824 2824
  * @return array Translation texts.
2825 2825
  */
2826 2826
 function geodir_load_gd_options_text_translation($translation_texts = array()) {
2827
-    $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array();
2828
-
2829
-    $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin');
2830
-
2831
-    /**
2832
-     * Filters the geodirectory option names that requires to add for translation.
2833
-     *
2834
-     * @since 1.5.7
2835
-     * @package GeoDirectory
2836
-     *
2837
-     * @param  array $gd_options Array of option names.
2838
-     */
2839
-    $gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options);
2840
-    $gd_options = array_unique($gd_options);
2841
-
2842
-    if (!empty($gd_options)) {
2843
-        foreach ($gd_options as $gd_option) {
2844
-            if ($gd_option != '' && $option_value = get_option($gd_option)) {
2845
-                $option_value = is_string($option_value) ? stripslashes_deep($option_value) : '';
2827
+	$translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array();
2828
+
2829
+	$gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin');
2830
+
2831
+	/**
2832
+	 * Filters the geodirectory option names that requires to add for translation.
2833
+	 *
2834
+	 * @since 1.5.7
2835
+	 * @package GeoDirectory
2836
+	 *
2837
+	 * @param  array $gd_options Array of option names.
2838
+	 */
2839
+	$gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options);
2840
+	$gd_options = array_unique($gd_options);
2841
+
2842
+	if (!empty($gd_options)) {
2843
+		foreach ($gd_options as $gd_option) {
2844
+			if ($gd_option != '' && $option_value = get_option($gd_option)) {
2845
+				$option_value = is_string($option_value) ? stripslashes_deep($option_value) : '';
2846 2846
                 
2847
-                if ($option_value != '' && !in_array($option_value, $translation_texts)) {
2848
-                    $translation_texts[] = stripslashes_deep($option_value);
2849
-                }
2850
-            }
2851
-        }
2852
-    }
2847
+				if ($option_value != '' && !in_array($option_value, $translation_texts)) {
2848
+					$translation_texts[] = stripslashes_deep($option_value);
2849
+				}
2850
+			}
2851
+		}
2852
+	}
2853 2853
 
2854
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
2854
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
2855 2855
 
2856
-    return $translation_texts;
2856
+	return $translation_texts;
2857 2857
 }
2858 2858
 
2859 2859
 add_filter('geodir_load_db_language', 'geodir_load_gd_options_text_translation');
@@ -2867,15 +2867,15 @@  discard block
 block discarded – undo
2867 2867
 
2868 2868
 add_filter('get_comments_link', 'gd_get_comments_link', 10, 2);
2869 2869
 function gd_get_comments_link($comments_link, $post_id) {
2870
-    $post_type = get_post_type($post_id);
2870
+	$post_type = get_post_type($post_id);
2871 2871
 
2872
-    $all_postypes = geodir_get_posttypes();
2873
-    if (in_array($post_type, $all_postypes)) {
2874
-        $comments_link = str_replace('#comments', '#reviews', $comments_link);
2875
-        $comments_link = str_replace('#respond', '#reviews', $comments_link);
2876
-    }
2872
+	$all_postypes = geodir_get_posttypes();
2873
+	if (in_array($post_type, $all_postypes)) {
2874
+		$comments_link = str_replace('#comments', '#reviews', $comments_link);
2875
+		$comments_link = str_replace('#respond', '#reviews', $comments_link);
2876
+	}
2877 2877
 
2878
-    return $comments_link;
2878
+	return $comments_link;
2879 2879
 }
2880 2880
 
2881 2881
 
@@ -2893,11 +2893,11 @@  discard block
 block discarded – undo
2893 2893
 function geodir_add_nav_menu_class( $args )
2894 2894
 {
2895 2895
 
2896
-        if(isset($args['menu_class'])){
2897
-            $args['menu_class'] = $args['menu_class']." gd-menu-z";
2898
-        }
2896
+		if(isset($args['menu_class'])){
2897
+			$args['menu_class'] = $args['menu_class']." gd-menu-z";
2898
+		}
2899 2899
     
2900
-    return $args;
2900
+	return $args;
2901 2901
 }
2902 2902
 
2903 2903
 add_filter( 'wp_nav_menu_args', 'geodir_add_nav_menu_class' );
2904 2904
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/custom_fields_output_functions.php 1 patch
Indentation   +1522 added lines, -1522 removed lines patch added patch discarded remove patch
@@ -21,84 +21,84 @@  discard block
 block discarded – undo
21 21
  */
22 22
 function geodir_cf_checkbox($html,$location,$cf,$p=''){
23 23
 
24
-    // check we have the post value
25
-    if(is_int($p)){$post = geodir_get_post_info($p);}
26
-    else{ global $post;}
27
-
28
-    if(!is_array($cf) && $cf!=''){
29
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
30
-        if(!$cf){return NULL;}
31
-    }
32
-
33
-    $html_var = $cf['htmlvar_name'];
34
-
35
-    // Check if there is a location specific filter.
36
-    if(has_filter("geodir_custom_field_output_checkbox_loc_{$location}")){
37
-        /**
38
-         * Filter the checkbox html by location.
39
-         *
40
-         * @param string $html The html to filter.
41
-         * @param array $cf The custom field array.
42
-         * @since 1.6.6
43
-         */
44
-        $html = apply_filters("geodir_custom_field_output_checkbox_loc_{$location}",$html,$cf);
45
-    }
46
-
47
-    // Check if there is a custom field specific filter.
48
-    if(has_filter("geodir_custom_field_output_checkbox_var_{$html_var}")){
49
-        /**
50
-         * Filter the checkbox html by individual custom field.
51
-         *
52
-         * @param string $html The html to filter.
53
-         * @param string $location The location to output the html.
54
-         * @param array $cf The custom field array.
55
-         * @since 1.6.6
56
-         */
57
-        $html = apply_filters("geodir_custom_field_output_checkbox_var_{$html_var}",$html,$location,$cf);
58
-    }
59
-
60
-    // Check if there is a custom field key specific filter.
61
-    if(has_filter("geodir_custom_field_output_checkbox_key_{$cf['field_type_key']}")){
62
-        /**
63
-         * Filter the checkbox html by field type key.
64
-         *
65
-         * @param string $html The html to filter.
66
-         * @param string $location The location to output the html.
67
-         * @param array $cf The custom field array.
68
-         * @since 1.6.6
69
-         */
70
-        $html = apply_filters("geodir_custom_field_output_checkbox_key_{$cf['field_type_key']}",$html,$location,$cf);
71
-    }
72
-
73
-    // If not html then we run the standard output.
74
-    if(empty($html)){
75
-
76
-        if ( (int) $post->{$html_var} == 1 ):
77
-
78
-            if ( $post->{$html_var} == '1' ):
79
-                $html_val = __( 'Yes', 'geodirectory' );
80
-            else:
81
-                $html_val = __( 'No', 'geodirectory' );
82
-            endif;
83
-
84
-            $field_icon = geodir_field_icon_proccess($cf);
85
-            if (strpos($field_icon, 'http') !== false) {
86
-                $field_icon_af = '';
87
-            } elseif ($field_icon == '') {
88
-                $field_icon_af = '';
89
-            } else {
90
-                $field_icon_af = $field_icon;
91
-                $field_icon = '';
92
-            }
93
-
94
-            $html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af;
95
-            $html .= ( trim( $cf['site_title'] ) ) ? __( $cf['site_title'], 'geodirectory' ) . ': ' : '';
96
-            $html .= '</span>' . $html_val . '</div>';
97
-        endif;
98
-
99
-    }
100
-
101
-    return $html;
24
+	// check we have the post value
25
+	if(is_int($p)){$post = geodir_get_post_info($p);}
26
+	else{ global $post;}
27
+
28
+	if(!is_array($cf) && $cf!=''){
29
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
30
+		if(!$cf){return NULL;}
31
+	}
32
+
33
+	$html_var = $cf['htmlvar_name'];
34
+
35
+	// Check if there is a location specific filter.
36
+	if(has_filter("geodir_custom_field_output_checkbox_loc_{$location}")){
37
+		/**
38
+		 * Filter the checkbox html by location.
39
+		 *
40
+		 * @param string $html The html to filter.
41
+		 * @param array $cf The custom field array.
42
+		 * @since 1.6.6
43
+		 */
44
+		$html = apply_filters("geodir_custom_field_output_checkbox_loc_{$location}",$html,$cf);
45
+	}
46
+
47
+	// Check if there is a custom field specific filter.
48
+	if(has_filter("geodir_custom_field_output_checkbox_var_{$html_var}")){
49
+		/**
50
+		 * Filter the checkbox html by individual custom field.
51
+		 *
52
+		 * @param string $html The html to filter.
53
+		 * @param string $location The location to output the html.
54
+		 * @param array $cf The custom field array.
55
+		 * @since 1.6.6
56
+		 */
57
+		$html = apply_filters("geodir_custom_field_output_checkbox_var_{$html_var}",$html,$location,$cf);
58
+	}
59
+
60
+	// Check if there is a custom field key specific filter.
61
+	if(has_filter("geodir_custom_field_output_checkbox_key_{$cf['field_type_key']}")){
62
+		/**
63
+		 * Filter the checkbox html by field type key.
64
+		 *
65
+		 * @param string $html The html to filter.
66
+		 * @param string $location The location to output the html.
67
+		 * @param array $cf The custom field array.
68
+		 * @since 1.6.6
69
+		 */
70
+		$html = apply_filters("geodir_custom_field_output_checkbox_key_{$cf['field_type_key']}",$html,$location,$cf);
71
+	}
72
+
73
+	// If not html then we run the standard output.
74
+	if(empty($html)){
75
+
76
+		if ( (int) $post->{$html_var} == 1 ):
77
+
78
+			if ( $post->{$html_var} == '1' ):
79
+				$html_val = __( 'Yes', 'geodirectory' );
80
+			else:
81
+				$html_val = __( 'No', 'geodirectory' );
82
+			endif;
83
+
84
+			$field_icon = geodir_field_icon_proccess($cf);
85
+			if (strpos($field_icon, 'http') !== false) {
86
+				$field_icon_af = '';
87
+			} elseif ($field_icon == '') {
88
+				$field_icon_af = '';
89
+			} else {
90
+				$field_icon_af = $field_icon;
91
+				$field_icon = '';
92
+			}
93
+
94
+			$html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af;
95
+			$html .= ( trim( $cf['site_title'] ) ) ? __( $cf['site_title'], 'geodirectory' ) . ': ' : '';
96
+			$html .= '</span>' . $html_val . '</div>';
97
+		endif;
98
+
99
+	}
100
+
101
+	return $html;
102 102
 }
103 103
 add_filter('geodir_custom_field_output_checkbox','geodir_cf_checkbox',10,3);
104 104
 
@@ -115,71 +115,71 @@  discard block
 block discarded – undo
115 115
  */
116 116
 function geodir_cf_fieldset($html,$location,$cf,$p=''){
117 117
 
118
-    // check we have the post value
119
-    if(is_int($p)){$post = geodir_get_post_info($p);}
120
-    else{ global $post;}
121
-
122
-    if(!is_array($cf) && $cf!=''){
123
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
124
-        if(!$cf){return NULL;}
125
-    }
126
-
127
-    $html_var = $cf['htmlvar_name'];
128
-
129
-    // Check if there is a location specific filter.
130
-    if(has_filter("geodir_custom_field_output_fieldset_loc_{$location}")){
131
-        /**
132
-         * Filter the fieldset html by location.
133
-         *
134
-         * @param string $html The html to filter.
135
-         * @param array $cf The custom field array.
136
-         * @since 1.6.6
137
-         */
138
-        $html = apply_filters("geodir_custom_field_output_fieldset_loc_{$location}",$html,$cf);
139
-    }
140
-
141
-    // Check if there is a custom field specific filter.
142
-    if(has_filter("geodir_custom_field_output_fieldset_var_{$html_var}")){
143
-        /**
144
-         * Filter the fieldset html by individual custom field.
145
-         *
146
-         * @param string $html The html to filter.
147
-         * @param string $location The location to output the html.
148
-         * @param array $cf The custom field array.
149
-         * @since 1.6.6
150
-         */
151
-        $html = apply_filters("geodir_custom_field_output_fieldset_var_{$html_var}",$html,$location,$cf);
152
-    }
153
-
154
-    // Check if there is a custom field key specific filter.
155
-    if(has_filter("geodir_custom_field_output_fieldset_key_{$cf['field_type_key']}")){
156
-        /**
157
-         * Filter the fieldset html by field type key.
158
-         *
159
-         * @param string $html The html to filter.
160
-         * @param string $location The location to output the html.
161
-         * @param array $cf The custom field array.
162
-         * @since 1.6.6
163
-         */
164
-        $html = apply_filters("geodir_custom_field_output_fieldset_key_{$cf['field_type_key']}",$html,$location,$cf);
165
-    }
166
-
167
-    // If not html then we run the standard output.
168
-    if(empty($html)){
169
-
170
-        global $field_set_start;
171
-        $fieldset_class = 'fieldset-'.sanitize_title_with_dashes($cf['site_title']);
172
-
173
-        if ($field_set_start == 1) {
174
-            echo '</div><div class="geodir-company_info field-group ' . $cf['htmlvar_name'] . '"><h2 class="'.$fieldset_class.'">' . __($cf['site_title'], 'geodirectory') . '</h2>';
175
-        } else {
176
-            echo '<h2 class="'.$fieldset_class.'">' . __($cf['site_title'], 'geodirectory') . '</h2>';
177
-            $field_set_start = 1;
178
-        }
179
-
180
-    }
181
-
182
-    return $html;
118
+	// check we have the post value
119
+	if(is_int($p)){$post = geodir_get_post_info($p);}
120
+	else{ global $post;}
121
+
122
+	if(!is_array($cf) && $cf!=''){
123
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
124
+		if(!$cf){return NULL;}
125
+	}
126
+
127
+	$html_var = $cf['htmlvar_name'];
128
+
129
+	// Check if there is a location specific filter.
130
+	if(has_filter("geodir_custom_field_output_fieldset_loc_{$location}")){
131
+		/**
132
+		 * Filter the fieldset html by location.
133
+		 *
134
+		 * @param string $html The html to filter.
135
+		 * @param array $cf The custom field array.
136
+		 * @since 1.6.6
137
+		 */
138
+		$html = apply_filters("geodir_custom_field_output_fieldset_loc_{$location}",$html,$cf);
139
+	}
140
+
141
+	// Check if there is a custom field specific filter.
142
+	if(has_filter("geodir_custom_field_output_fieldset_var_{$html_var}")){
143
+		/**
144
+		 * Filter the fieldset html by individual custom field.
145
+		 *
146
+		 * @param string $html The html to filter.
147
+		 * @param string $location The location to output the html.
148
+		 * @param array $cf The custom field array.
149
+		 * @since 1.6.6
150
+		 */
151
+		$html = apply_filters("geodir_custom_field_output_fieldset_var_{$html_var}",$html,$location,$cf);
152
+	}
153
+
154
+	// Check if there is a custom field key specific filter.
155
+	if(has_filter("geodir_custom_field_output_fieldset_key_{$cf['field_type_key']}")){
156
+		/**
157
+		 * Filter the fieldset html by field type key.
158
+		 *
159
+		 * @param string $html The html to filter.
160
+		 * @param string $location The location to output the html.
161
+		 * @param array $cf The custom field array.
162
+		 * @since 1.6.6
163
+		 */
164
+		$html = apply_filters("geodir_custom_field_output_fieldset_key_{$cf['field_type_key']}",$html,$location,$cf);
165
+	}
166
+
167
+	// If not html then we run the standard output.
168
+	if(empty($html)){
169
+
170
+		global $field_set_start;
171
+		$fieldset_class = 'fieldset-'.sanitize_title_with_dashes($cf['site_title']);
172
+
173
+		if ($field_set_start == 1) {
174
+			echo '</div><div class="geodir-company_info field-group ' . $cf['htmlvar_name'] . '"><h2 class="'.$fieldset_class.'">' . __($cf['site_title'], 'geodirectory') . '</h2>';
175
+		} else {
176
+			echo '<h2 class="'.$fieldset_class.'">' . __($cf['site_title'], 'geodirectory') . '</h2>';
177
+			$field_set_start = 1;
178
+		}
179
+
180
+	}
181
+
182
+	return $html;
183 183
 }
184 184
 add_filter('geodir_custom_field_output_fieldset','geodir_cf_fieldset',10,3);
185 185
 
@@ -196,106 +196,106 @@  discard block
 block discarded – undo
196 196
  */
197 197
 function geodir_cf_url($html,$location,$cf,$p=''){
198 198
 
199
-    // check we have the post value
200
-    if(is_int($p)){$post = geodir_get_post_info($p);}
201
-    else{ global $post;}
202
-
203
-    if(!is_array($cf) && $cf!=''){
204
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
205
-        if(!$cf){return NULL;}
206
-    }
207
-
208
-    $html_var = $cf['htmlvar_name'];
209
-
210
-    // Check if there is a location specific filter.
211
-    if(has_filter("geodir_custom_field_output_url_loc_{$location}")){
212
-        /**
213
-         * Filter the url html by location.
214
-         *
215
-         * @param string $html The html to filter.
216
-         * @param array $cf The custom field array.
217
-         * @since 1.6.6
218
-         */
219
-        $html = apply_filters("geodir_custom_field_output_url_loc_{$location}",$html,$cf);
220
-    }
221
-
222
-    // Check if there is a custom field specific filter.
223
-    if(has_filter("geodir_custom_field_output_url_var_{$html_var}")){
224
-        /**
225
-         * Filter the url html by individual custom field.
226
-         *
227
-         * @param string $html The html to filter.
228
-         * @param string $location The location to output the html.
229
-         * @param array $cf The custom field array.
230
-         * @since 1.6.6
231
-         */
232
-        $html = apply_filters("geodir_custom_field_output_url_var_{$html_var}",$html,$location,$cf);
233
-    }
234
-
235
-    // Check if there is a custom field key specific filter.
236
-    if(has_filter("geodir_custom_field_output_url_key_{$cf['field_type_key']}")){
237
-        /**
238
-         * Filter the url html by field type key.
239
-         *
240
-         * @param string $html The html to filter.
241
-         * @param string $location The location to output the html.
242
-         * @param array $cf The custom field array.
243
-         * @since 1.6.6
244
-         */
245
-        $html = apply_filters("geodir_custom_field_output_url_key_{$cf['field_type_key']}",$html,$location,$cf);
246
-    }
247
-
248
-    // If not html then we run the standard output.
249
-    if(empty($html)){
250
-
251
-        if ($post->{$cf['htmlvar_name']}):
252
-
253
-            $field_icon = geodir_field_icon_proccess($cf);
254
-            if (strpos($field_icon, 'http') !== false) {
255
-                $field_icon_af = '';
256
-            } elseif ($field_icon == '') {
257
-
258
-                if ($cf['name'] == 'geodir_facebook') {
259
-                    $field_icon_af = '<i class="fa fa-facebook-square"></i>';
260
-                } elseif ($cf['name'] == 'geodir_twitter') {
261
-                    $field_icon_af = '<i class="fa fa-twitter-square"></i>';
262
-                } else {
263
-                    $field_icon_af = '<i class="fa fa-link"></i>';
264
-                }
265
-
266
-            } else {
267
-                $field_icon_af = $field_icon;
268
-                $field_icon = '';
269
-            }
270
-
271
-            $a_url = geodir_parse_custom_field_url($post->{$cf['htmlvar_name']});
272
-
273
-
274
-            $website = !empty($a_url['url']) ? $a_url['url'] : '';
275
-            $title = !empty($a_url['label']) ? $a_url['label'] : $cf['site_title'];
276
-            if(!empty($cf['default_value'])){$title = $cf['default_value'];}
277
-            $title = $title != '' ? __(stripslashes($title), 'geodirectory') : '';
278
-
279
-
280
-
281
-            // all search engines that use the nofollow value exclude links that use it from their ranking calculation
282
-            $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"';
283
-            /**
284
-             * Filter custom field website name.
285
-             *
286
-             * @since 1.0.0
287
-             *
288
-             * @param string $title Website Title.
289
-             * @param string $website Website URL.
290
-             * @param int $post->ID Post ID.
291
-             */
292
-            $html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . '<a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . apply_filters('geodir_custom_field_website_name', $title, $website, $post->ID) . '</strong></a></span></div>';
293
-
294
-        endif;
295
-
296
-    }
297
-
298
-    return $html;
199
+	// check we have the post value
200
+	if(is_int($p)){$post = geodir_get_post_info($p);}
201
+	else{ global $post;}
202
+
203
+	if(!is_array($cf) && $cf!=''){
204
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
205
+		if(!$cf){return NULL;}
206
+	}
207
+
208
+	$html_var = $cf['htmlvar_name'];
209
+
210
+	// Check if there is a location specific filter.
211
+	if(has_filter("geodir_custom_field_output_url_loc_{$location}")){
212
+		/**
213
+		 * Filter the url html by location.
214
+		 *
215
+		 * @param string $html The html to filter.
216
+		 * @param array $cf The custom field array.
217
+		 * @since 1.6.6
218
+		 */
219
+		$html = apply_filters("geodir_custom_field_output_url_loc_{$location}",$html,$cf);
220
+	}
221
+
222
+	// Check if there is a custom field specific filter.
223
+	if(has_filter("geodir_custom_field_output_url_var_{$html_var}")){
224
+		/**
225
+		 * Filter the url html by individual custom field.
226
+		 *
227
+		 * @param string $html The html to filter.
228
+		 * @param string $location The location to output the html.
229
+		 * @param array $cf The custom field array.
230
+		 * @since 1.6.6
231
+		 */
232
+		$html = apply_filters("geodir_custom_field_output_url_var_{$html_var}",$html,$location,$cf);
233
+	}
234
+
235
+	// Check if there is a custom field key specific filter.
236
+	if(has_filter("geodir_custom_field_output_url_key_{$cf['field_type_key']}")){
237
+		/**
238
+		 * Filter the url html by field type key.
239
+		 *
240
+		 * @param string $html The html to filter.
241
+		 * @param string $location The location to output the html.
242
+		 * @param array $cf The custom field array.
243
+		 * @since 1.6.6
244
+		 */
245
+		$html = apply_filters("geodir_custom_field_output_url_key_{$cf['field_type_key']}",$html,$location,$cf);
246
+	}
247
+
248
+	// If not html then we run the standard output.
249
+	if(empty($html)){
250
+
251
+		if ($post->{$cf['htmlvar_name']}):
252
+
253
+			$field_icon = geodir_field_icon_proccess($cf);
254
+			if (strpos($field_icon, 'http') !== false) {
255
+				$field_icon_af = '';
256
+			} elseif ($field_icon == '') {
257
+
258
+				if ($cf['name'] == 'geodir_facebook') {
259
+					$field_icon_af = '<i class="fa fa-facebook-square"></i>';
260
+				} elseif ($cf['name'] == 'geodir_twitter') {
261
+					$field_icon_af = '<i class="fa fa-twitter-square"></i>';
262
+				} else {
263
+					$field_icon_af = '<i class="fa fa-link"></i>';
264
+				}
265
+
266
+			} else {
267
+				$field_icon_af = $field_icon;
268
+				$field_icon = '';
269
+			}
270
+
271
+			$a_url = geodir_parse_custom_field_url($post->{$cf['htmlvar_name']});
272
+
273
+
274
+			$website = !empty($a_url['url']) ? $a_url['url'] : '';
275
+			$title = !empty($a_url['label']) ? $a_url['label'] : $cf['site_title'];
276
+			if(!empty($cf['default_value'])){$title = $cf['default_value'];}
277
+			$title = $title != '' ? __(stripslashes($title), 'geodirectory') : '';
278
+
279
+
280
+
281
+			// all search engines that use the nofollow value exclude links that use it from their ranking calculation
282
+			$rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"';
283
+			/**
284
+			 * Filter custom field website name.
285
+			 *
286
+			 * @since 1.0.0
287
+			 *
288
+			 * @param string $title Website Title.
289
+			 * @param string $website Website URL.
290
+			 * @param int $post->ID Post ID.
291
+			 */
292
+			$html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . '<a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . apply_filters('geodir_custom_field_website_name', $title, $website, $post->ID) . '</strong></a></span></div>';
293
+
294
+		endif;
295
+
296
+	}
297
+
298
+	return $html;
299 299
 }
300 300
 add_filter('geodir_custom_field_output_url','geodir_cf_url',10,3);
301 301
 
@@ -312,80 +312,80 @@  discard block
 block discarded – undo
312 312
  */
313 313
 function geodir_cf_phone($html,$location,$cf,$p=''){
314 314
 
315
-    // check we have the post value
316
-    if(is_int($p)){$post = geodir_get_post_info($p);}
317
-    else{ global $post;}
318
-
319
-    if(!is_array($cf) && $cf!=''){
320
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
321
-        if(!$cf){return NULL;}
322
-    }
323
-
324
-    $html_var = $cf['htmlvar_name'];
325
-
326
-    // Check if there is a location specific filter.
327
-    if(has_filter("geodir_custom_field_output_phone_loc_{$location}")){
328
-        /**
329
-         * Filter the phone html by location.
330
-         *
331
-         * @param string $html The html to filter.
332
-         * @param array $cf The custom field array.
333
-         * @since 1.6.6
334
-         */
335
-        $html = apply_filters("geodir_custom_field_output_phone_loc_{$location}",$html,$cf);
336
-    }
337
-
338
-    // Check if there is a custom field specific filter.
339
-    if(has_filter("geodir_custom_field_output_phone_var_{$html_var}")){
340
-        /**
341
-         * Filter the phone html by individual custom field.
342
-         *
343
-         * @param string $html The html to filter.
344
-         * @param string $location The location to output the html.
345
-         * @param array $cf The custom field array.
346
-         * @since 1.6.6
347
-         */
348
-        $html = apply_filters("geodir_custom_field_output_phone_var_{$html_var}",$html,$location,$cf);
349
-    }
350
-
351
-    // Check if there is a custom field key specific filter.
352
-    if(has_filter("geodir_custom_field_output_phone_key_{$cf['field_type_key']}")){
353
-        /**
354
-         * Filter the phone html by field type key.
355
-         *
356
-         * @param string $html The html to filter.
357
-         * @param string $location The location to output the html.
358
-         * @param array $cf The custom field array.
359
-         * @since 1.6.6
360
-         */
361
-        $html = apply_filters("geodir_custom_field_output_phone_key_{$cf['field_type_key']}",$html,$location,$cf);
362
-    }
363
-
364
-    // If not html then we run the standard output.
365
-    if(empty($html)){
366
-
367
-        if ($post->{$cf['htmlvar_name']}):
368
-
369
-            $field_icon = geodir_field_icon_proccess($cf);
370
-            if (strpos($field_icon, 'http') !== false) {
371
-                $field_icon_af = '';
372
-            } elseif ($field_icon == '') {
373
-                $field_icon_af = '<i class="fa fa-phone"></i>';
374
-            } else {
375
-                $field_icon_af = $field_icon;
376
-                $field_icon = '';
377
-            }
378
-
379
-
380
-            $html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af .
381
-                    $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '&nbsp;';
382
-            $html .= '</span><a href="tel:' . preg_replace('/[^0-9+]/', '', $post->{$cf['htmlvar_name']}) . '">' . $post->{$cf['htmlvar_name']} . '</a></div>';
383
-
384
-        endif;
385
-
386
-    }
387
-
388
-    return $html;
315
+	// check we have the post value
316
+	if(is_int($p)){$post = geodir_get_post_info($p);}
317
+	else{ global $post;}
318
+
319
+	if(!is_array($cf) && $cf!=''){
320
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
321
+		if(!$cf){return NULL;}
322
+	}
323
+
324
+	$html_var = $cf['htmlvar_name'];
325
+
326
+	// Check if there is a location specific filter.
327
+	if(has_filter("geodir_custom_field_output_phone_loc_{$location}")){
328
+		/**
329
+		 * Filter the phone html by location.
330
+		 *
331
+		 * @param string $html The html to filter.
332
+		 * @param array $cf The custom field array.
333
+		 * @since 1.6.6
334
+		 */
335
+		$html = apply_filters("geodir_custom_field_output_phone_loc_{$location}",$html,$cf);
336
+	}
337
+
338
+	// Check if there is a custom field specific filter.
339
+	if(has_filter("geodir_custom_field_output_phone_var_{$html_var}")){
340
+		/**
341
+		 * Filter the phone html by individual custom field.
342
+		 *
343
+		 * @param string $html The html to filter.
344
+		 * @param string $location The location to output the html.
345
+		 * @param array $cf The custom field array.
346
+		 * @since 1.6.6
347
+		 */
348
+		$html = apply_filters("geodir_custom_field_output_phone_var_{$html_var}",$html,$location,$cf);
349
+	}
350
+
351
+	// Check if there is a custom field key specific filter.
352
+	if(has_filter("geodir_custom_field_output_phone_key_{$cf['field_type_key']}")){
353
+		/**
354
+		 * Filter the phone html by field type key.
355
+		 *
356
+		 * @param string $html The html to filter.
357
+		 * @param string $location The location to output the html.
358
+		 * @param array $cf The custom field array.
359
+		 * @since 1.6.6
360
+		 */
361
+		$html = apply_filters("geodir_custom_field_output_phone_key_{$cf['field_type_key']}",$html,$location,$cf);
362
+	}
363
+
364
+	// If not html then we run the standard output.
365
+	if(empty($html)){
366
+
367
+		if ($post->{$cf['htmlvar_name']}):
368
+
369
+			$field_icon = geodir_field_icon_proccess($cf);
370
+			if (strpos($field_icon, 'http') !== false) {
371
+				$field_icon_af = '';
372
+			} elseif ($field_icon == '') {
373
+				$field_icon_af = '<i class="fa fa-phone"></i>';
374
+			} else {
375
+				$field_icon_af = $field_icon;
376
+				$field_icon = '';
377
+			}
378
+
379
+
380
+			$html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af .
381
+					$html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '&nbsp;';
382
+			$html .= '</span><a href="tel:' . preg_replace('/[^0-9+]/', '', $post->{$cf['htmlvar_name']}) . '">' . $post->{$cf['htmlvar_name']} . '</a></div>';
383
+
384
+		endif;
385
+
386
+	}
387
+
388
+	return $html;
389 389
 }
390 390
 add_filter('geodir_custom_field_output_phone','geodir_cf_phone',10,3);
391 391
 
@@ -402,85 +402,85 @@  discard block
 block discarded – undo
402 402
  */
403 403
 function geodir_cf_time($html,$location,$cf,$p=''){
404 404
 
405
-    // check we have the post value
406
-    if(is_int($p)){$post = geodir_get_post_info($p);}
407
-    else{ global $post;}
408
-
409
-    if(!is_array($cf) && $cf!=''){
410
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
411
-        if(!$cf){return NULL;}
412
-    }
413
-
414
-    $html_var = $cf['htmlvar_name'];
415
-
416
-    // Check if there is a location specific filter.
417
-    if(has_filter("geodir_custom_field_output_time_loc_{$location}")){
418
-        /**
419
-         * Filter the time html by location.
420
-         *
421
-         * @param string $html The html to filter.
422
-         * @param array $cf The custom field array.
423
-         * @since 1.6.6
424
-         */
425
-        $html = apply_filters("geodir_custom_field_output_time_loc_{$location}",$html,$cf);
426
-    }
427
-
428
-    // Check if there is a custom field specific filter.
429
-    if(has_filter("geodir_custom_field_output_time_var_{$html_var}")){
430
-        /**
431
-         * Filter the time html by individual custom field.
432
-         *
433
-         * @param string $html The html to filter.
434
-         * @param string $location The location to output the html.
435
-         * @param array $cf The custom field array.
436
-         * @since 1.6.6
437
-         */
438
-        $html = apply_filters("geodir_custom_field_output_time_var_{$html_var}",$html,$location,$cf);
439
-    }
440
-
441
-    // Check if there is a custom field key specific filter.
442
-    if(has_filter("geodir_custom_field_output_time_key_{$cf['field_type_key']}")){
443
-        /**
444
-         * Filter the time html by field type key.
445
-         *
446
-         * @param string $html The html to filter.
447
-         * @param string $location The location to output the html.
448
-         * @param array $cf The custom field array.
449
-         * @since 1.6.6
450
-         */
451
-        $html = apply_filters("geodir_custom_field_output_time_key_{$cf['field_type_key']}",$html,$location,$cf);
452
-    }
453
-
454
-    // If not html then we run the standard output.
455
-    if(empty($html)){
456
-
457
-        if ($post->{$cf['htmlvar_name']}):
458
-
459
-            $value = '';
460
-            if ($post->{$cf['htmlvar_name']} != '')
461
-                //$value = date('h:i',strtotime($post->{$cf['htmlvar_name']}));
462
-                $value = date(get_option('time_format'), strtotime($post->{$cf['htmlvar_name']}));
463
-
464
-            $field_icon = geodir_field_icon_proccess($cf);
465
-            if (strpos($field_icon, 'http') !== false) {
466
-                $field_icon_af = '';
467
-            } elseif ($field_icon == '') {
468
-                $field_icon_af = '<i class="fa fa-clock-o"></i>';
469
-            } else {
470
-                $field_icon_af = $field_icon;
471
-                $field_icon = '';
472
-            }
473
-
474
-
475
-            $html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af;
476
-            $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '&nbsp;';
477
-            $html .= '</span>' . $value . '</div>';
478
-
479
-        endif;
480
-
481
-    }
482
-
483
-    return $html;
405
+	// check we have the post value
406
+	if(is_int($p)){$post = geodir_get_post_info($p);}
407
+	else{ global $post;}
408
+
409
+	if(!is_array($cf) && $cf!=''){
410
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
411
+		if(!$cf){return NULL;}
412
+	}
413
+
414
+	$html_var = $cf['htmlvar_name'];
415
+
416
+	// Check if there is a location specific filter.
417
+	if(has_filter("geodir_custom_field_output_time_loc_{$location}")){
418
+		/**
419
+		 * Filter the time html by location.
420
+		 *
421
+		 * @param string $html The html to filter.
422
+		 * @param array $cf The custom field array.
423
+		 * @since 1.6.6
424
+		 */
425
+		$html = apply_filters("geodir_custom_field_output_time_loc_{$location}",$html,$cf);
426
+	}
427
+
428
+	// Check if there is a custom field specific filter.
429
+	if(has_filter("geodir_custom_field_output_time_var_{$html_var}")){
430
+		/**
431
+		 * Filter the time html by individual custom field.
432
+		 *
433
+		 * @param string $html The html to filter.
434
+		 * @param string $location The location to output the html.
435
+		 * @param array $cf The custom field array.
436
+		 * @since 1.6.6
437
+		 */
438
+		$html = apply_filters("geodir_custom_field_output_time_var_{$html_var}",$html,$location,$cf);
439
+	}
440
+
441
+	// Check if there is a custom field key specific filter.
442
+	if(has_filter("geodir_custom_field_output_time_key_{$cf['field_type_key']}")){
443
+		/**
444
+		 * Filter the time html by field type key.
445
+		 *
446
+		 * @param string $html The html to filter.
447
+		 * @param string $location The location to output the html.
448
+		 * @param array $cf The custom field array.
449
+		 * @since 1.6.6
450
+		 */
451
+		$html = apply_filters("geodir_custom_field_output_time_key_{$cf['field_type_key']}",$html,$location,$cf);
452
+	}
453
+
454
+	// If not html then we run the standard output.
455
+	if(empty($html)){
456
+
457
+		if ($post->{$cf['htmlvar_name']}):
458
+
459
+			$value = '';
460
+			if ($post->{$cf['htmlvar_name']} != '')
461
+				//$value = date('h:i',strtotime($post->{$cf['htmlvar_name']}));
462
+				$value = date(get_option('time_format'), strtotime($post->{$cf['htmlvar_name']}));
463
+
464
+			$field_icon = geodir_field_icon_proccess($cf);
465
+			if (strpos($field_icon, 'http') !== false) {
466
+				$field_icon_af = '';
467
+			} elseif ($field_icon == '') {
468
+				$field_icon_af = '<i class="fa fa-clock-o"></i>';
469
+			} else {
470
+				$field_icon_af = $field_icon;
471
+				$field_icon = '';
472
+			}
473
+
474
+
475
+			$html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af;
476
+			$html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '&nbsp;';
477
+			$html .= '</span>' . $value . '</div>';
478
+
479
+		endif;
480
+
481
+	}
482
+
483
+	return $html;
484 484
 }
485 485
 add_filter('geodir_custom_field_output_time','geodir_cf_time',10,3);
486 486
 
@@ -497,107 +497,107 @@  discard block
 block discarded – undo
497 497
  */
498 498
 function geodir_cf_datepicker($html,$location,$cf,$p=''){
499 499
 
500
-    // check we have the post value
501
-    if(is_int($p)){$post = geodir_get_post_info($p);}
502
-    else{ global $post;}
503
-
504
-    if(!is_array($cf) && $cf!=''){
505
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
506
-        if(!$cf){return NULL;}
507
-    }
508
-
509
-    $html_var = $cf['htmlvar_name'];
510
-
511
-    // Check if there is a location specific filter.
512
-    if(has_filter("geodir_custom_field_output_datepicker_loc_{$location}")){
513
-        /**
514
-         * Filter the datepicker html by location.
515
-         *
516
-         * @param string $html The html to filter.
517
-         * @param array $cf The custom field array.
518
-         * @since 1.6.6
519
-         */
520
-        $html = apply_filters("geodir_custom_field_output_datepicker_loc_{$location}",$html,$cf);
521
-    }
522
-
523
-    // Check if there is a custom field specific filter.
524
-    if(has_filter("geodir_custom_field_output_datepicker_var_{$html_var}")){
525
-        /**
526
-         * Filter the datepicker html by individual custom field.
527
-         *
528
-         * @param string $html The html to filter.
529
-         * @param string $location The location to output the html.
530
-         * @param array $cf The custom field array.
531
-         * @since 1.6.6
532
-         */
533
-        $html = apply_filters("geodir_custom_field_output_datepicker_var_{$html_var}",$html,$location,$cf);
534
-    }
535
-
536
-    // Check if there is a custom field key specific filter.
537
-    if(has_filter("geodir_custom_field_output_datepicker_key_{$cf['field_type_key']}")){
538
-        /**
539
-         * Filter the datepicker html by field type key.
540
-         *
541
-         * @param string $html The html to filter.
542
-         * @param string $location The location to output the html.
543
-         * @param array $cf The custom field array.
544
-         * @since 1.6.6
545
-         */
546
-        $html = apply_filters("geodir_custom_field_output_datepicker_key_{$cf['field_type_key']}",$html,$location,$cf);
547
-    }
548
-
549
-    // If not html then we run the standard output.
550
-    if(empty($html)){
551
-
552
-        if ($post->{$cf['htmlvar_name']}):
553
-
554
-            $date_format = geodir_default_date_format();
555
-            if ($cf['extra_fields'] != '') {
556
-                $date_format = unserialize($cf['extra_fields']);
557
-                $date_format = $date_format['date_format'];
558
-            }
559
-            // check if we need to change the format or not
560
-            $date_format_len = strlen(str_replace(' ', '', $date_format));
561
-            if($date_format_len>5){// if greater then 4 then it's the old style format.
562
-
563
-                $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
564
-                $replace = array('d','j','l','m','n','F','Y');//PHP date format
565
-
566
-                $date_format = str_replace($search, $replace, $date_format);
567
-
568
-                $post_htmlvar_value = ($date_format == 'd/m/Y' || $date_format == 'j/n/Y' ) ? str_replace('/', '-', $post->{$cf['htmlvar_name']}) : $post->{$cf['htmlvar_name']}; // PHP doesn't work well with dd/mm/yyyy format
569
-            }else{
570
-                $post_htmlvar_value = $post->{$cf['htmlvar_name']};
571
-            }
572
-
573
-            if ($post->{$cf['htmlvar_name']} != '' && $post->{$cf['htmlvar_name']}!="0000-00-00") {
574
-                $value = date_i18n($date_format, strtotime($post_htmlvar_value));
575
-            }else{
576
-                return '';
577
-            }
578
-
579
-            $field_icon = geodir_field_icon_proccess($cf);
580
-
581
-            if (strpos($field_icon, 'http') !== false) {
582
-                $field_icon_af = '';
583
-            } elseif ($field_icon == '') {
584
-                $field_icon_af = '<i class="fa fa-calendar"></i>';
585
-            } else {
586
-                $field_icon_af = $field_icon;
587
-                $field_icon = '';
588
-            }
589
-
590
-
591
-
592
-            $html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af;
593
-            $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
594
-            $html .= '</span>' . $value . '</div>';
595
-
596
-        endif;
597
-
598
-    }
599
-
600
-    return $html;
500
+	// check we have the post value
501
+	if(is_int($p)){$post = geodir_get_post_info($p);}
502
+	else{ global $post;}
503
+
504
+	if(!is_array($cf) && $cf!=''){
505
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
506
+		if(!$cf){return NULL;}
507
+	}
508
+
509
+	$html_var = $cf['htmlvar_name'];
510
+
511
+	// Check if there is a location specific filter.
512
+	if(has_filter("geodir_custom_field_output_datepicker_loc_{$location}")){
513
+		/**
514
+		 * Filter the datepicker html by location.
515
+		 *
516
+		 * @param string $html The html to filter.
517
+		 * @param array $cf The custom field array.
518
+		 * @since 1.6.6
519
+		 */
520
+		$html = apply_filters("geodir_custom_field_output_datepicker_loc_{$location}",$html,$cf);
521
+	}
522
+
523
+	// Check if there is a custom field specific filter.
524
+	if(has_filter("geodir_custom_field_output_datepicker_var_{$html_var}")){
525
+		/**
526
+		 * Filter the datepicker html by individual custom field.
527
+		 *
528
+		 * @param string $html The html to filter.
529
+		 * @param string $location The location to output the html.
530
+		 * @param array $cf The custom field array.
531
+		 * @since 1.6.6
532
+		 */
533
+		$html = apply_filters("geodir_custom_field_output_datepicker_var_{$html_var}",$html,$location,$cf);
534
+	}
535
+
536
+	// Check if there is a custom field key specific filter.
537
+	if(has_filter("geodir_custom_field_output_datepicker_key_{$cf['field_type_key']}")){
538
+		/**
539
+		 * Filter the datepicker html by field type key.
540
+		 *
541
+		 * @param string $html The html to filter.
542
+		 * @param string $location The location to output the html.
543
+		 * @param array $cf The custom field array.
544
+		 * @since 1.6.6
545
+		 */
546
+		$html = apply_filters("geodir_custom_field_output_datepicker_key_{$cf['field_type_key']}",$html,$location,$cf);
547
+	}
548
+
549
+	// If not html then we run the standard output.
550
+	if(empty($html)){
551
+
552
+		if ($post->{$cf['htmlvar_name']}):
553
+
554
+			$date_format = geodir_default_date_format();
555
+			if ($cf['extra_fields'] != '') {
556
+				$date_format = unserialize($cf['extra_fields']);
557
+				$date_format = $date_format['date_format'];
558
+			}
559
+			// check if we need to change the format or not
560
+			$date_format_len = strlen(str_replace(' ', '', $date_format));
561
+			if($date_format_len>5){// if greater then 4 then it's the old style format.
562
+
563
+				$search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
564
+				$replace = array('d','j','l','m','n','F','Y');//PHP date format
565
+
566
+				$date_format = str_replace($search, $replace, $date_format);
567
+
568
+				$post_htmlvar_value = ($date_format == 'd/m/Y' || $date_format == 'j/n/Y' ) ? str_replace('/', '-', $post->{$cf['htmlvar_name']}) : $post->{$cf['htmlvar_name']}; // PHP doesn't work well with dd/mm/yyyy format
569
+			}else{
570
+				$post_htmlvar_value = $post->{$cf['htmlvar_name']};
571
+			}
572
+
573
+			if ($post->{$cf['htmlvar_name']} != '' && $post->{$cf['htmlvar_name']}!="0000-00-00") {
574
+				$value = date_i18n($date_format, strtotime($post_htmlvar_value));
575
+			}else{
576
+				return '';
577
+			}
578
+
579
+			$field_icon = geodir_field_icon_proccess($cf);
580
+
581
+			if (strpos($field_icon, 'http') !== false) {
582
+				$field_icon_af = '';
583
+			} elseif ($field_icon == '') {
584
+				$field_icon_af = '<i class="fa fa-calendar"></i>';
585
+			} else {
586
+				$field_icon_af = $field_icon;
587
+				$field_icon = '';
588
+			}
589
+
590
+
591
+
592
+			$html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af;
593
+			$html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
594
+			$html .= '</span>' . $value . '</div>';
595
+
596
+		endif;
597
+
598
+	}
599
+
600
+	return $html;
601 601
 }
602 602
 add_filter('geodir_custom_field_output_datepicker','geodir_cf_datepicker',10,3);
603 603
 
@@ -614,84 +614,84 @@  discard block
 block discarded – undo
614 614
  */
615 615
 function geodir_cf_text($html,$location,$cf,$p=''){
616 616
 
617
-    // check we have the post value
618
-    if(is_int($p)){$post = geodir_get_post_info($p);}
619
-    else{ global $post;}
620
-
621
-    if(!is_array($cf) && $cf!=''){
622
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
623
-        if(!$cf){return NULL;}
624
-    }
625
-
626
-    $html_var = $cf['htmlvar_name'];
627
-
628
-    // Check if there is a location specific filter.
629
-    if(has_filter("geodir_custom_field_output_text_loc_{$location}")){
630
-        /**
631
-         * Filter the text html by location.
632
-         *
633
-         * @param string $html The html to filter.
634
-         * @param array $cf The custom field array.
635
-         * @since 1.6.6
636
-         */
637
-        $html = apply_filters("geodir_custom_field_output_text_loc_{$location}",$html,$cf);
638
-    }
639
-
640
-    // Check if there is a custom field specific filter.
641
-    if(has_filter("geodir_custom_field_output_text_var_{$html_var}")){
642
-        /**
643
-         * Filter the text html by individual custom field.
644
-         *
645
-         * @param string $html The html to filter.
646
-         * @param string $location The location to output the html.
647
-         * @param array $cf The custom field array.
648
-         * @since 1.6.6
649
-         */
650
-        $html = apply_filters("geodir_custom_field_output_text_var_{$html_var}",$html,$location,$cf);
651
-    }
652
-
653
-    // Check if there is a custom field key specific filter.
654
-    if(has_filter("geodir_custom_field_output_text_key_{$cf['field_type_key']}")){
655
-        /**
656
-         * Filter the text html by field type key.
657
-         *
658
-         * @param string $html The html to filter.
659
-         * @param string $location The location to output the html.
660
-         * @param array $cf The custom field array.
661
-         * @since 1.6.6
662
-         */
663
-        $html = apply_filters("geodir_custom_field_output_text_key_{$cf['field_type_key']}",$html,$location,$cf);
664
-    }
617
+	// check we have the post value
618
+	if(is_int($p)){$post = geodir_get_post_info($p);}
619
+	else{ global $post;}
620
+
621
+	if(!is_array($cf) && $cf!=''){
622
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
623
+		if(!$cf){return NULL;}
624
+	}
625
+
626
+	$html_var = $cf['htmlvar_name'];
627
+
628
+	// Check if there is a location specific filter.
629
+	if(has_filter("geodir_custom_field_output_text_loc_{$location}")){
630
+		/**
631
+		 * Filter the text html by location.
632
+		 *
633
+		 * @param string $html The html to filter.
634
+		 * @param array $cf The custom field array.
635
+		 * @since 1.6.6
636
+		 */
637
+		$html = apply_filters("geodir_custom_field_output_text_loc_{$location}",$html,$cf);
638
+	}
639
+
640
+	// Check if there is a custom field specific filter.
641
+	if(has_filter("geodir_custom_field_output_text_var_{$html_var}")){
642
+		/**
643
+		 * Filter the text html by individual custom field.
644
+		 *
645
+		 * @param string $html The html to filter.
646
+		 * @param string $location The location to output the html.
647
+		 * @param array $cf The custom field array.
648
+		 * @since 1.6.6
649
+		 */
650
+		$html = apply_filters("geodir_custom_field_output_text_var_{$html_var}",$html,$location,$cf);
651
+	}
652
+
653
+	// Check if there is a custom field key specific filter.
654
+	if(has_filter("geodir_custom_field_output_text_key_{$cf['field_type_key']}")){
655
+		/**
656
+		 * Filter the text html by field type key.
657
+		 *
658
+		 * @param string $html The html to filter.
659
+		 * @param string $location The location to output the html.
660
+		 * @param array $cf The custom field array.
661
+		 * @since 1.6.6
662
+		 */
663
+		$html = apply_filters("geodir_custom_field_output_text_key_{$cf['field_type_key']}",$html,$location,$cf);
664
+	}
665 665
 
666 666
     
667 667
 
668
-    // If not html then we run the standard output.
669
-    if(empty($html)){
668
+	// If not html then we run the standard output.
669
+	if(empty($html)){
670 670
 
671
-        if (isset($post->{$cf['htmlvar_name']}) && $post->{$cf['htmlvar_name']} != '' ):
671
+		if (isset($post->{$cf['htmlvar_name']}) && $post->{$cf['htmlvar_name']} != '' ):
672 672
 
673
-            $class = ($cf['htmlvar_name'] == 'geodir_timing') ? "geodir-i-time" : "geodir-i-text";
673
+			$class = ($cf['htmlvar_name'] == 'geodir_timing') ? "geodir-i-time" : "geodir-i-text";
674 674
 
675
-            $field_icon = geodir_field_icon_proccess($cf);
676
-            if (strpos($field_icon, 'http') !== false) {
677
-                $field_icon_af = '';
678
-            } elseif ($field_icon == '') {
679
-                $field_icon_af = ($cf['htmlvar_name'] == 'geodir_timing') ? '<i class="fa fa-clock-o"></i>' : "";
680
-            } else {
681
-                $field_icon_af = $field_icon;
682
-                $field_icon = '';
683
-            }
675
+			$field_icon = geodir_field_icon_proccess($cf);
676
+			if (strpos($field_icon, 'http') !== false) {
677
+				$field_icon_af = '';
678
+			} elseif ($field_icon == '') {
679
+				$field_icon_af = ($cf['htmlvar_name'] == 'geodir_timing') ? '<i class="fa fa-clock-o"></i>' : "";
680
+			} else {
681
+				$field_icon_af = $field_icon;
682
+				$field_icon = '';
683
+			}
684 684
 
685 685
 
686
-            $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="'.$class.'" style="' . $field_icon . '">' . $field_icon_af;
687
-            $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
688
-            $html .= '</span>' . $post->{$cf['htmlvar_name']} . '</div>';
686
+			$html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="'.$class.'" style="' . $field_icon . '">' . $field_icon_af;
687
+			$html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
688
+			$html .= '</span>' . $post->{$cf['htmlvar_name']} . '</div>';
689 689
 
690
-        endif;
690
+		endif;
691 691
 
692
-    }
692
+	}
693 693
 
694
-    return $html;
694
+	return $html;
695 695
 }
696 696
 add_filter('geodir_custom_field_output_text','geodir_cf_text',10,3);
697 697
 
@@ -708,98 +708,98 @@  discard block
 block discarded – undo
708 708
  */
709 709
 function geodir_cf_radio($html,$location,$cf,$p=''){
710 710
 
711
-    // check we have the post value
712
-    if(is_int($p)){$post = geodir_get_post_info($p);}
713
-    else{ global $post;}
714
-
715
-    if(!is_array($cf) && $cf!=''){
716
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
717
-        if(!$cf){return NULL;}
718
-    }
719
-
720
-    $html_var = $cf['htmlvar_name'];
721
-
722
-    // Check if there is a location specific filter.
723
-    if(has_filter("geodir_custom_field_output_radio_loc_{$location}")){
724
-        /**
725
-         * Filter the radio html by location.
726
-         *
727
-         * @param string $html The html to filter.
728
-         * @param array $cf The custom field array.
729
-         * @since 1.6.6
730
-         */
731
-        $html = apply_filters("geodir_custom_field_output_radio_loc_{$location}",$html,$cf);
732
-    }
733
-
734
-    // Check if there is a custom field specific filter.
735
-    if(has_filter("geodir_custom_field_output_radio_var_{$html_var}")){
736
-        /**
737
-         * Filter the radio html by individual custom field.
738
-         *
739
-         * @param string $html The html to filter.
740
-         * @param string $location The location to output the html.
741
-         * @param array $cf The custom field array.
742
-         * @since 1.6.6
743
-         */
744
-        $html = apply_filters("geodir_custom_field_output_radio_var_{$html_var}",$html,$location,$cf);
745
-    }
746
-
747
-    // Check if there is a custom field key specific filter.
748
-    if(has_filter("geodir_custom_field_output_radio_key_{$cf['field_type_key']}")){
749
-        /**
750
-         * Filter the radio html by field type key.
751
-         *
752
-         * @param string $html The html to filter.
753
-         * @param string $location The location to output the html.
754
-         * @param array $cf The custom field array.
755
-         * @since 1.6.6
756
-         */
757
-        $html = apply_filters("geodir_custom_field_output_radio_key_{$cf['field_type_key']}",$html,$location,$cf);
758
-    }
759
-
760
-    // If not html then we run the standard output.
761
-    if(empty($html)){
762
-
763
-        $html_val = __($post->{$cf['htmlvar_name']}, 'geodirectory');
764
-        if ($post->{$cf['htmlvar_name']} != ''):
765
-
766
-            if ($post->{$cf['htmlvar_name']} == 'f' || $post->{$cf['htmlvar_name']} == '0') {
767
-                $html_val = __('No', 'geodirectory');
768
-            } else if ($post->{$cf['htmlvar_name']} == 't' || $post->{$cf['htmlvar_name']} == '1') {
769
-                $html_val = __('Yes', 'geodirectory');
770
-            } else {
771
-                if (!empty($cf['option_values'])) {
772
-                    $cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true);
773
-
774
-                    if (!empty($cf_option_values)) {
775
-                        foreach ($cf_option_values as $cf_option_value) {
776
-                            if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$cf['htmlvar_name']}) {
777
-                                $html_val = $cf_option_value['label'];
778
-                            }
779
-                        }
780
-                    }
781
-                }
782
-            }
783
-
784
-            $field_icon = geodir_field_icon_proccess($cf);
785
-            if (strpos($field_icon, 'http') !== false) {
786
-                $field_icon_af = '';
787
-            } elseif ($field_icon == '') {
788
-                $field_icon_af = '';
789
-            } else {
790
-                $field_icon_af = $field_icon;
791
-                $field_icon = '';
792
-            }
793
-
794
-
795
-            $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af;
796
-            $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
797
-            $html .= '</span>' . $html_val . '</div>';
798
-        endif;
799
-
800
-    }
801
-
802
-    return $html;
711
+	// check we have the post value
712
+	if(is_int($p)){$post = geodir_get_post_info($p);}
713
+	else{ global $post;}
714
+
715
+	if(!is_array($cf) && $cf!=''){
716
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
717
+		if(!$cf){return NULL;}
718
+	}
719
+
720
+	$html_var = $cf['htmlvar_name'];
721
+
722
+	// Check if there is a location specific filter.
723
+	if(has_filter("geodir_custom_field_output_radio_loc_{$location}")){
724
+		/**
725
+		 * Filter the radio html by location.
726
+		 *
727
+		 * @param string $html The html to filter.
728
+		 * @param array $cf The custom field array.
729
+		 * @since 1.6.6
730
+		 */
731
+		$html = apply_filters("geodir_custom_field_output_radio_loc_{$location}",$html,$cf);
732
+	}
733
+
734
+	// Check if there is a custom field specific filter.
735
+	if(has_filter("geodir_custom_field_output_radio_var_{$html_var}")){
736
+		/**
737
+		 * Filter the radio html by individual custom field.
738
+		 *
739
+		 * @param string $html The html to filter.
740
+		 * @param string $location The location to output the html.
741
+		 * @param array $cf The custom field array.
742
+		 * @since 1.6.6
743
+		 */
744
+		$html = apply_filters("geodir_custom_field_output_radio_var_{$html_var}",$html,$location,$cf);
745
+	}
746
+
747
+	// Check if there is a custom field key specific filter.
748
+	if(has_filter("geodir_custom_field_output_radio_key_{$cf['field_type_key']}")){
749
+		/**
750
+		 * Filter the radio html by field type key.
751
+		 *
752
+		 * @param string $html The html to filter.
753
+		 * @param string $location The location to output the html.
754
+		 * @param array $cf The custom field array.
755
+		 * @since 1.6.6
756
+		 */
757
+		$html = apply_filters("geodir_custom_field_output_radio_key_{$cf['field_type_key']}",$html,$location,$cf);
758
+	}
759
+
760
+	// If not html then we run the standard output.
761
+	if(empty($html)){
762
+
763
+		$html_val = __($post->{$cf['htmlvar_name']}, 'geodirectory');
764
+		if ($post->{$cf['htmlvar_name']} != ''):
765
+
766
+			if ($post->{$cf['htmlvar_name']} == 'f' || $post->{$cf['htmlvar_name']} == '0') {
767
+				$html_val = __('No', 'geodirectory');
768
+			} else if ($post->{$cf['htmlvar_name']} == 't' || $post->{$cf['htmlvar_name']} == '1') {
769
+				$html_val = __('Yes', 'geodirectory');
770
+			} else {
771
+				if (!empty($cf['option_values'])) {
772
+					$cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true);
773
+
774
+					if (!empty($cf_option_values)) {
775
+						foreach ($cf_option_values as $cf_option_value) {
776
+							if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$cf['htmlvar_name']}) {
777
+								$html_val = $cf_option_value['label'];
778
+							}
779
+						}
780
+					}
781
+				}
782
+			}
783
+
784
+			$field_icon = geodir_field_icon_proccess($cf);
785
+			if (strpos($field_icon, 'http') !== false) {
786
+				$field_icon_af = '';
787
+			} elseif ($field_icon == '') {
788
+				$field_icon_af = '';
789
+			} else {
790
+				$field_icon_af = $field_icon;
791
+				$field_icon = '';
792
+			}
793
+
794
+
795
+			$html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af;
796
+			$html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
797
+			$html .= '</span>' . $html_val . '</div>';
798
+		endif;
799
+
800
+	}
801
+
802
+	return $html;
803 803
 }
804 804
 add_filter('geodir_custom_field_output_radio','geodir_cf_radio',10,3);
805 805
 
@@ -816,92 +816,92 @@  discard block
 block discarded – undo
816 816
  */
817 817
 function geodir_cf_select($html,$location,$cf,$p=''){
818 818
 
819
-    // check we have the post value
820
-    if(is_int($p)){$post = geodir_get_post_info($p);}
821
-    else{ global $post;}
822
-
823
-    if(!is_array($cf) && $cf!=''){
824
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
825
-        if(!$cf){return NULL;}
826
-    }
827
-
828
-    $html_var = $cf['htmlvar_name'];
829
-
830
-    // Check if there is a location specific filter.
831
-    if(has_filter("geodir_custom_field_output_select_loc_{$location}")){
832
-        /**
833
-         * Filter the select html by location.
834
-         *
835
-         * @param string $html The html to filter.
836
-         * @param array $cf The custom field array.
837
-         * @since 1.6.6
838
-         */
839
-        $html = apply_filters("geodir_custom_field_output_select_loc_{$location}",$html,$cf);
840
-    }
841
-
842
-    // Check if there is a custom field specific filter.
843
-    if(has_filter("geodir_custom_field_output_select_var_{$html_var}")){
844
-        /**
845
-         * Filter the select html by individual custom field.
846
-         *
847
-         * @param string $html The html to filter.
848
-         * @param string $location The location to output the html.
849
-         * @param array $cf The custom field array.
850
-         * @since 1.6.6
851
-         */
852
-        $html = apply_filters("geodir_custom_field_output_select_var_{$html_var}",$html,$location,$cf);
853
-    }
854
-
855
-    // Check if there is a custom field key specific filter.
856
-    if(has_filter("geodir_custom_field_output_select_key_{$cf['field_type_key']}")){
857
-        /**
858
-         * Filter the select html by field type key.
859
-         *
860
-         * @param string $html The html to filter.
861
-         * @param string $location The location to output the html.
862
-         * @param array $cf The custom field array.
863
-         * @since 1.6.6
864
-         */
865
-        $html = apply_filters("geodir_custom_field_output_select_key_{$cf['field_type_key']}",$html,$location,$cf);
866
-    }
867
-
868
-    // If not html then we run the standard output.
869
-    if(empty($html)){
870
-
871
-        if ($post->{$cf['htmlvar_name']}):
872
-            $field_value = __($post->{$cf['htmlvar_name']}, 'geodirectory');
873
-
874
-            if (!empty($cf['option_values'])) {
875
-                $cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true);
876
-
877
-                if (!empty($cf_option_values)) {
878
-                    foreach ($cf_option_values as $cf_option_value) {
879
-                        if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$cf['htmlvar_name']}) {
880
-                            //$field_value = $cf_option_value['label']; // no longer needed here.
881
-                        }
882
-                    }
883
-                }
884
-            }
885
-
886
-            $field_icon = geodir_field_icon_proccess($cf);
887
-            if (strpos($field_icon, 'http') !== false) {
888
-                $field_icon_af = '';
889
-            } elseif ($field_icon == '') {
890
-                $field_icon_af = '';
891
-            } else {
892
-                $field_icon_af = $field_icon;
893
-                $field_icon = '';
894
-            }
895
-
896
-
897
-            $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
898
-            $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
899
-            $html .= '</span>' . $field_value . '</div>';
900
-        endif;
901
-
902
-    }
903
-
904
-    return $html;
819
+	// check we have the post value
820
+	if(is_int($p)){$post = geodir_get_post_info($p);}
821
+	else{ global $post;}
822
+
823
+	if(!is_array($cf) && $cf!=''){
824
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
825
+		if(!$cf){return NULL;}
826
+	}
827
+
828
+	$html_var = $cf['htmlvar_name'];
829
+
830
+	// Check if there is a location specific filter.
831
+	if(has_filter("geodir_custom_field_output_select_loc_{$location}")){
832
+		/**
833
+		 * Filter the select html by location.
834
+		 *
835
+		 * @param string $html The html to filter.
836
+		 * @param array $cf The custom field array.
837
+		 * @since 1.6.6
838
+		 */
839
+		$html = apply_filters("geodir_custom_field_output_select_loc_{$location}",$html,$cf);
840
+	}
841
+
842
+	// Check if there is a custom field specific filter.
843
+	if(has_filter("geodir_custom_field_output_select_var_{$html_var}")){
844
+		/**
845
+		 * Filter the select html by individual custom field.
846
+		 *
847
+		 * @param string $html The html to filter.
848
+		 * @param string $location The location to output the html.
849
+		 * @param array $cf The custom field array.
850
+		 * @since 1.6.6
851
+		 */
852
+		$html = apply_filters("geodir_custom_field_output_select_var_{$html_var}",$html,$location,$cf);
853
+	}
854
+
855
+	// Check if there is a custom field key specific filter.
856
+	if(has_filter("geodir_custom_field_output_select_key_{$cf['field_type_key']}")){
857
+		/**
858
+		 * Filter the select html by field type key.
859
+		 *
860
+		 * @param string $html The html to filter.
861
+		 * @param string $location The location to output the html.
862
+		 * @param array $cf The custom field array.
863
+		 * @since 1.6.6
864
+		 */
865
+		$html = apply_filters("geodir_custom_field_output_select_key_{$cf['field_type_key']}",$html,$location,$cf);
866
+	}
867
+
868
+	// If not html then we run the standard output.
869
+	if(empty($html)){
870
+
871
+		if ($post->{$cf['htmlvar_name']}):
872
+			$field_value = __($post->{$cf['htmlvar_name']}, 'geodirectory');
873
+
874
+			if (!empty($cf['option_values'])) {
875
+				$cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true);
876
+
877
+				if (!empty($cf_option_values)) {
878
+					foreach ($cf_option_values as $cf_option_value) {
879
+						if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$cf['htmlvar_name']}) {
880
+							//$field_value = $cf_option_value['label']; // no longer needed here.
881
+						}
882
+					}
883
+				}
884
+			}
885
+
886
+			$field_icon = geodir_field_icon_proccess($cf);
887
+			if (strpos($field_icon, 'http') !== false) {
888
+				$field_icon_af = '';
889
+			} elseif ($field_icon == '') {
890
+				$field_icon_af = '';
891
+			} else {
892
+				$field_icon_af = $field_icon;
893
+				$field_icon = '';
894
+			}
895
+
896
+
897
+			$html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
898
+			$html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
899
+			$html .= '</span>' . $field_value . '</div>';
900
+		endif;
901
+
902
+	}
903
+
904
+	return $html;
905 905
 }
906 906
 add_filter('geodir_custom_field_output_select','geodir_cf_select',10,3);
907 907
 
@@ -918,113 +918,113 @@  discard block
 block discarded – undo
918 918
  */
919 919
 function geodir_cf_multiselect($html,$location,$cf,$p=''){
920 920
 
921
-    // check we have the post value
922
-    if(is_int($p)){$post = geodir_get_post_info($p);}
923
-    else{ global $post;}
924
-
925
-    if(!is_array($cf) && $cf!=''){
926
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
927
-        if(!$cf){return NULL;}
928
-    }
929
-
930
-    $html_var = $cf['htmlvar_name'];
931
-
932
-    // Check if there is a location specific filter.
933
-    if(has_filter("geodir_custom_field_output_multiselect_loc_{$location}")){
934
-        /**
935
-         * Filter the multiselect html by location.
936
-         *
937
-         * @param string $html The html to filter.
938
-         * @param array $cf The custom field array.
939
-         * @since 1.6.6
940
-         */
941
-        $html = apply_filters("geodir_custom_field_output_multiselect_loc_{$location}",$html,$cf);
942
-    }
943
-
944
-    // Check if there is a custom field specific filter.
945
-    if(has_filter("geodir_custom_field_output_multiselect_var_{$html_var}")){
946
-        /**
947
-         * Filter the multiselect html by individual custom field.
948
-         *
949
-         * @param string $html The html to filter.
950
-         * @param string $location The location to output the html.
951
-         * @param array $cf The custom field array.
952
-         * @since 1.6.6
953
-         */
954
-        $html = apply_filters("geodir_custom_field_output_multiselect_var_{$html_var}",$html,$location,$cf);
955
-    }
956
-
957
-    // Check if there is a custom field key specific filter.
958
-    if(has_filter("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}")){
959
-        /**
960
-         * Filter the multiselect html by field type key.
961
-         *
962
-         * @param string $html The html to filter.
963
-         * @param string $location The location to output the html.
964
-         * @param array $cf The custom field array.
965
-         * @since 1.6.6
966
-         */
967
-        $html = apply_filters("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}",$html,$location,$cf);
968
-    }
969
-
970
-    // If not html then we run the standard output.
971
-    if(empty($html)){
972
-
973
-
974
-        if (!empty($post->{$cf['htmlvar_name']})):
975
-
976
-            if (is_array($post->{$cf['htmlvar_name']})) {
977
-                $post->{$cf['htmlvar_name']} = implode(', ', $post->{$cf['htmlvar_name']});
978
-            }
979
-
980
-            $field_icon = geodir_field_icon_proccess($cf);
981
-            if (strpos($field_icon, 'http') !== false) {
982
-                $field_icon_af = '';
983
-            } elseif ($field_icon == '') {
984
-                $field_icon_af = '';
985
-            } else {
986
-                $field_icon_af = $field_icon;
987
-                $field_icon = '';
988
-            }
989
-
990
-            $field_values = explode(',', trim($post->{$cf['htmlvar_name']}, ","));
991
-
992
-            $option_values = array();
993
-            if (!empty($cf['option_values'])) {
994
-                $cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true);
995
-
996
-                if (!empty($cf_option_values)) {
997
-                    foreach ($cf_option_values as $cf_option_value) {
998
-                        if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
999
-                            $option_values[] = $cf_option_value['label'];
1000
-                        }
1001
-                    }
1002
-                }
1003
-            }
1004
-
1005
-
1006
-            $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
1007
-            $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
1008
-            $html .= '</span>';
1009
-
1010
-            if (count($option_values) > 1) {
1011
-                $html .= '<ul>';
1012
-
1013
-                foreach ($option_values as $val) {
1014
-                    $html .= '<li>' . $val . '</li>';
1015
-                }
1016
-
1017
-                $html .= '</ul>';
1018
-            } else {
1019
-                $html .= $post->{$cf['htmlvar_name']};
1020
-            }
1021
-
1022
-            $html .= '</div>';
1023
-        endif;
1024
-
1025
-    }
1026
-
1027
-    return $html;
921
+	// check we have the post value
922
+	if(is_int($p)){$post = geodir_get_post_info($p);}
923
+	else{ global $post;}
924
+
925
+	if(!is_array($cf) && $cf!=''){
926
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
927
+		if(!$cf){return NULL;}
928
+	}
929
+
930
+	$html_var = $cf['htmlvar_name'];
931
+
932
+	// Check if there is a location specific filter.
933
+	if(has_filter("geodir_custom_field_output_multiselect_loc_{$location}")){
934
+		/**
935
+		 * Filter the multiselect html by location.
936
+		 *
937
+		 * @param string $html The html to filter.
938
+		 * @param array $cf The custom field array.
939
+		 * @since 1.6.6
940
+		 */
941
+		$html = apply_filters("geodir_custom_field_output_multiselect_loc_{$location}",$html,$cf);
942
+	}
943
+
944
+	// Check if there is a custom field specific filter.
945
+	if(has_filter("geodir_custom_field_output_multiselect_var_{$html_var}")){
946
+		/**
947
+		 * Filter the multiselect html by individual custom field.
948
+		 *
949
+		 * @param string $html The html to filter.
950
+		 * @param string $location The location to output the html.
951
+		 * @param array $cf The custom field array.
952
+		 * @since 1.6.6
953
+		 */
954
+		$html = apply_filters("geodir_custom_field_output_multiselect_var_{$html_var}",$html,$location,$cf);
955
+	}
956
+
957
+	// Check if there is a custom field key specific filter.
958
+	if(has_filter("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}")){
959
+		/**
960
+		 * Filter the multiselect html by field type key.
961
+		 *
962
+		 * @param string $html The html to filter.
963
+		 * @param string $location The location to output the html.
964
+		 * @param array $cf The custom field array.
965
+		 * @since 1.6.6
966
+		 */
967
+		$html = apply_filters("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}",$html,$location,$cf);
968
+	}
969
+
970
+	// If not html then we run the standard output.
971
+	if(empty($html)){
972
+
973
+
974
+		if (!empty($post->{$cf['htmlvar_name']})):
975
+
976
+			if (is_array($post->{$cf['htmlvar_name']})) {
977
+				$post->{$cf['htmlvar_name']} = implode(', ', $post->{$cf['htmlvar_name']});
978
+			}
979
+
980
+			$field_icon = geodir_field_icon_proccess($cf);
981
+			if (strpos($field_icon, 'http') !== false) {
982
+				$field_icon_af = '';
983
+			} elseif ($field_icon == '') {
984
+				$field_icon_af = '';
985
+			} else {
986
+				$field_icon_af = $field_icon;
987
+				$field_icon = '';
988
+			}
989
+
990
+			$field_values = explode(',', trim($post->{$cf['htmlvar_name']}, ","));
991
+
992
+			$option_values = array();
993
+			if (!empty($cf['option_values'])) {
994
+				$cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true);
995
+
996
+				if (!empty($cf_option_values)) {
997
+					foreach ($cf_option_values as $cf_option_value) {
998
+						if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
999
+							$option_values[] = $cf_option_value['label'];
1000
+						}
1001
+					}
1002
+				}
1003
+			}
1004
+
1005
+
1006
+			$html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
1007
+			$html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
1008
+			$html .= '</span>';
1009
+
1010
+			if (count($option_values) > 1) {
1011
+				$html .= '<ul>';
1012
+
1013
+				foreach ($option_values as $val) {
1014
+					$html .= '<li>' . $val . '</li>';
1015
+				}
1016
+
1017
+				$html .= '</ul>';
1018
+			} else {
1019
+				$html .= $post->{$cf['htmlvar_name']};
1020
+			}
1021
+
1022
+			$html .= '</div>';
1023
+		endif;
1024
+
1025
+	}
1026
+
1027
+	return $html;
1028 1028
 }
1029 1029
 add_filter('geodir_custom_field_output_multiselect','geodir_cf_multiselect',10,3);
1030 1030
 
@@ -1041,153 +1041,153 @@  discard block
 block discarded – undo
1041 1041
  */
1042 1042
 function geodir_cf_email($html,$location,$cf,$p=''){
1043 1043
 
1044
-    // check we have the post value
1045
-    if(is_int($p)){$post = geodir_get_post_info($p);}
1046
-    else{ global $post;}
1047
-
1048
-    if(!is_array($cf) && $cf!=''){
1049
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
1050
-        if(!$cf){return NULL;}
1051
-    }
1052
-
1053
-    $html_var = $cf['htmlvar_name'];
1054
-
1055
-    // Check if there is a location specific filter.
1056
-    if(has_filter("geodir_custom_field_output_email_loc_{$location}")){
1057
-        /**
1058
-         * Filter the email html by location.
1059
-         *
1060
-         * @param string $html The html to filter.
1061
-         * @param array $cf The custom field array.
1062
-         * @since 1.6.6
1063
-         */
1064
-        $html = apply_filters("geodir_custom_field_output_email_loc_{$location}",$html,$cf);
1065
-    }
1066
-
1067
-    // Check if there is a custom field specific filter.
1068
-    if(has_filter("geodir_custom_field_output_email_var_{$html_var}")){
1069
-        /**
1070
-         * Filter the email html by individual custom field.
1071
-         *
1072
-         * @param string $html The html to filter.
1073
-         * @param string $location The location to output the html.
1074
-         * @param array $cf The custom field array.
1075
-         * @since 1.6.6
1076
-         */
1077
-        $html = apply_filters("geodir_custom_field_output_email_var_{$html_var}",$html,$location,$cf);
1078
-    }
1079
-
1080
-    // Check if there is a custom field key specific filter.
1081
-    if(has_filter("geodir_custom_field_output_email_key_{$cf['field_type_key']}")){
1082
-        /**
1083
-         * Filter the email html by field type key.
1084
-         *
1085
-         * @param string $html The html to filter.
1086
-         * @param string $location The location to output the html.
1087
-         * @param array $cf The custom field array.
1088
-         * @since 1.6.6
1089
-         */
1090
-        $html = apply_filters("geodir_custom_field_output_email_key_{$cf['field_type_key']}",$html,$location,$cf);
1091
-    }
1092
-
1093
-    // If not html then we run the standard output.
1094
-    if(empty($html)){
1095
-
1096
-        global $preview;
1097
-        if ($cf['htmlvar_name'] == 'geodir_email' && !(geodir_is_page('detail') || geodir_is_page('preview'))) {
1098
-            return ''; // Remove Send Enquiry | Send To Friend from listings page
1099
-        }
1100
-
1101
-        $package_info = (array)geodir_post_package_info(array(), $post, $post->post_type);
1102
-
1103
-        if ($cf['htmlvar_name'] == 'geodir_email' && ((isset($package_info->sendtofriend) && $package_info->sendtofriend) || $post->{$cf['htmlvar_name']})) {
1104
-            $send_to_friend = true;
1105
-            $b_send_inquiry = '';
1106
-            $b_sendtofriend = '';
1107
-
1108
-            $html = '';
1109
-            if (!$preview) {
1110
-                $b_send_inquiry = 'b_send_inquiry';
1111
-                $b_sendtofriend = 'b_sendtofriend';
1112
-                $html = '<input type="hidden" name="geodir_popup_post_id" value="' . $post->ID . '" /><div class="geodir_display_popup_forms"></div>';
1113
-            }
1114
-
1115
-            $field_icon = geodir_field_icon_proccess($cf);
1116
-            if (strpos($field_icon, 'http') !== false) {
1117
-                $field_icon_af = '';
1118
-            } elseif ($field_icon == '') {
1119
-                $field_icon_af = '<i class="fa fa-envelope"></i>';
1120
-            } else {
1121
-                $field_icon_af = $field_icon;
1122
-                $field_icon = '';
1123
-            }
1124
-
1125
-
1126
-            $html .= '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af;
1127
-            $seperator = '';
1128
-            if ($post->{$cf['htmlvar_name']}) {
1129
-                $html .= '<a href="javascript:void(0);" class="' . $b_send_inquiry . '" >' . SEND_INQUIRY . '</a>';
1130
-                $seperator = ' | ';
1131
-            }
1132
-
1133
-            if (isset($package_info->sendtofriend) && $package_info->sendtofriend) {
1134
-                $html .= $seperator . '<a href="javascript:void(0);" class="' . $b_sendtofriend . '">' . SEND_TO_FRIEND . '</a>';
1135
-            }
1136
-
1137
-            $html .= '</span></div>';
1138
-
1139
-
1140
-            if (isset($_REQUEST['send_inquiry']) && $_REQUEST['send_inquiry'] == 'success') {
1141
-                $html .= '<p class="sucess_msg">' . SEND_INQUIRY_SUCCESS . '</p>';
1142
-            } elseif (isset($_REQUEST['sendtofrnd']) && $_REQUEST['sendtofrnd'] == 'success') {
1143
-                $html .= '<p class="sucess_msg">' . SEND_FRIEND_SUCCESS . '</p>';
1144
-            } elseif (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'captch') {
1145
-                $html .= '<p class="error_msg_fix">' . WRONG_CAPTCH_MSG . '</p>';
1146
-            }
1147
-
1148
-            /*if(!$preview){require_once (geodir_plugin_path().'/geodirectory-templates/popup-forms.php');}*/
1149
-
1150
-        } else {
1151
-
1152
-            if ($post->{$cf['htmlvar_name']}) {
1153
-
1154
-                $field_icon = geodir_field_icon_proccess($cf);
1155
-                if (strpos($field_icon, 'http') !== false) {
1156
-                    $field_icon_af = '';
1157
-                } elseif ($field_icon == '') {
1158
-                    $field_icon_af = '<i class="fa fa-envelope"></i>';
1159
-                } else {
1160
-                    $field_icon_af = $field_icon;
1161
-                    $field_icon = '';
1162
-                }
1163
-
1164
-
1165
-                $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af;
1166
-                $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
1167
-                $html .= '</span><span class="geodir-email-address-output">';
1168
-                $email = $post->{$cf['htmlvar_name']} ;
1169
-                if($e_split = explode('@',$email)){
1170
-                    /**
1171
-                     * Filter email custom field name output.
1172
-                     *
1173
-                     * @since 1.5.3
1174
-                     *
1175
-                     * @param string $email The email string being output.
1176
-                     * @param array $cf Custom field variables array.
1177
-                     */
1178
-                    $email_name = apply_filters('geodir_email_field_name_output',$email,$cf);
1179
-                    $html .=  "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>";
1180
-                }else{
1181
-                    $html .=  $email;
1182
-                }
1183
-                $html .= '</span></div>';
1184
-            }
1185
-
1186
-        }
1187
-
1188
-    }
1189
-
1190
-    return $html;
1044
+	// check we have the post value
1045
+	if(is_int($p)){$post = geodir_get_post_info($p);}
1046
+	else{ global $post;}
1047
+
1048
+	if(!is_array($cf) && $cf!=''){
1049
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
1050
+		if(!$cf){return NULL;}
1051
+	}
1052
+
1053
+	$html_var = $cf['htmlvar_name'];
1054
+
1055
+	// Check if there is a location specific filter.
1056
+	if(has_filter("geodir_custom_field_output_email_loc_{$location}")){
1057
+		/**
1058
+		 * Filter the email html by location.
1059
+		 *
1060
+		 * @param string $html The html to filter.
1061
+		 * @param array $cf The custom field array.
1062
+		 * @since 1.6.6
1063
+		 */
1064
+		$html = apply_filters("geodir_custom_field_output_email_loc_{$location}",$html,$cf);
1065
+	}
1066
+
1067
+	// Check if there is a custom field specific filter.
1068
+	if(has_filter("geodir_custom_field_output_email_var_{$html_var}")){
1069
+		/**
1070
+		 * Filter the email html by individual custom field.
1071
+		 *
1072
+		 * @param string $html The html to filter.
1073
+		 * @param string $location The location to output the html.
1074
+		 * @param array $cf The custom field array.
1075
+		 * @since 1.6.6
1076
+		 */
1077
+		$html = apply_filters("geodir_custom_field_output_email_var_{$html_var}",$html,$location,$cf);
1078
+	}
1079
+
1080
+	// Check if there is a custom field key specific filter.
1081
+	if(has_filter("geodir_custom_field_output_email_key_{$cf['field_type_key']}")){
1082
+		/**
1083
+		 * Filter the email html by field type key.
1084
+		 *
1085
+		 * @param string $html The html to filter.
1086
+		 * @param string $location The location to output the html.
1087
+		 * @param array $cf The custom field array.
1088
+		 * @since 1.6.6
1089
+		 */
1090
+		$html = apply_filters("geodir_custom_field_output_email_key_{$cf['field_type_key']}",$html,$location,$cf);
1091
+	}
1092
+
1093
+	// If not html then we run the standard output.
1094
+	if(empty($html)){
1095
+
1096
+		global $preview;
1097
+		if ($cf['htmlvar_name'] == 'geodir_email' && !(geodir_is_page('detail') || geodir_is_page('preview'))) {
1098
+			return ''; // Remove Send Enquiry | Send To Friend from listings page
1099
+		}
1100
+
1101
+		$package_info = (array)geodir_post_package_info(array(), $post, $post->post_type);
1102
+
1103
+		if ($cf['htmlvar_name'] == 'geodir_email' && ((isset($package_info->sendtofriend) && $package_info->sendtofriend) || $post->{$cf['htmlvar_name']})) {
1104
+			$send_to_friend = true;
1105
+			$b_send_inquiry = '';
1106
+			$b_sendtofriend = '';
1107
+
1108
+			$html = '';
1109
+			if (!$preview) {
1110
+				$b_send_inquiry = 'b_send_inquiry';
1111
+				$b_sendtofriend = 'b_sendtofriend';
1112
+				$html = '<input type="hidden" name="geodir_popup_post_id" value="' . $post->ID . '" /><div class="geodir_display_popup_forms"></div>';
1113
+			}
1114
+
1115
+			$field_icon = geodir_field_icon_proccess($cf);
1116
+			if (strpos($field_icon, 'http') !== false) {
1117
+				$field_icon_af = '';
1118
+			} elseif ($field_icon == '') {
1119
+				$field_icon_af = '<i class="fa fa-envelope"></i>';
1120
+			} else {
1121
+				$field_icon_af = $field_icon;
1122
+				$field_icon = '';
1123
+			}
1124
+
1125
+
1126
+			$html .= '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af;
1127
+			$seperator = '';
1128
+			if ($post->{$cf['htmlvar_name']}) {
1129
+				$html .= '<a href="javascript:void(0);" class="' . $b_send_inquiry . '" >' . SEND_INQUIRY . '</a>';
1130
+				$seperator = ' | ';
1131
+			}
1132
+
1133
+			if (isset($package_info->sendtofriend) && $package_info->sendtofriend) {
1134
+				$html .= $seperator . '<a href="javascript:void(0);" class="' . $b_sendtofriend . '">' . SEND_TO_FRIEND . '</a>';
1135
+			}
1136
+
1137
+			$html .= '</span></div>';
1138
+
1139
+
1140
+			if (isset($_REQUEST['send_inquiry']) && $_REQUEST['send_inquiry'] == 'success') {
1141
+				$html .= '<p class="sucess_msg">' . SEND_INQUIRY_SUCCESS . '</p>';
1142
+			} elseif (isset($_REQUEST['sendtofrnd']) && $_REQUEST['sendtofrnd'] == 'success') {
1143
+				$html .= '<p class="sucess_msg">' . SEND_FRIEND_SUCCESS . '</p>';
1144
+			} elseif (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'captch') {
1145
+				$html .= '<p class="error_msg_fix">' . WRONG_CAPTCH_MSG . '</p>';
1146
+			}
1147
+
1148
+			/*if(!$preview){require_once (geodir_plugin_path().'/geodirectory-templates/popup-forms.php');}*/
1149
+
1150
+		} else {
1151
+
1152
+			if ($post->{$cf['htmlvar_name']}) {
1153
+
1154
+				$field_icon = geodir_field_icon_proccess($cf);
1155
+				if (strpos($field_icon, 'http') !== false) {
1156
+					$field_icon_af = '';
1157
+				} elseif ($field_icon == '') {
1158
+					$field_icon_af = '<i class="fa fa-envelope"></i>';
1159
+				} else {
1160
+					$field_icon_af = $field_icon;
1161
+					$field_icon = '';
1162
+				}
1163
+
1164
+
1165
+				$html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af;
1166
+				$html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
1167
+				$html .= '</span><span class="geodir-email-address-output">';
1168
+				$email = $post->{$cf['htmlvar_name']} ;
1169
+				if($e_split = explode('@',$email)){
1170
+					/**
1171
+					 * Filter email custom field name output.
1172
+					 *
1173
+					 * @since 1.5.3
1174
+					 *
1175
+					 * @param string $email The email string being output.
1176
+					 * @param array $cf Custom field variables array.
1177
+					 */
1178
+					$email_name = apply_filters('geodir_email_field_name_output',$email,$cf);
1179
+					$html .=  "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>";
1180
+				}else{
1181
+					$html .=  $email;
1182
+				}
1183
+				$html .= '</span></div>';
1184
+			}
1185
+
1186
+		}
1187
+
1188
+	}
1189
+
1190
+	return $html;
1191 1191
 }
1192 1192
 add_filter('geodir_custom_field_output_email','geodir_cf_email',10,3);
1193 1193
 
@@ -1204,130 +1204,130 @@  discard block
 block discarded – undo
1204 1204
  */
1205 1205
 function geodir_cf_file($html,$location,$cf,$p=''){
1206 1206
 
1207
-    // check we have the post value
1208
-    if(is_int($p)){$post = geodir_get_post_info($p);}
1209
-    else{ global $post;}
1210
-
1211
-    if(!is_array($cf) && $cf!=''){
1212
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
1213
-        if(!$cf){return NULL;}
1214
-    }
1215
-
1216
-    $html_var = $cf['htmlvar_name'];
1217
-
1218
-    // Check if there is a location specific filter.
1219
-    if(has_filter("geodir_custom_field_output_file_loc_{$location}")){
1220
-        /**
1221
-         * Filter the file html by location.
1222
-         *
1223
-         * @param string $html The html to filter.
1224
-         * @param array $cf The custom field array.
1225
-         * @since 1.6.6
1226
-         */
1227
-        $html = apply_filters("geodir_custom_field_output_file_loc_{$location}",$html,$cf);
1228
-    }
1229
-
1230
-    // Check if there is a custom field specific filter.
1231
-    if(has_filter("geodir_custom_field_output_file_var_{$html_var}")){
1232
-        /**
1233
-         * Filter the file html by individual custom field.
1234
-         *
1235
-         * @param string $html The html to filter.
1236
-         * @param string $location The location to output the html.
1237
-         * @param array $cf The custom field array.
1238
-         * @since 1.6.6
1239
-         */
1240
-        $html = apply_filters("geodir_custom_field_output_file_var_{$html_var}",$html,$location,$cf);
1241
-    }
1242
-
1243
-    // Check if there is a custom field key specific filter.
1244
-    if(has_filter("geodir_custom_field_output_file_key_{$cf['field_type_key']}")){
1245
-        /**
1246
-         * Filter the file html by field type key.
1247
-         *
1248
-         * @param string $html The html to filter.
1249
-         * @param string $location The location to output the html.
1250
-         * @param array $cf The custom field array.
1251
-         * @since 1.6.6
1252
-         */
1253
-        $html = apply_filters("geodir_custom_field_output_file_key_{$cf['field_type_key']}",$html,$location,$cf);
1254
-    }
1255
-
1256
-    // If not html then we run the standard output.
1257
-    if(empty($html)){
1258
-
1259
-        if (!empty($post->{$cf['htmlvar_name']})):
1260
-
1261
-            $files = explode(",", $post->{$cf['htmlvar_name']});
1262
-            if (!empty($files)):
1263
-
1264
-                $extra_fields = !empty($cf['extra_fields']) ? maybe_unserialize($cf['extra_fields']) : NULL;
1265
-                $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
1266
-
1267
-                $file_paths = '';
1268
-                foreach ($files as $file) {
1269
-                    if (!empty($file)) {
1270
-
1271
-                        // $filetype = wp_check_filetype($file);
1272
-
1273
-                        $image_name_arr = explode('/', $file);
1274
-                        $curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
1275
-                        $filename = end($image_name_arr);
1276
-                        $img_name_arr = explode('.', $filename);
1277
-
1278
-                        $arr_file_type = wp_check_filetype($filename);
1279
-                        if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
1280
-                            continue;
1281
-                        }
1282
-
1283
-                        $uploaded_file_type = $arr_file_type['type'];
1284
-                        $uploaded_file_ext = $arr_file_type['ext'];
1285
-
1286
-                        if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
1287
-                            continue; // Invalid file type.
1288
-                        }
1289
-
1290
-                        //$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
1291
-                        $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
1292
-
1293
-                        // If the uploaded file is image
1294
-                        if (in_array($uploaded_file_type, $image_file_types)) {
1295
-                            $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">';
1296
-                            $file_paths .= '<a href="'.$file.'">';
1297
-                            $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
1298
-                            $file_paths .= '</a>';
1299
-                            //$file_paths .= '<img src="'.$file.'"  />';	
1300
-                            $file_paths .= '</div>';
1301
-                        } else {
1302
-                            $ext_path = '_' . $html_var . '_';
1303
-                            $filename = explode($ext_path, $filename);
1304
-                            $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>';
1305
-                        }
1306
-                    }
1307
-                }
1308
-
1309
-                $field_icon = geodir_field_icon_proccess($cf);
1310
-                if (strpos($field_icon, 'http') !== false) {
1311
-                    $field_icon_af = '';
1312
-                } elseif ($field_icon == '') {
1313
-                    $field_icon_af = '';
1314
-                } else {
1315
-                    $field_icon_af = $field_icon;
1316
-                    $field_icon = '';
1317
-                }
1318
-
1319
-                $html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' geodir-custom-file-box ' . $cf['htmlvar_name'] . '"><div class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
1320
-                $html .= '<span style="display: inline-block; vertical-align: top; padding-right: 14px;">';
1321
-                $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
1322
-                $html .= '</span>';
1323
-                $html .= $file_paths . '</div></div>';
1324
-
1325
-            endif;
1326
-        endif;
1327
-
1328
-    }
1329
-
1330
-    return $html;
1207
+	// check we have the post value
1208
+	if(is_int($p)){$post = geodir_get_post_info($p);}
1209
+	else{ global $post;}
1210
+
1211
+	if(!is_array($cf) && $cf!=''){
1212
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
1213
+		if(!$cf){return NULL;}
1214
+	}
1215
+
1216
+	$html_var = $cf['htmlvar_name'];
1217
+
1218
+	// Check if there is a location specific filter.
1219
+	if(has_filter("geodir_custom_field_output_file_loc_{$location}")){
1220
+		/**
1221
+		 * Filter the file html by location.
1222
+		 *
1223
+		 * @param string $html The html to filter.
1224
+		 * @param array $cf The custom field array.
1225
+		 * @since 1.6.6
1226
+		 */
1227
+		$html = apply_filters("geodir_custom_field_output_file_loc_{$location}",$html,$cf);
1228
+	}
1229
+
1230
+	// Check if there is a custom field specific filter.
1231
+	if(has_filter("geodir_custom_field_output_file_var_{$html_var}")){
1232
+		/**
1233
+		 * Filter the file html by individual custom field.
1234
+		 *
1235
+		 * @param string $html The html to filter.
1236
+		 * @param string $location The location to output the html.
1237
+		 * @param array $cf The custom field array.
1238
+		 * @since 1.6.6
1239
+		 */
1240
+		$html = apply_filters("geodir_custom_field_output_file_var_{$html_var}",$html,$location,$cf);
1241
+	}
1242
+
1243
+	// Check if there is a custom field key specific filter.
1244
+	if(has_filter("geodir_custom_field_output_file_key_{$cf['field_type_key']}")){
1245
+		/**
1246
+		 * Filter the file html by field type key.
1247
+		 *
1248
+		 * @param string $html The html to filter.
1249
+		 * @param string $location The location to output the html.
1250
+		 * @param array $cf The custom field array.
1251
+		 * @since 1.6.6
1252
+		 */
1253
+		$html = apply_filters("geodir_custom_field_output_file_key_{$cf['field_type_key']}",$html,$location,$cf);
1254
+	}
1255
+
1256
+	// If not html then we run the standard output.
1257
+	if(empty($html)){
1258
+
1259
+		if (!empty($post->{$cf['htmlvar_name']})):
1260
+
1261
+			$files = explode(",", $post->{$cf['htmlvar_name']});
1262
+			if (!empty($files)):
1263
+
1264
+				$extra_fields = !empty($cf['extra_fields']) ? maybe_unserialize($cf['extra_fields']) : NULL;
1265
+				$allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
1266
+
1267
+				$file_paths = '';
1268
+				foreach ($files as $file) {
1269
+					if (!empty($file)) {
1270
+
1271
+						// $filetype = wp_check_filetype($file);
1272
+
1273
+						$image_name_arr = explode('/', $file);
1274
+						$curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
1275
+						$filename = end($image_name_arr);
1276
+						$img_name_arr = explode('.', $filename);
1277
+
1278
+						$arr_file_type = wp_check_filetype($filename);
1279
+						if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
1280
+							continue;
1281
+						}
1282
+
1283
+						$uploaded_file_type = $arr_file_type['type'];
1284
+						$uploaded_file_ext = $arr_file_type['ext'];
1285
+
1286
+						if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
1287
+							continue; // Invalid file type.
1288
+						}
1289
+
1290
+						//$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
1291
+						$image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
1292
+
1293
+						// If the uploaded file is image
1294
+						if (in_array($uploaded_file_type, $image_file_types)) {
1295
+							$file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">';
1296
+							$file_paths .= '<a href="'.$file.'">';
1297
+							$file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
1298
+							$file_paths .= '</a>';
1299
+							//$file_paths .= '<img src="'.$file.'"  />';	
1300
+							$file_paths .= '</div>';
1301
+						} else {
1302
+							$ext_path = '_' . $html_var . '_';
1303
+							$filename = explode($ext_path, $filename);
1304
+							$file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>';
1305
+						}
1306
+					}
1307
+				}
1308
+
1309
+				$field_icon = geodir_field_icon_proccess($cf);
1310
+				if (strpos($field_icon, 'http') !== false) {
1311
+					$field_icon_af = '';
1312
+				} elseif ($field_icon == '') {
1313
+					$field_icon_af = '';
1314
+				} else {
1315
+					$field_icon_af = $field_icon;
1316
+					$field_icon = '';
1317
+				}
1318
+
1319
+				$html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' geodir-custom-file-box ' . $cf['htmlvar_name'] . '"><div class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
1320
+				$html .= '<span style="display: inline-block; vertical-align: top; padding-right: 14px;">';
1321
+				$html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
1322
+				$html .= '</span>';
1323
+				$html .= $file_paths . '</div></div>';
1324
+
1325
+			endif;
1326
+		endif;
1327
+
1328
+	}
1329
+
1330
+	return $html;
1331 1331
 }
1332 1332
 add_filter('geodir_custom_field_output_file','geodir_cf_file',10,3);
1333 1333
 
@@ -1345,80 +1345,80 @@  discard block
 block discarded – undo
1345 1345
  */
1346 1346
 function geodir_cf_textarea($html,$location,$cf,$p=''){
1347 1347
 
1348
-    // check we have the post value
1349
-    if(is_int($p)){$post = geodir_get_post_info($p);}
1350
-    else{ global $post;}
1351
-
1352
-    if(!is_array($cf) && $cf!=''){
1353
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
1354
-        if(!$cf){return NULL;}
1355
-    }
1356
-
1357
-    $html_var = $cf['htmlvar_name'];
1358
-
1359
-    // Check if there is a location specific filter.
1360
-    if(has_filter("geodir_custom_field_output_textarea_loc_{$location}")){
1361
-        /**
1362
-         * Filter the textarea html by location.
1363
-         *
1364
-         * @param string $html The html to filter.
1365
-         * @param array $cf The custom field array.
1366
-         * @since 1.6.6
1367
-         */
1368
-        $html = apply_filters("geodir_custom_field_output_textarea_loc_{$location}",$html,$cf);
1369
-    }
1370
-
1371
-    // Check if there is a custom field specific filter.
1372
-    if(has_filter("geodir_custom_field_output_textarea_var_{$html_var}")){
1373
-        /**
1374
-         * Filter the textarea html by individual custom field.
1375
-         *
1376
-         * @param string $html The html to filter.
1377
-         * @param string $location The location to output the html.
1378
-         * @param array $cf The custom field array.
1379
-         * @since 1.6.6
1380
-         */
1381
-        $html = apply_filters("geodir_custom_field_output_textarea_var_{$html_var}",$html,$location,$cf);
1382
-    }
1383
-
1384
-    // Check if there is a custom field key specific filter.
1385
-    if(has_filter("geodir_custom_field_output_textarea_key_{$cf['field_type_key']}")){
1386
-        /**
1387
-         * Filter the textarea html by field type key.
1388
-         *
1389
-         * @param string $html The html to filter.
1390
-         * @param string $location The location to output the html.
1391
-         * @param array $cf The custom field array.
1392
-         * @since 1.6.6
1393
-         */
1394
-        $html = apply_filters("geodir_custom_field_output_textarea_key_{$cf['field_type_key']}",$html,$location,$cf);
1395
-    }
1396
-
1397
-    // If not html then we run the standard output.
1398
-    if(empty($html)){
1399
-
1400
-        if (!empty($post->{$cf['htmlvar_name']})) {
1401
-
1402
-            $field_icon = geodir_field_icon_proccess($cf);
1403
-            if (strpos($field_icon, 'http') !== false) {
1404
-                $field_icon_af = '';
1405
-            } elseif ($field_icon == '') {
1406
-                $field_icon_af = '';
1407
-            } else {
1408
-                $field_icon_af = $field_icon;
1409
-                $field_icon = '';
1410
-            }
1411
-
1412
-
1413
-            $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
1414
-            $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
1415
-            $html .= '</span>' . wpautop($post->{$cf['htmlvar_name']}) . '</div>';
1416
-
1417
-        }
1418
-
1419
-    }
1420
-
1421
-    return $html;
1348
+	// check we have the post value
1349
+	if(is_int($p)){$post = geodir_get_post_info($p);}
1350
+	else{ global $post;}
1351
+
1352
+	if(!is_array($cf) && $cf!=''){
1353
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
1354
+		if(!$cf){return NULL;}
1355
+	}
1356
+
1357
+	$html_var = $cf['htmlvar_name'];
1358
+
1359
+	// Check if there is a location specific filter.
1360
+	if(has_filter("geodir_custom_field_output_textarea_loc_{$location}")){
1361
+		/**
1362
+		 * Filter the textarea html by location.
1363
+		 *
1364
+		 * @param string $html The html to filter.
1365
+		 * @param array $cf The custom field array.
1366
+		 * @since 1.6.6
1367
+		 */
1368
+		$html = apply_filters("geodir_custom_field_output_textarea_loc_{$location}",$html,$cf);
1369
+	}
1370
+
1371
+	// Check if there is a custom field specific filter.
1372
+	if(has_filter("geodir_custom_field_output_textarea_var_{$html_var}")){
1373
+		/**
1374
+		 * Filter the textarea html by individual custom field.
1375
+		 *
1376
+		 * @param string $html The html to filter.
1377
+		 * @param string $location The location to output the html.
1378
+		 * @param array $cf The custom field array.
1379
+		 * @since 1.6.6
1380
+		 */
1381
+		$html = apply_filters("geodir_custom_field_output_textarea_var_{$html_var}",$html,$location,$cf);
1382
+	}
1383
+
1384
+	// Check if there is a custom field key specific filter.
1385
+	if(has_filter("geodir_custom_field_output_textarea_key_{$cf['field_type_key']}")){
1386
+		/**
1387
+		 * Filter the textarea html by field type key.
1388
+		 *
1389
+		 * @param string $html The html to filter.
1390
+		 * @param string $location The location to output the html.
1391
+		 * @param array $cf The custom field array.
1392
+		 * @since 1.6.6
1393
+		 */
1394
+		$html = apply_filters("geodir_custom_field_output_textarea_key_{$cf['field_type_key']}",$html,$location,$cf);
1395
+	}
1396
+
1397
+	// If not html then we run the standard output.
1398
+	if(empty($html)){
1399
+
1400
+		if (!empty($post->{$cf['htmlvar_name']})) {
1401
+
1402
+			$field_icon = geodir_field_icon_proccess($cf);
1403
+			if (strpos($field_icon, 'http') !== false) {
1404
+				$field_icon_af = '';
1405
+			} elseif ($field_icon == '') {
1406
+				$field_icon_af = '';
1407
+			} else {
1408
+				$field_icon_af = $field_icon;
1409
+				$field_icon = '';
1410
+			}
1411
+
1412
+
1413
+			$html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
1414
+			$html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
1415
+			$html .= '</span>' . wpautop($post->{$cf['htmlvar_name']}) . '</div>';
1416
+
1417
+		}
1418
+
1419
+	}
1420
+
1421
+	return $html;
1422 1422
 }
1423 1423
 add_filter('geodir_custom_field_output_textarea','geodir_cf_textarea',10,3);
1424 1424
 
@@ -1436,79 +1436,79 @@  discard block
 block discarded – undo
1436 1436
  */
1437 1437
 function geodir_cf_html($html,$location,$cf,$p=''){
1438 1438
 
1439
-    // check we have the post value
1440
-    if(is_int($p)){$post = geodir_get_post_info($p);}
1441
-    else{ global $post;}
1442
-
1443
-    if(!is_array($cf) && $cf!=''){
1444
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
1445
-        if(!$cf){return NULL;}
1446
-    }
1447
-
1448
-    $html_var = $cf['htmlvar_name'];
1449
-
1450
-    // Check if there is a location specific filter.
1451
-    if(has_filter("geodir_custom_field_output_html_loc_{$location}")){
1452
-        /**
1453
-         * Filter the html html by location.
1454
-         *
1455
-         * @param string $html The html to filter.
1456
-         * @param array $cf The custom field array.
1457
-         * @since 1.6.6
1458
-         */
1459
-        $html = apply_filters("geodir_custom_field_output_html_loc_{$location}",$html,$cf);
1460
-    }
1461
-
1462
-    // Check if there is a custom field specific filter.
1463
-    if(has_filter("geodir_custom_field_output_html_var_{$html_var}")){
1464
-        /**
1465
-         * Filter the html html by individual custom field.
1466
-         *
1467
-         * @param string $html The html to filter.
1468
-         * @param string $location The location to output the html.
1469
-         * @param array $cf The custom field array.
1470
-         * @since 1.6.6
1471
-         */
1472
-        $html = apply_filters("geodir_custom_field_output_html_var_{$html_var}",$html,$location,$cf);
1473
-    }
1474
-
1475
-    // Check if there is a custom field key specific filter.
1476
-    if(has_filter("geodir_custom_field_output_html_key_{$cf['field_type_key']}")){
1477
-        /**
1478
-         * Filter the html html by field type key.
1479
-         *
1480
-         * @param string $html The html to filter.
1481
-         * @param string $location The location to output the html.
1482
-         * @param array $cf The custom field array.
1483
-         * @since 1.6.6
1484
-         */
1485
-        $html = apply_filters("geodir_custom_field_output_html_key_{$cf['field_type_key']}",$html,$location,$cf);
1486
-    }
1487
-
1488
-    // If not html then we run the standard output.
1489
-    if(empty($html)){
1490
-
1491
-        if (!empty($post->{$cf['htmlvar_name']})) {
1492
-
1493
-            $field_icon = geodir_field_icon_proccess($cf);
1494
-            if (strpos($field_icon, 'http') !== false) {
1495
-                $field_icon_af = '';
1496
-            } elseif ($field_icon == '') {
1497
-                $field_icon_af = '';
1498
-            } else {
1499
-                $field_icon_af = $field_icon;
1500
-                $field_icon = '';
1501
-            }
1502
-
1503
-            $html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
1504
-            $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
1505
-            $html .= '</span>' . wpautop($post->{$cf['htmlvar_name']}) . '</div>';
1506
-
1507
-        }
1508
-
1509
-    }
1510
-
1511
-    return $html;
1439
+	// check we have the post value
1440
+	if(is_int($p)){$post = geodir_get_post_info($p);}
1441
+	else{ global $post;}
1442
+
1443
+	if(!is_array($cf) && $cf!=''){
1444
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
1445
+		if(!$cf){return NULL;}
1446
+	}
1447
+
1448
+	$html_var = $cf['htmlvar_name'];
1449
+
1450
+	// Check if there is a location specific filter.
1451
+	if(has_filter("geodir_custom_field_output_html_loc_{$location}")){
1452
+		/**
1453
+		 * Filter the html html by location.
1454
+		 *
1455
+		 * @param string $html The html to filter.
1456
+		 * @param array $cf The custom field array.
1457
+		 * @since 1.6.6
1458
+		 */
1459
+		$html = apply_filters("geodir_custom_field_output_html_loc_{$location}",$html,$cf);
1460
+	}
1461
+
1462
+	// Check if there is a custom field specific filter.
1463
+	if(has_filter("geodir_custom_field_output_html_var_{$html_var}")){
1464
+		/**
1465
+		 * Filter the html html by individual custom field.
1466
+		 *
1467
+		 * @param string $html The html to filter.
1468
+		 * @param string $location The location to output the html.
1469
+		 * @param array $cf The custom field array.
1470
+		 * @since 1.6.6
1471
+		 */
1472
+		$html = apply_filters("geodir_custom_field_output_html_var_{$html_var}",$html,$location,$cf);
1473
+	}
1474
+
1475
+	// Check if there is a custom field key specific filter.
1476
+	if(has_filter("geodir_custom_field_output_html_key_{$cf['field_type_key']}")){
1477
+		/**
1478
+		 * Filter the html html by field type key.
1479
+		 *
1480
+		 * @param string $html The html to filter.
1481
+		 * @param string $location The location to output the html.
1482
+		 * @param array $cf The custom field array.
1483
+		 * @since 1.6.6
1484
+		 */
1485
+		$html = apply_filters("geodir_custom_field_output_html_key_{$cf['field_type_key']}",$html,$location,$cf);
1486
+	}
1487
+
1488
+	// If not html then we run the standard output.
1489
+	if(empty($html)){
1490
+
1491
+		if (!empty($post->{$cf['htmlvar_name']})) {
1492
+
1493
+			$field_icon = geodir_field_icon_proccess($cf);
1494
+			if (strpos($field_icon, 'http') !== false) {
1495
+				$field_icon_af = '';
1496
+			} elseif ($field_icon == '') {
1497
+				$field_icon_af = '';
1498
+			} else {
1499
+				$field_icon_af = $field_icon;
1500
+				$field_icon = '';
1501
+			}
1502
+
1503
+			$html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
1504
+			$html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
1505
+			$html .= '</span>' . wpautop($post->{$cf['htmlvar_name']}) . '</div>';
1506
+
1507
+		}
1508
+
1509
+	}
1510
+
1511
+	return $html;
1512 1512
 }
1513 1513
 add_filter('geodir_custom_field_output_html','geodir_cf_html',10,3);
1514 1514
 
@@ -1526,113 +1526,113 @@  discard block
 block discarded – undo
1526 1526
  */
1527 1527
 function geodir_cf_taxonomy($html,$location,$cf,$p=''){
1528 1528
 
1529
-    // check we have the post value
1530
-    if(is_int($p)){$post = geodir_get_post_info($p);}
1531
-    else{ global $post;}
1532
-
1533
-    if(!is_array($cf) && $cf!=''){
1534
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
1535
-        if(!$cf){return NULL;}
1536
-    }
1537
-
1538
-    $html_var = $cf['htmlvar_name'];
1539
-
1540
-    // Check if there is a location specific filter.
1541
-    if(has_filter("geodir_custom_field_output_taxonomy_loc_{$location}")){
1542
-        /**
1543
-         * Filter the taxonomy html by location.
1544
-         *
1545
-         * @param string $html The html to filter.
1546
-         * @param array $cf The custom field array.
1547
-         * @since 1.6.6
1548
-         */
1549
-        $html = apply_filters("geodir_custom_field_output_taxonomy_loc_{$location}",$html,$cf);
1550
-    }
1551
-
1552
-    // Check if there is a custom field specific filter.
1553
-    if(has_filter("geodir_custom_field_output_taxonomy_var_{$html_var}")){
1554
-        /**
1555
-         * Filter the taxonomy html by individual custom field.
1556
-         *
1557
-         * @param string $html The html to filter.
1558
-         * @param string $location The location to output the html.
1559
-         * @param array $cf The custom field array.
1560
-         * @since 1.6.6
1561
-         */
1562
-        $html = apply_filters("geodir_custom_field_output_taxonomy_var_{$html_var}",$html,$location,$cf);
1563
-    }
1564
-
1565
-    // Check if there is a custom field key specific filter.
1566
-    if(has_filter("geodir_custom_field_output_taxonomy_key_{$cf['field_type_key']}")){
1567
-        /**
1568
-         * Filter the taxonomy html by field type key.
1569
-         *
1570
-         * @param string $html The html to filter.
1571
-         * @param string $location The location to output the html.
1572
-         * @param array $cf The custom field array.
1573
-         * @since 1.6.6
1574
-         */
1575
-        $html = apply_filters("geodir_custom_field_output_taxonomy_key_{$cf['field_type_key']}",$html,$location,$cf);
1576
-    }
1577
-
1578
-    // If not html then we run the standard output.
1579
-    if(empty($html)){
1580
-
1581
-        if ($html_var == $post->post_type . 'category' && !empty($post->{$html_var})) {
1582
-            $post_taxonomy = $post->post_type . 'category';
1583
-            $field_value = $post->{$html_var};
1584
-            $links = array();
1585
-            $terms = array();
1586
-            $termsOrdered = array();
1587
-            if (!is_array($field_value)) {
1588
-                $field_value = explode(",", trim($field_value, ","));
1589
-            }
1590
-
1591
-            $field_value = array_unique($field_value);
1592
-
1593
-            if (!empty($field_value)) {
1594
-                foreach ($field_value as $term) {
1595
-                    $term = trim($term);
1596
-
1597
-                    if ($term != '') {
1598
-                        $term = get_term_by('id', $term, $html_var);
1599
-                        if (is_object($term)) {
1600
-                            $links[] = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>" . $term->name . "</a>";
1601
-                            $terms[] = $term;
1602
-                        }
1603
-                    }
1604
-                }
1605
-                if (!empty($links)) {
1606
-                    // order alphabetically
1607
-                    asort($links);
1608
-                    foreach (array_keys($links) as $key) {
1609
-                        $termsOrdered[$key] = $terms[$key];
1610
-                    }
1611
-                    $terms = $termsOrdered;
1612
-                }
1613
-            }
1614
-            $html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object)$terms) : '';
1615
-
1616
-            if ($html_value != '') {
1617
-                $field_icon = geodir_field_icon_proccess($cf);
1618
-                if (strpos($field_icon, 'http') !== false) {
1619
-                    $field_icon_af = '';
1620
-                } else if ($field_icon == '') {
1621
-                    $field_icon_af = '';
1622
-                } else {
1623
-                    $field_icon_af = $field_icon;
1624
-                    $field_icon = '';
1625
-                }
1626
-
1627
-                $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $html_var . '" style="clear:both;"><span class="geodir-i-taxonomy geodir-i-category" style="' . $field_icon . '">' . $field_icon_af;
1628
-                $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
1629
-                $html .= '</span> ' . $html_value . '</div>';
1630
-            }
1631
-        }
1632
-
1633
-    }
1634
-
1635
-    return $html;
1529
+	// check we have the post value
1530
+	if(is_int($p)){$post = geodir_get_post_info($p);}
1531
+	else{ global $post;}
1532
+
1533
+	if(!is_array($cf) && $cf!=''){
1534
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
1535
+		if(!$cf){return NULL;}
1536
+	}
1537
+
1538
+	$html_var = $cf['htmlvar_name'];
1539
+
1540
+	// Check if there is a location specific filter.
1541
+	if(has_filter("geodir_custom_field_output_taxonomy_loc_{$location}")){
1542
+		/**
1543
+		 * Filter the taxonomy html by location.
1544
+		 *
1545
+		 * @param string $html The html to filter.
1546
+		 * @param array $cf The custom field array.
1547
+		 * @since 1.6.6
1548
+		 */
1549
+		$html = apply_filters("geodir_custom_field_output_taxonomy_loc_{$location}",$html,$cf);
1550
+	}
1551
+
1552
+	// Check if there is a custom field specific filter.
1553
+	if(has_filter("geodir_custom_field_output_taxonomy_var_{$html_var}")){
1554
+		/**
1555
+		 * Filter the taxonomy html by individual custom field.
1556
+		 *
1557
+		 * @param string $html The html to filter.
1558
+		 * @param string $location The location to output the html.
1559
+		 * @param array $cf The custom field array.
1560
+		 * @since 1.6.6
1561
+		 */
1562
+		$html = apply_filters("geodir_custom_field_output_taxonomy_var_{$html_var}",$html,$location,$cf);
1563
+	}
1564
+
1565
+	// Check if there is a custom field key specific filter.
1566
+	if(has_filter("geodir_custom_field_output_taxonomy_key_{$cf['field_type_key']}")){
1567
+		/**
1568
+		 * Filter the taxonomy html by field type key.
1569
+		 *
1570
+		 * @param string $html The html to filter.
1571
+		 * @param string $location The location to output the html.
1572
+		 * @param array $cf The custom field array.
1573
+		 * @since 1.6.6
1574
+		 */
1575
+		$html = apply_filters("geodir_custom_field_output_taxonomy_key_{$cf['field_type_key']}",$html,$location,$cf);
1576
+	}
1577
+
1578
+	// If not html then we run the standard output.
1579
+	if(empty($html)){
1580
+
1581
+		if ($html_var == $post->post_type . 'category' && !empty($post->{$html_var})) {
1582
+			$post_taxonomy = $post->post_type . 'category';
1583
+			$field_value = $post->{$html_var};
1584
+			$links = array();
1585
+			$terms = array();
1586
+			$termsOrdered = array();
1587
+			if (!is_array($field_value)) {
1588
+				$field_value = explode(",", trim($field_value, ","));
1589
+			}
1590
+
1591
+			$field_value = array_unique($field_value);
1592
+
1593
+			if (!empty($field_value)) {
1594
+				foreach ($field_value as $term) {
1595
+					$term = trim($term);
1596
+
1597
+					if ($term != '') {
1598
+						$term = get_term_by('id', $term, $html_var);
1599
+						if (is_object($term)) {
1600
+							$links[] = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>" . $term->name . "</a>";
1601
+							$terms[] = $term;
1602
+						}
1603
+					}
1604
+				}
1605
+				if (!empty($links)) {
1606
+					// order alphabetically
1607
+					asort($links);
1608
+					foreach (array_keys($links) as $key) {
1609
+						$termsOrdered[$key] = $terms[$key];
1610
+					}
1611
+					$terms = $termsOrdered;
1612
+				}
1613
+			}
1614
+			$html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object)$terms) : '';
1615
+
1616
+			if ($html_value != '') {
1617
+				$field_icon = geodir_field_icon_proccess($cf);
1618
+				if (strpos($field_icon, 'http') !== false) {
1619
+					$field_icon_af = '';
1620
+				} else if ($field_icon == '') {
1621
+					$field_icon_af = '';
1622
+				} else {
1623
+					$field_icon_af = $field_icon;
1624
+					$field_icon = '';
1625
+				}
1626
+
1627
+				$html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $html_var . '" style="clear:both;"><span class="geodir-i-taxonomy geodir-i-category" style="' . $field_icon . '">' . $field_icon_af;
1628
+				$html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
1629
+				$html .= '</span> ' . $html_value . '</div>';
1630
+			}
1631
+		}
1632
+
1633
+	}
1634
+
1635
+	return $html;
1636 1636
 }
1637 1637
 add_filter('geodir_custom_field_output_taxonomy','geodir_cf_taxonomy',10,3);
1638 1638
 
@@ -1649,162 +1649,162 @@  discard block
 block discarded – undo
1649 1649
  */
1650 1650
 function geodir_cf_address($html,$location,$cf,$p=''){
1651 1651
 
1652
-    // check we have the post value
1653
-    if(is_int($p)){$post = geodir_get_post_info($p);}
1654
-    else{ global $post;}
1655
-
1656
-    if(!is_array($cf) && $cf!=''){
1657
-        $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
1658
-        if(!$cf){return NULL;}
1659
-    }
1660
-
1661
-    $html_var = $cf['htmlvar_name'];
1662
-
1663
-    // Check if there is a location specific filter.
1664
-    if(has_filter("geodir_custom_field_output_address_loc_{$location}")){
1665
-        /**
1666
-         * Filter the address html by location.
1667
-         *
1668
-         * @param string $html The html to filter.
1669
-         * @param array $cf The custom field array.
1670
-         * @since 1.6.6
1671
-         */
1672
-        $html = apply_filters("geodir_custom_field_output_address_loc_{$location}",$html,$cf);
1673
-    }
1674
-
1675
-    // Check if there is a custom field specific filter.
1676
-    if(has_filter("geodir_custom_field_output_address_var_{$html_var}")){
1677
-        /**
1678
-         * Filter the address html by individual custom field.
1679
-         *
1680
-         * @param string $html The html to filter.
1681
-         * @param string $location The location to output the html.
1682
-         * @param array $cf The custom field array.
1683
-         * @since 1.6.6
1684
-         */
1685
-        $html = apply_filters("geodir_custom_field_output_address_var_{$html_var}",$html,$location,$cf);
1686
-    }
1687
-
1688
-    // Check if there is a custom field key specific filter.
1689
-    if(has_filter("geodir_custom_field_output_address_key_{$cf['field_type_key']}")){
1690
-        /**
1691
-         * Filter the address html by field type key.
1692
-         *
1693
-         * @param string $html The html to filter.
1694
-         * @param string $location The location to output the html.
1695
-         * @param array $cf The custom field array.
1696
-         * @since 1.6.6
1697
-         */
1698
-        $html = apply_filters("geodir_custom_field_output_address_key_{$cf['field_type_key']}",$html,$location,$cf);
1699
-    }
1700
-
1701
-    // If not html then we run the standard output.
1702
-    if(empty($html)){
1703
-
1704
-        global $preview;
1705
-        $html_var = $cf['htmlvar_name'] . '_address';
1706
-
1707
-        if ($cf['extra_fields']) {
1708
-
1709
-            $extra_fields = unserialize($cf['extra_fields']);
1710
-
1711
-            $addition_fields = '';
1712
-
1713
-            if (!empty($extra_fields)) {
1714
-
1715
-                $show_city_in_address = false;
1716
-                if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
1717
-                    $show_city_in_address = true;
1718
-                }
1719
-                /**
1720
-                 * Filter "show city in address" value.
1721
-                 *
1722
-                 * @since 1.0.0
1723
-                 */
1724
-                $show_city_in_address = apply_filters('geodir_show_city_in_address', $show_city_in_address);
1725
-
1726
-
1727
-                $show_region_in_address = false;
1728
-                if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
1729
-                    $show_region_in_address = true;
1730
-                }
1731
-                /**
1732
-                 * Filter "show region in address" value.
1733
-                 *
1734
-                 * @since 1.6.6
1735
-                 */
1736
-                $show_region_in_address = apply_filters('geodir_show_region_in_address', $show_region_in_address);
1737
-
1738
-                $show_country_in_address = false;
1739
-                if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
1740
-                    $show_country_in_address = true;
1741
-                }
1742
-                /**
1743
-                 * Filter "show country in address" value.
1744
-                 *
1745
-                 * @since 1.6.6
1746
-                 */
1747
-                $show_country_in_address = apply_filters('geodir_show_country_in_address', $show_country_in_address);
1748
-
1749
-                $show_zip_in_address = false;
1750
-                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
1751
-                    $show_zip_in_address = true;
1752
-                }
1753
-                /**
1754
-                 * Filter "show zip in address" value.
1755
-                 *
1756
-                 * @since 1.6.6
1757
-                 */
1758
-                $show_zip_in_address = apply_filters('geodir_show_zip_in_address', $show_zip_in_address);
1759
-
1760
-
1761
-            }
1762
-
1763
-        }
1764
-
1765
-
1766
-        if ($post->{$html_var}) {
1767
-
1768
-            $field_icon = geodir_field_icon_proccess( $cf );
1769
-            if ( strpos( $field_icon, 'http' ) !== false ) {
1770
-                $field_icon_af = '';
1771
-            } elseif ( $field_icon == '' ) {
1772
-                $field_icon_af = '<i class="fa fa-home"></i>';
1773
-            } else {
1774
-                $field_icon_af = $field_icon;
1775
-                $field_icon    = '';
1776
-            }
1652
+	// check we have the post value
1653
+	if(is_int($p)){$post = geodir_get_post_info($p);}
1654
+	else{ global $post;}
1655
+
1656
+	if(!is_array($cf) && $cf!=''){
1657
+		$cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
1658
+		if(!$cf){return NULL;}
1659
+	}
1660
+
1661
+	$html_var = $cf['htmlvar_name'];
1662
+
1663
+	// Check if there is a location specific filter.
1664
+	if(has_filter("geodir_custom_field_output_address_loc_{$location}")){
1665
+		/**
1666
+		 * Filter the address html by location.
1667
+		 *
1668
+		 * @param string $html The html to filter.
1669
+		 * @param array $cf The custom field array.
1670
+		 * @since 1.6.6
1671
+		 */
1672
+		$html = apply_filters("geodir_custom_field_output_address_loc_{$location}",$html,$cf);
1673
+	}
1674
+
1675
+	// Check if there is a custom field specific filter.
1676
+	if(has_filter("geodir_custom_field_output_address_var_{$html_var}")){
1677
+		/**
1678
+		 * Filter the address html by individual custom field.
1679
+		 *
1680
+		 * @param string $html The html to filter.
1681
+		 * @param string $location The location to output the html.
1682
+		 * @param array $cf The custom field array.
1683
+		 * @since 1.6.6
1684
+		 */
1685
+		$html = apply_filters("geodir_custom_field_output_address_var_{$html_var}",$html,$location,$cf);
1686
+	}
1687
+
1688
+	// Check if there is a custom field key specific filter.
1689
+	if(has_filter("geodir_custom_field_output_address_key_{$cf['field_type_key']}")){
1690
+		/**
1691
+		 * Filter the address html by field type key.
1692
+		 *
1693
+		 * @param string $html The html to filter.
1694
+		 * @param string $location The location to output the html.
1695
+		 * @param array $cf The custom field array.
1696
+		 * @since 1.6.6
1697
+		 */
1698
+		$html = apply_filters("geodir_custom_field_output_address_key_{$cf['field_type_key']}",$html,$location,$cf);
1699
+	}
1700
+
1701
+	// If not html then we run the standard output.
1702
+	if(empty($html)){
1703
+
1704
+		global $preview;
1705
+		$html_var = $cf['htmlvar_name'] . '_address';
1706
+
1707
+		if ($cf['extra_fields']) {
1708
+
1709
+			$extra_fields = unserialize($cf['extra_fields']);
1710
+
1711
+			$addition_fields = '';
1712
+
1713
+			if (!empty($extra_fields)) {
1714
+
1715
+				$show_city_in_address = false;
1716
+				if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
1717
+					$show_city_in_address = true;
1718
+				}
1719
+				/**
1720
+				 * Filter "show city in address" value.
1721
+				 *
1722
+				 * @since 1.0.0
1723
+				 */
1724
+				$show_city_in_address = apply_filters('geodir_show_city_in_address', $show_city_in_address);
1725
+
1726
+
1727
+				$show_region_in_address = false;
1728
+				if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
1729
+					$show_region_in_address = true;
1730
+				}
1731
+				/**
1732
+				 * Filter "show region in address" value.
1733
+				 *
1734
+				 * @since 1.6.6
1735
+				 */
1736
+				$show_region_in_address = apply_filters('geodir_show_region_in_address', $show_region_in_address);
1737
+
1738
+				$show_country_in_address = false;
1739
+				if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
1740
+					$show_country_in_address = true;
1741
+				}
1742
+				/**
1743
+				 * Filter "show country in address" value.
1744
+				 *
1745
+				 * @since 1.6.6
1746
+				 */
1747
+				$show_country_in_address = apply_filters('geodir_show_country_in_address', $show_country_in_address);
1748
+
1749
+				$show_zip_in_address = false;
1750
+				if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
1751
+					$show_zip_in_address = true;
1752
+				}
1753
+				/**
1754
+				 * Filter "show zip in address" value.
1755
+				 *
1756
+				 * @since 1.6.6
1757
+				 */
1758
+				$show_zip_in_address = apply_filters('geodir_show_zip_in_address', $show_zip_in_address);
1759
+
1760
+
1761
+			}
1762
+
1763
+		}
1764
+
1765
+
1766
+		if ($post->{$html_var}) {
1767
+
1768
+			$field_icon = geodir_field_icon_proccess( $cf );
1769
+			if ( strpos( $field_icon, 'http' ) !== false ) {
1770
+				$field_icon_af = '';
1771
+			} elseif ( $field_icon == '' ) {
1772
+				$field_icon_af = '<i class="fa fa-home"></i>';
1773
+			} else {
1774
+				$field_icon_af = $field_icon;
1775
+				$field_icon    = '';
1776
+			}
1777 1777
             
1778 1778
 
1779 1779
 
1780
-            $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"  itemscope itemtype="http://schema.org/PostalAddress">';
1781
-            $html .= '<span class="geodir-i-location" style="' . $field_icon . '">' . $field_icon_af;
1782
-            $html .= ( trim( $cf['site_title'] ) ) ? __( $cf['site_title'], 'geodirectory' ) . ': ' : '&nbsp;';
1783
-            $html .= '</span>';
1780
+			$html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"  itemscope itemtype="http://schema.org/PostalAddress">';
1781
+			$html .= '<span class="geodir-i-location" style="' . $field_icon . '">' . $field_icon_af;
1782
+			$html .= ( trim( $cf['site_title'] ) ) ? __( $cf['site_title'], 'geodirectory' ) . ': ' : '&nbsp;';
1783
+			$html .= '</span>';
1784 1784
 
1785 1785
 
1786
-            if ( $post->post_address ) {
1787
-                $html .= '<span itemprop="streetAddress">' . $post->post_address . '</span><br>';
1788
-            }
1789
-            if ($show_city_in_address && $post->post_city ) {
1790
-                $html .= '<span itemprop="addressLocality">' . $post->post_city . '</span><br>';
1791
-            }
1792
-            if ($show_region_in_address && $post->post_region ) {
1793
-                $html .= '<span itemprop="addressRegion">' . $post->post_region . '</span><br>';
1794
-            }
1795
-            if ($show_zip_in_address && $post->post_zip ) {
1796
-                $html .= '<span itemprop="postalCode">' . $post->post_zip . '</span><br>';
1797
-            }
1798
-            if ($show_country_in_address && $post->post_country ) {
1799
-                $html .= '<span itemprop="addressCountry">' . __( $post->post_country, 'geodirectory' ) . '</span><br>';
1800
-            }
1801
-            $html .= '</div>';
1786
+			if ( $post->post_address ) {
1787
+				$html .= '<span itemprop="streetAddress">' . $post->post_address . '</span><br>';
1788
+			}
1789
+			if ($show_city_in_address && $post->post_city ) {
1790
+				$html .= '<span itemprop="addressLocality">' . $post->post_city . '</span><br>';
1791
+			}
1792
+			if ($show_region_in_address && $post->post_region ) {
1793
+				$html .= '<span itemprop="addressRegion">' . $post->post_region . '</span><br>';
1794
+			}
1795
+			if ($show_zip_in_address && $post->post_zip ) {
1796
+				$html .= '<span itemprop="postalCode">' . $post->post_zip . '</span><br>';
1797
+			}
1798
+			if ($show_country_in_address && $post->post_country ) {
1799
+				$html .= '<span itemprop="addressCountry">' . __( $post->post_country, 'geodirectory' ) . '</span><br>';
1800
+			}
1801
+			$html .= '</div>';
1802 1802
 
1803
-        }
1803
+		}
1804 1804
 
1805
-    }
1805
+	}
1806 1806
 
1807 1807
 
1808
-    return $html;
1808
+	return $html;
1809 1809
 }
1810 1810
 add_filter('geodir_custom_field_output_address','geodir_cf_address',10,3);
1811 1811
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/custom_fields_functions.php 1 patch
Indentation   +1951 added lines, -1951 removed lines patch added patch discarded remove patch
@@ -10,52 +10,52 @@  discard block
 block discarded – undo
10 10
 global $wpdb, $table_prefix;
11 11
 
12 12
 if (!function_exists('geodir_column_exist')) {
13
-    /**
14
-     * Check table column exist or not.
15
-     *
16
-     * @since 1.0.0
17
-     * @package GeoDirectory
18
-     * @global object $wpdb WordPress Database object.
19
-     * @param string $db The table name.
20
-     * @param string $column The column name.
21
-     * @return bool If column exists returns true. Otherwise false.
22
-     */
23
-    function geodir_column_exist($db, $column)
24
-    {
25
-        global $wpdb;
26
-        $exists = false;
27
-        $columns = $wpdb->get_col("show columns from $db");
28
-        foreach ($columns as $c) {
29
-            if ($c == $column) {
30
-                $exists = true;
31
-                break;
32
-            }
33
-        }
34
-        return $exists;
35
-    }
13
+	/**
14
+	 * Check table column exist or not.
15
+	 *
16
+	 * @since 1.0.0
17
+	 * @package GeoDirectory
18
+	 * @global object $wpdb WordPress Database object.
19
+	 * @param string $db The table name.
20
+	 * @param string $column The column name.
21
+	 * @return bool If column exists returns true. Otherwise false.
22
+	 */
23
+	function geodir_column_exist($db, $column)
24
+	{
25
+		global $wpdb;
26
+		$exists = false;
27
+		$columns = $wpdb->get_col("show columns from $db");
28
+		foreach ($columns as $c) {
29
+			if ($c == $column) {
30
+				$exists = true;
31
+				break;
32
+			}
33
+		}
34
+		return $exists;
35
+	}
36 36
 }
37 37
 
38 38
 if (!function_exists('geodir_add_column_if_not_exist')) {
39
-    /**
40
-     * Add column if table column not exist.
41
-     *
42
-     * @since 1.0.0
43
-     * @package GeoDirectory
44
-     * @global object $wpdb WordPress Database object.
45
-     * @param string $db The table name.
46
-     * @param string $column The column name.
47
-     * @param string $column_attr The column attributes.
48
-     */
49
-    function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL")
50
-    {
51
-        global $wpdb;
52
-        $result = 0;// no rows affected
53
-        if (!geodir_column_exist($db, $column)) {
54
-            if (!empty($db) && !empty($column))
55
-                $result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
56
-        }
57
-        return $result;
58
-    }
39
+	/**
40
+	 * Add column if table column not exist.
41
+	 *
42
+	 * @since 1.0.0
43
+	 * @package GeoDirectory
44
+	 * @global object $wpdb WordPress Database object.
45
+	 * @param string $db The table name.
46
+	 * @param string $column The column name.
47
+	 * @param string $column_attr The column attributes.
48
+	 */
49
+	function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL")
50
+	{
51
+		global $wpdb;
52
+		$result = 0;// no rows affected
53
+		if (!geodir_column_exist($db, $column)) {
54
+			if (!empty($db) && !empty($column))
55
+				$result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
56
+		}
57
+		return $result;
58
+	}
59 59
 }
60 60
 
61 61
 /**
@@ -72,705 +72,705 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function geodir_post_custom_fields($package_id = '', $default = 'all', $post_type = 'gd_place', $fields_location = 'none')
74 74
 {
75
-    global $wpdb, $geodir_post_custom_fields_cache;
76
-
77
-    $cache_stored = $post_type . '_' . $package_id . '_' . $default . '_' . $fields_location;
78
-
79
-    if (array_key_exists($cache_stored, $geodir_post_custom_fields_cache)) {
80
-        return $geodir_post_custom_fields_cache[$cache_stored];
81
-    }
82
-
83
-    $default_query = '';
84
-
85
-    if ($default == 'default')
86
-        $default_query .= " and is_admin IN ('1') ";
87
-    elseif ($default == 'custom')
88
-        $default_query .= " and is_admin = '0' ";
89
-
90
-    if ($fields_location == 'none') {
91
-    } else{
92
-        $fields_location = esc_sql( $fields_location );
93
-        $default_query .= " and show_in LIKE '%%[$fields_location]%%' ";
94
-    }
95
-
96
-    $post_meta_info = $wpdb->get_results(
97
-        $wpdb->prepare(
98
-            "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where is_active = '1' and post_type = %s {$default_query} order by sort_order asc,admin_title asc",
99
-            array($post_type)
100
-        )
101
-    );
102
-
103
-
104
-    $return_arr = array();
105
-    if ($post_meta_info) {
106
-
107
-        foreach ($post_meta_info as $post_meta_info_obj) {
108
-
109
-            $custom_fields = array(
110
-                "name" => $post_meta_info_obj->htmlvar_name,
111
-                "label" => $post_meta_info_obj->clabels,
112
-                "default" => $post_meta_info_obj->default_value,
113
-                "type" => $post_meta_info_obj->field_type,
114
-                "desc" => $post_meta_info_obj->admin_desc);
115
-
116
-            if ($post_meta_info_obj->field_type) {
117
-                $options = explode(',', $post_meta_info_obj->option_values);
118
-                $custom_fields["options"] = $options;
119
-            }
120
-
121
-            foreach ($post_meta_info_obj as $key => $val) {
122
-                $custom_fields[$key] = $val;
123
-            }
124
-
125
-            $pricearr = array();
126
-            $pricearr = explode(',', $post_meta_info_obj->packages);
127
-
128
-            if ($package_id != '' && in_array($package_id, $pricearr)) {
129
-                $return_arr[$post_meta_info_obj->sort_order] = $custom_fields;
130
-            } elseif ($package_id == '') {
131
-                $return_arr[$post_meta_info_obj->sort_order] = $custom_fields;
132
-            }
133
-        }
134
-    }
135
-    $geodir_post_custom_fields_cache[$cache_stored] = $return_arr;
136
-
137
-    if (has_filter('geodir_filter_geodir_post_custom_fields')) {
138
-        /**
139
-         * Filter the post custom fields array.
140
-         *
141
-         * @since 1.0.0
142
-         *
143
-         * @param array $return_arr Post custom fields array.
144
-         * @param int|string $package_id The package ID.
145
-         * @param string $post_type Optional. The wordpress post type.
146
-         * @param string $fields_location Optional. Where exactly are you going to place this custom fields?.
147
-         */
148
-        $return_arr = apply_filters('geodir_filter_geodir_post_custom_fields', $return_arr, $package_id, $post_type, $fields_location);
149
-    }
150
-
151
-    return $return_arr;
75
+	global $wpdb, $geodir_post_custom_fields_cache;
76
+
77
+	$cache_stored = $post_type . '_' . $package_id . '_' . $default . '_' . $fields_location;
78
+
79
+	if (array_key_exists($cache_stored, $geodir_post_custom_fields_cache)) {
80
+		return $geodir_post_custom_fields_cache[$cache_stored];
81
+	}
82
+
83
+	$default_query = '';
84
+
85
+	if ($default == 'default')
86
+		$default_query .= " and is_admin IN ('1') ";
87
+	elseif ($default == 'custom')
88
+		$default_query .= " and is_admin = '0' ";
89
+
90
+	if ($fields_location == 'none') {
91
+	} else{
92
+		$fields_location = esc_sql( $fields_location );
93
+		$default_query .= " and show_in LIKE '%%[$fields_location]%%' ";
94
+	}
95
+
96
+	$post_meta_info = $wpdb->get_results(
97
+		$wpdb->prepare(
98
+			"select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where is_active = '1' and post_type = %s {$default_query} order by sort_order asc,admin_title asc",
99
+			array($post_type)
100
+		)
101
+	);
102
+
103
+
104
+	$return_arr = array();
105
+	if ($post_meta_info) {
106
+
107
+		foreach ($post_meta_info as $post_meta_info_obj) {
108
+
109
+			$custom_fields = array(
110
+				"name" => $post_meta_info_obj->htmlvar_name,
111
+				"label" => $post_meta_info_obj->clabels,
112
+				"default" => $post_meta_info_obj->default_value,
113
+				"type" => $post_meta_info_obj->field_type,
114
+				"desc" => $post_meta_info_obj->admin_desc);
115
+
116
+			if ($post_meta_info_obj->field_type) {
117
+				$options = explode(',', $post_meta_info_obj->option_values);
118
+				$custom_fields["options"] = $options;
119
+			}
120
+
121
+			foreach ($post_meta_info_obj as $key => $val) {
122
+				$custom_fields[$key] = $val;
123
+			}
124
+
125
+			$pricearr = array();
126
+			$pricearr = explode(',', $post_meta_info_obj->packages);
127
+
128
+			if ($package_id != '' && in_array($package_id, $pricearr)) {
129
+				$return_arr[$post_meta_info_obj->sort_order] = $custom_fields;
130
+			} elseif ($package_id == '') {
131
+				$return_arr[$post_meta_info_obj->sort_order] = $custom_fields;
132
+			}
133
+		}
134
+	}
135
+	$geodir_post_custom_fields_cache[$cache_stored] = $return_arr;
136
+
137
+	if (has_filter('geodir_filter_geodir_post_custom_fields')) {
138
+		/**
139
+		 * Filter the post custom fields array.
140
+		 *
141
+		 * @since 1.0.0
142
+		 *
143
+		 * @param array $return_arr Post custom fields array.
144
+		 * @param int|string $package_id The package ID.
145
+		 * @param string $post_type Optional. The wordpress post type.
146
+		 * @param string $fields_location Optional. Where exactly are you going to place this custom fields?.
147
+		 */
148
+		$return_arr = apply_filters('geodir_filter_geodir_post_custom_fields', $return_arr, $package_id, $post_type, $fields_location);
149
+	}
150
+
151
+	return $return_arr;
152 152
 }
153 153
 
154
-    /**
155
-     * Adds admin html for custom fields.
156
-     *
157
-     * @since 1.0.0
158
-     * @package GeoDirectory
159
-     * @global object $wpdb WordPress Database object.
160
-     * @param string $field_type The form field type.
161
-     * @param object|int $result_str The custom field results object or row id.
162
-     * @param string $field_ins_upd When set to "submit" displays form.
163
-     * @param string $field_type_key The key of the custom field.
164
-     */
165
-    function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key ='')
166
-    {
167
-        global $wpdb;
168
-        $cf = $result_str;
169
-        if (!is_object($cf)) {
170
-
171
-            $field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)));
172
-
173
-        } else {
174
-            $field_info = $cf;
175
-            $result_str = $cf->id;
176
-        }
177
-        /**
178
-         * Contains custom field html.
179
-         *
180
-         * @since 1.0.0
181
-         */
182
-        include('custom_field_html.php');
183
-
184
-    }
154
+	/**
155
+	 * Adds admin html for custom fields.
156
+	 *
157
+	 * @since 1.0.0
158
+	 * @package GeoDirectory
159
+	 * @global object $wpdb WordPress Database object.
160
+	 * @param string $field_type The form field type.
161
+	 * @param object|int $result_str The custom field results object or row id.
162
+	 * @param string $field_ins_upd When set to "submit" displays form.
163
+	 * @param string $field_type_key The key of the custom field.
164
+	 */
165
+	function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key ='')
166
+	{
167
+		global $wpdb;
168
+		$cf = $result_str;
169
+		if (!is_object($cf)) {
170
+
171
+			$field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)));
172
+
173
+		} else {
174
+			$field_info = $cf;
175
+			$result_str = $cf->id;
176
+		}
177
+		/**
178
+		 * Contains custom field html.
179
+		 *
180
+		 * @since 1.0.0
181
+		 */
182
+		include('custom_field_html.php');
183
+
184
+	}
185 185
 
186 186
 
187 187
 if (!function_exists('geodir_custom_field_delete')) {
188
-    /**
189
-     * Delete custom field using field id.
190
-     *
191
-     * @since 1.0.0
192
-     * @since 1.5.7 Delete field from sorting fields table when custom field deleted.
193
-     * @package GeoDirectory
194
-     * @global object $wpdb WordPress Database object.
195
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
196
-     * @param string $field_id The custom field ID.
197
-     * @return int|string If field deleted successfully, returns field id. Otherwise returns 0.
198
-     */
199
-    function geodir_custom_field_delete($field_id = '') {
200
-        global $wpdb, $plugin_prefix;
201
-
202
-        if ($field_id != '') {
203
-            $cf = trim($field_id, '_');
204
-
205
-            if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
206
-                $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
207
-
208
-                $post_type = $field->post_type;
209
-                $htmlvar_name = $field->htmlvar_name;
210
-
211
-                if ($post_type != '' && $htmlvar_name != '') {
212
-                    $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type)));
213
-                }
214
-
215
-                /**
216
-                 * Called after a custom field is deleted.
217
-                 *
218
-                 * @since 1.0.0
219
-                 * @param string $cf The fields ID.
220
-                 * @param string $field->htmlvar_name The html variable name for the field.
221
-                 * @param string $post_type The post type the field belongs to.
222
-                 */
223
-                do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type);
224
-
225
-                if ($field->field_type == 'address') {
226
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`");
227
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`");
228
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`");
229
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`");
230
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`");
231
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`");
232
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`");
233
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`");
234
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`");
235
-                } else {
236
-                    if ($field->field_type != 'fieldset') {
237
-                        $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`");
238
-                    }
239
-                }
240
-
241
-                return $field_id;
242
-            } else
243
-                return 0;
244
-        } else
245
-            return 0;
246
-    }
188
+	/**
189
+	 * Delete custom field using field id.
190
+	 *
191
+	 * @since 1.0.0
192
+	 * @since 1.5.7 Delete field from sorting fields table when custom field deleted.
193
+	 * @package GeoDirectory
194
+	 * @global object $wpdb WordPress Database object.
195
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
196
+	 * @param string $field_id The custom field ID.
197
+	 * @return int|string If field deleted successfully, returns field id. Otherwise returns 0.
198
+	 */
199
+	function geodir_custom_field_delete($field_id = '') {
200
+		global $wpdb, $plugin_prefix;
201
+
202
+		if ($field_id != '') {
203
+			$cf = trim($field_id, '_');
204
+
205
+			if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
206
+				$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
207
+
208
+				$post_type = $field->post_type;
209
+				$htmlvar_name = $field->htmlvar_name;
210
+
211
+				if ($post_type != '' && $htmlvar_name != '') {
212
+					$wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type)));
213
+				}
214
+
215
+				/**
216
+				 * Called after a custom field is deleted.
217
+				 *
218
+				 * @since 1.0.0
219
+				 * @param string $cf The fields ID.
220
+				 * @param string $field->htmlvar_name The html variable name for the field.
221
+				 * @param string $post_type The post type the field belongs to.
222
+				 */
223
+				do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type);
224
+
225
+				if ($field->field_type == 'address') {
226
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`");
227
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`");
228
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`");
229
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`");
230
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`");
231
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`");
232
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`");
233
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`");
234
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`");
235
+				} else {
236
+					if ($field->field_type != 'fieldset') {
237
+						$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`");
238
+					}
239
+				}
240
+
241
+				return $field_id;
242
+			} else
243
+				return 0;
244
+		} else
245
+			return 0;
246
+	}
247 247
 }
248 248
 
249 249
 if (!function_exists('geodir_custom_field_save')) {
250
-    /**
251
-     * Save or Update custom fields into the database.
252
-     *
253
-     * @since 1.0.0
254
-     * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt.
255
-     * @package GeoDirectory
256
-     * @global object $wpdb WordPress Database object.
257
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
258
-     * @param array $request_field {
259
-     *    Attributes of the request field array.
260
-     *
261
-     *    @type string $action Ajax Action name. Default "geodir_ajax_action".
262
-     *    @type string $manage_field_type Field type Default "custom_fields".
263
-     *    @type string $create_field Create field Default "true".
264
-     *    @type string $field_ins_upd Field ins upd Default "submit".
265
-     *    @type string $_wpnonce WP nonce value.
266
-     *    @type string $listing_type Listing type Example "gd_place".
267
-     *    @type string $field_type Field type Example "radio".
268
-     *    @type string $field_id Field id Example "12".
269
-     *    @type string $data_type Data type Example "VARCHAR".
270
-     *    @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere.
271
-     *    @type array $show_on_pkg Package list to display this field.
272
-     *    @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings.
273
-     *    @type string $site_title Section title which you wish to display in frontend.
274
-     *    @type string $admin_desc Section description which will appear in frontend.
275
-     *    @type string $htmlvar_name Html variable name. This should be a unique name.
276
-     *    @type string $clabels Section Title which will appear in backend.
277
-     *    @type string $default_value The default value (for "link" this will be used as the link text).
278
-     *    @type string $sort_order The display order of this field in backend. e.g. 5.
279
-     *    @type string $is_default Either "1" or "0". If "0" is used then the field will be displayed as main form field or additional field.
280
-     *    @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field.
281
-     *    @type string $is_required Use "1" to set field as required.
282
-     *    @type string $required_msg Enter text for error message if field required and have not full fill requirment.
283
-     *    @type string $show_on_listing Want to show this on listing page?.
284
-     *    @type string $show_in What locations to show the custom field in.
285
-     *    @type string $show_on_detail Want to show this in More Info tab on detail page?.
286
-     *    @type string $show_as_tab Want to display this as a tab on detail page? If "1" then "Show on detail page?" must be Yes.
287
-     *    @type string $option_values Option Values should be separated by comma.
288
-     *    @type string $field_icon Upload icon using media and enter its url path, or enter font awesome class.
289
-     *    @type string $css_class Enter custom css class for field custom style.
290
-     *
291
-     * }
292
-     * @param bool $default Not yet implemented.
293
-     * @return int|string If field is unique returns inserted row id. Otherwise returns error string.
294
-     */
295
-    function geodir_custom_field_save($request_field = array(), $default = false)
296
-    {
297
-
298
-        global $wpdb, $plugin_prefix;
299
-
300
-        $old_html_variable = '';
301
-
302
-        $data_type = trim($request_field['data_type']);
303
-
304
-        $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
305
-
306
-        // some servers fail if a POST value is VARCHAR so we change it.
307
-        if(isset($request_field['data_type']) && $request_field['data_type']=='XVARCHAR'){
308
-            $request_field['data_type'] = 'VARCHAR';
309
-        }
310
-
311
-        $cf = trim($result_str, '_');
312
-
313
-
314
-        /*-------- check dublicate validation --------*/
315
-
316
-        $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
317
-        $post_type = $request_field['listing_type'];
318
-
319
-        if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') {
320
-            $cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name;
321
-        }
322
-
323
-        $check_html_variable = $wpdb->get_var(
324
-            $wpdb->prepare(
325
-                "select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ",
326
-                array($cf, $cehhtmlvar_name, $post_type)
327
-            )
328
-        );
329
-
330
-
331
-        if (!$check_html_variable || $request_field['field_type'] == 'fieldset') {
332
-
333
-            if ($cf != '') {
334
-
335
-                $post_meta_info = $wpdb->get_row(
336
-                    $wpdb->prepare(
337
-                        "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d",
338
-                        array($cf)
339
-                    )
340
-                );
341
-
342
-            }
343
-
344
-            if (!empty($post_meta_info)) {
345
-                $post_val = $post_meta_info;
346
-                $old_html_variable = $post_val->htmlvar_name;
347
-
348
-            }
349
-
350
-
351
-
352
-            if ($post_type == '') $post_type = 'gd_place';
353
-
354
-
355
-            $detail_table = $plugin_prefix . $post_type . '_detail';
356
-
357
-            $admin_title = $request_field['admin_title'];
358
-            $site_title = $request_field['site_title'];
359
-            $data_type = $request_field['data_type'];
360
-            $field_type = $request_field['field_type'];
361
-            $field_type_key = $request_field['field_type_key'];
362
-            $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
363
-            $admin_desc = $request_field['admin_desc'];
364
-            $clabels = $request_field['clabels'];
365
-            $default_value = isset($request_field['default_value']) ? $request_field['default_value'] : '';
366
-            $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : '';
367
-            $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : '';
368
-            $is_required = isset($request_field['is_required']) ? $request_field['is_required'] : '';
369
-            $required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : '';
370
-            $css_class = isset($request_field['css_class']) ? $request_field['css_class'] : '';
371
-            $field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : '';
372
-            $show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : '';
373
-            $show_in = isset($request_field['show_in']) ? $request_field['show_in'] : '';
374
-            $show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : '';
375
-            $show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : '';
376
-            $decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type
377
-            $decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : '';
378
-            $validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : '';
379
-            $validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : '';
380
-            $for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : '';
250
+	/**
251
+	 * Save or Update custom fields into the database.
252
+	 *
253
+	 * @since 1.0.0
254
+	 * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt.
255
+	 * @package GeoDirectory
256
+	 * @global object $wpdb WordPress Database object.
257
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
258
+	 * @param array $request_field {
259
+	 *    Attributes of the request field array.
260
+	 *
261
+	 *    @type string $action Ajax Action name. Default "geodir_ajax_action".
262
+	 *    @type string $manage_field_type Field type Default "custom_fields".
263
+	 *    @type string $create_field Create field Default "true".
264
+	 *    @type string $field_ins_upd Field ins upd Default "submit".
265
+	 *    @type string $_wpnonce WP nonce value.
266
+	 *    @type string $listing_type Listing type Example "gd_place".
267
+	 *    @type string $field_type Field type Example "radio".
268
+	 *    @type string $field_id Field id Example "12".
269
+	 *    @type string $data_type Data type Example "VARCHAR".
270
+	 *    @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere.
271
+	 *    @type array $show_on_pkg Package list to display this field.
272
+	 *    @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings.
273
+	 *    @type string $site_title Section title which you wish to display in frontend.
274
+	 *    @type string $admin_desc Section description which will appear in frontend.
275
+	 *    @type string $htmlvar_name Html variable name. This should be a unique name.
276
+	 *    @type string $clabels Section Title which will appear in backend.
277
+	 *    @type string $default_value The default value (for "link" this will be used as the link text).
278
+	 *    @type string $sort_order The display order of this field in backend. e.g. 5.
279
+	 *    @type string $is_default Either "1" or "0". If "0" is used then the field will be displayed as main form field or additional field.
280
+	 *    @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field.
281
+	 *    @type string $is_required Use "1" to set field as required.
282
+	 *    @type string $required_msg Enter text for error message if field required and have not full fill requirment.
283
+	 *    @type string $show_on_listing Want to show this on listing page?.
284
+	 *    @type string $show_in What locations to show the custom field in.
285
+	 *    @type string $show_on_detail Want to show this in More Info tab on detail page?.
286
+	 *    @type string $show_as_tab Want to display this as a tab on detail page? If "1" then "Show on detail page?" must be Yes.
287
+	 *    @type string $option_values Option Values should be separated by comma.
288
+	 *    @type string $field_icon Upload icon using media and enter its url path, or enter font awesome class.
289
+	 *    @type string $css_class Enter custom css class for field custom style.
290
+	 *
291
+	 * }
292
+	 * @param bool $default Not yet implemented.
293
+	 * @return int|string If field is unique returns inserted row id. Otherwise returns error string.
294
+	 */
295
+	function geodir_custom_field_save($request_field = array(), $default = false)
296
+	{
297
+
298
+		global $wpdb, $plugin_prefix;
299
+
300
+		$old_html_variable = '';
301
+
302
+		$data_type = trim($request_field['data_type']);
303
+
304
+		$result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
305
+
306
+		// some servers fail if a POST value is VARCHAR so we change it.
307
+		if(isset($request_field['data_type']) && $request_field['data_type']=='XVARCHAR'){
308
+			$request_field['data_type'] = 'VARCHAR';
309
+		}
310
+
311
+		$cf = trim($result_str, '_');
312
+
313
+
314
+		/*-------- check dublicate validation --------*/
315
+
316
+		$cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
317
+		$post_type = $request_field['listing_type'];
318
+
319
+		if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') {
320
+			$cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name;
321
+		}
322
+
323
+		$check_html_variable = $wpdb->get_var(
324
+			$wpdb->prepare(
325
+				"select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ",
326
+				array($cf, $cehhtmlvar_name, $post_type)
327
+			)
328
+		);
329
+
330
+
331
+		if (!$check_html_variable || $request_field['field_type'] == 'fieldset') {
332
+
333
+			if ($cf != '') {
334
+
335
+				$post_meta_info = $wpdb->get_row(
336
+					$wpdb->prepare(
337
+						"select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d",
338
+						array($cf)
339
+					)
340
+				);
341
+
342
+			}
343
+
344
+			if (!empty($post_meta_info)) {
345
+				$post_val = $post_meta_info;
346
+				$old_html_variable = $post_val->htmlvar_name;
347
+
348
+			}
349
+
350
+
351
+
352
+			if ($post_type == '') $post_type = 'gd_place';
353
+
354
+
355
+			$detail_table = $plugin_prefix . $post_type . '_detail';
356
+
357
+			$admin_title = $request_field['admin_title'];
358
+			$site_title = $request_field['site_title'];
359
+			$data_type = $request_field['data_type'];
360
+			$field_type = $request_field['field_type'];
361
+			$field_type_key = $request_field['field_type_key'];
362
+			$htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
363
+			$admin_desc = $request_field['admin_desc'];
364
+			$clabels = $request_field['clabels'];
365
+			$default_value = isset($request_field['default_value']) ? $request_field['default_value'] : '';
366
+			$sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : '';
367
+			$is_active = isset($request_field['is_active']) ? $request_field['is_active'] : '';
368
+			$is_required = isset($request_field['is_required']) ? $request_field['is_required'] : '';
369
+			$required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : '';
370
+			$css_class = isset($request_field['css_class']) ? $request_field['css_class'] : '';
371
+			$field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : '';
372
+			$show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : '';
373
+			$show_in = isset($request_field['show_in']) ? $request_field['show_in'] : '';
374
+			$show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : '';
375
+			$show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : '';
376
+			$decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type
377
+			$decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : '';
378
+			$validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : '';
379
+			$validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : '';
380
+			$for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : '';
381 381
 
382 382
             
383
-            if(is_array($show_in)){
384
-                $show_in = implode(",", $request_field['show_in']);
385
-            }
383
+			if(is_array($show_in)){
384
+				$show_in = implode(",", $request_field['show_in']);
385
+			}
386 386
             
387
-            if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
388
-                $htmlvar_name = 'geodir_' . $htmlvar_name;
389
-            }
387
+			if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
388
+				$htmlvar_name = 'geodir_' . $htmlvar_name;
389
+			}
390 390
 
391
-            $option_values = '';
392
-            if (isset($request_field['option_values']))
393
-                $option_values = $request_field['option_values'];
391
+			$option_values = '';
392
+			if (isset($request_field['option_values']))
393
+				$option_values = $request_field['option_values'];
394 394
 
395
-            $cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0';
395
+			$cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0';
396 396
 
397
-            $cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0';
397
+			$cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0';
398 398
 
399
-            if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg']))
400
-                $price_pkg = implode(",", $request_field['show_on_pkg']);
401
-            else {
402
-                $package_info = array();
399
+			if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg']))
400
+				$price_pkg = implode(",", $request_field['show_on_pkg']);
401
+			else {
402
+				$package_info = array();
403 403
 
404
-                $package_info = geodir_post_package_info($package_info, '', $post_type);
405
-                $price_pkg = $package_info->pid;
406
-            }
404
+				$package_info = geodir_post_package_info($package_info, '', $post_type);
405
+				$price_pkg = $package_info->pid;
406
+			}
407 407
 
408 408
 
409
-            if (isset($request_field['extra']) && !empty($request_field['extra']))
410
-                $extra_fields = $request_field['extra'];
409
+			if (isset($request_field['extra']) && !empty($request_field['extra']))
410
+				$extra_fields = $request_field['extra'];
411 411
 
412
-            if (isset($request_field['is_default']) && $request_field['is_default'] != '')
413
-                $is_default = $request_field['is_default'];
414
-            else
415
-                $is_default = '0';
412
+			if (isset($request_field['is_default']) && $request_field['is_default'] != '')
413
+				$is_default = $request_field['is_default'];
414
+			else
415
+				$is_default = '0';
416 416
 
417
-            if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
418
-                $is_admin = $request_field['is_admin'];
419
-            else
420
-                $is_admin = '0';
417
+			if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
418
+				$is_admin = $request_field['is_admin'];
419
+			else
420
+				$is_admin = '0';
421 421
 
422 422
 
423
-            if ($is_active == '') $is_active = 1;
424
-            if ($is_required == '') $is_required = 0;
423
+			if ($is_active == '') $is_active = 1;
424
+			if ($is_required == '') $is_required = 0;
425 425
 
426 426
 
427
-            if ($sort_order == '') {
427
+			if ($sort_order == '') {
428 428
 
429
-                $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
429
+				$last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
430 430
 
431
-                $sort_order = (int)$last_order + 1;
432
-            }
431
+				$sort_order = (int)$last_order + 1;
432
+			}
433 433
 
434
-            $default_value_add = '';
434
+			$default_value_add = '';
435 435
 
436 436
 
437
-            if (!empty($post_meta_info)) {
438
-                switch ($field_type):
437
+			if (!empty($post_meta_info)) {
438
+				switch ($field_type):
439 439
 
440
-                    case 'address':
440
+					case 'address':
441 441
 
442
-                        if ($htmlvar_name != '') {
443
-                            $prefix = $htmlvar_name . '_';
444
-                        }
445
-                        $old_prefix = $old_html_variable . '_';
442
+						if ($htmlvar_name != '') {
443
+							$prefix = $htmlvar_name . '_';
444
+						}
445
+						$old_prefix = $old_html_variable . '_';
446 446
 
447 447
 
448
-                        $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL";
448
+						$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL";
449 449
 
450
-                        if ($default_value != '') {
451
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
452
-                        }
450
+						if ($default_value != '') {
451
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
452
+						}
453 453
 
454
-                        $wpdb->query($meta_field_add);
454
+						$wpdb->query($meta_field_add);
455 455
 
456
-                        if ($extra_fields != '') {
456
+						if ($extra_fields != '') {
457 457
 
458
-                            if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
458
+							if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
459 459
 
460
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'");
461
-                                if ($is_column) {
462
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL";
460
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'");
461
+								if ($is_column) {
462
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL";
463 463
 
464
-                                    if ($default_value != '') {
465
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
466
-                                    }
464
+									if ($default_value != '') {
465
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
466
+									}
467 467
 
468
-                                    $wpdb->query($meta_field_add);
469
-                                } else {
468
+									$wpdb->query($meta_field_add);
469
+								} else {
470 470
 
471
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
472
-                                    if ($default_value != '') {
473
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
474
-                                    }
475
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
471
+									$meta_field_add = "VARCHAR( 50 ) NULL";
472
+									if ($default_value != '') {
473
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
474
+									}
475
+									geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
476 476
 
477
-                                }
477
+								}
478 478
 
479 479
 
480
-                            }
480
+							}
481 481
 
482 482
 
483
-                            if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
483
+							if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
484 484
 
485
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
485
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
486 486
 
487
-                                if ($is_column) {
488
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL";
487
+								if ($is_column) {
488
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL";
489 489
 
490
-                                    if ($default_value != '') {
491
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
492
-                                    }
490
+									if ($default_value != '') {
491
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
492
+									}
493 493
 
494
-                                    $wpdb->query($meta_field_add);
495
-                                } else {
496
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
497
-                                    if ($default_value != '') {
498
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
499
-                                    }
494
+									$wpdb->query($meta_field_add);
495
+								} else {
496
+									$meta_field_add = "VARCHAR( 50 ) NULL";
497
+									if ($default_value != '') {
498
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
499
+									}
500 500
 
501
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
502
-                                }
501
+									geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
502
+								}
503 503
 
504
-                            }
505
-                            if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
504
+							}
505
+							if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
506 506
 
507
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
507
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
508 508
 
509
-                                if ($is_column) {
509
+								if ($is_column) {
510 510
 
511
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL";
511
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL";
512 512
 
513
-                                    if ($default_value != '') {
514
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
515
-                                    }
513
+									if ($default_value != '') {
514
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
515
+									}
516 516
 
517
-                                    $wpdb->query($meta_field_add);
518
-                                } else {
517
+									$wpdb->query($meta_field_add);
518
+								} else {
519 519
 
520
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
521
-                                    if ($default_value != '') {
522
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
523
-                                    }
520
+									$meta_field_add = "VARCHAR( 50 ) NULL";
521
+									if ($default_value != '') {
522
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
523
+									}
524 524
 
525
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
525
+									geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
526 526
 
527
-                                }
527
+								}
528 528
 
529
-                            }
530
-                            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
529
+							}
530
+							if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
531 531
 
532
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
532
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
533 533
 
534
-                                if ($is_column) {
534
+								if ($is_column) {
535 535
 
536
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL";
536
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL";
537 537
 
538
-                                    if ($default_value != '') {
539
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
540
-                                    }
538
+									if ($default_value != '') {
539
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
540
+									}
541 541
 
542
-                                    $wpdb->query($meta_field_add);
543
-                                } else {
542
+									$wpdb->query($meta_field_add);
543
+								} else {
544 544
 
545
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
546
-                                    if ($default_value != '') {
547
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
548
-                                    }
545
+									$meta_field_add = "VARCHAR( 50 ) NULL";
546
+									if ($default_value != '') {
547
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
548
+									}
549 549
 
550
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
550
+									geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
551 551
 
552
-                                }
552
+								}
553 553
 
554
-                            }
555
-                            if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
554
+							}
555
+							if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
556 556
 
557
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
558
-                                if ($is_column) {
557
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
558
+								if ($is_column) {
559 559
 
560
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
560
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
561 561
 
562
-                                    if ($default_value != '') {
563
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
564
-                                    }
562
+									if ($default_value != '') {
563
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
564
+									}
565 565
 
566
-                                    $wpdb->query($meta_field_add);
567
-                                } else {
566
+									$wpdb->query($meta_field_add);
567
+								} else {
568 568
 
569
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
570
-                                    $meta_field_add = "VARCHAR( 20 ) NULL";
571
-                                    if ($default_value != '') {
572
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
573
-                                    }
569
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
570
+									$meta_field_add = "VARCHAR( 20 ) NULL";
571
+									if ($default_value != '') {
572
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
573
+									}
574 574
 
575
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
575
+									geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
576 576
 
577
-                                }
577
+								}
578 578
 
579 579
 
580
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
580
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
581 581
 
582
-                                if ($is_column) {
583
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
582
+								if ($is_column) {
583
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
584 584
 
585
-                                    if ($default_value != '') {
586
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
587
-                                    }
585
+									if ($default_value != '') {
586
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
587
+									}
588 588
 
589
-                                    $wpdb->query($meta_field_add);
590
-                                } else {
589
+									$wpdb->query($meta_field_add);
590
+								} else {
591 591
 
592
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
593
-                                    $meta_field_add = "VARCHAR( 20 ) NULL";
594
-                                    if ($default_value != '') {
595
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
596
-                                    }
592
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
593
+									$meta_field_add = "VARCHAR( 20 ) NULL";
594
+									if ($default_value != '') {
595
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
596
+									}
597 597
 
598
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
599
-                                }
598
+									geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
599
+								}
600 600
 
601
-                            }
602
-                            if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
601
+							}
602
+							if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
603 603
 
604
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
604
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
605 605
 
606
-                                if ($is_column) {
607
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
606
+								if ($is_column) {
607
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
608 608
 
609
-                                    if ($default_value != '') {
610
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
611
-                                    }
609
+									if ($default_value != '') {
610
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
611
+									}
612 612
 
613
-                                    $wpdb->query($meta_field_add);
614
-                                } else {
613
+									$wpdb->query($meta_field_add);
614
+								} else {
615 615
 
616
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
616
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
617 617
 
618
-                                    $meta_field_add = "VARCHAR( 15 ) NULL";
619
-                                    if ($default_value != '') {
620
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
621
-                                    }
618
+									$meta_field_add = "VARCHAR( 15 ) NULL";
619
+									if ($default_value != '') {
620
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
621
+									}
622 622
 
623
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
624
-                                }
623
+									geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
624
+								}
625 625
 
626 626
 
627
-                            }
628
-                            if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
627
+							}
628
+							if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
629 629
 
630
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'");
631
-                                if ($is_column) {
632
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
630
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'");
631
+								if ($is_column) {
632
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
633 633
 
634
-                                    if ($default_value != '') {
635
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
636
-                                    }
634
+									if ($default_value != '') {
635
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
636
+									}
637 637
 
638
-                                    $wpdb->query($meta_field_add);
638
+									$wpdb->query($meta_field_add);
639 639
 
640
-                                } else {
640
+								} else {
641 641
 
642
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
642
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
643 643
 
644
-                                    $meta_field_add = "VARCHAR( 3 ) NULL";
645
-                                    if ($default_value != '') {
646
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
647
-                                    }
644
+									$meta_field_add = "VARCHAR( 3 ) NULL";
645
+									if ($default_value != '') {
646
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
647
+									}
648 648
 
649
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
650
-                                }
649
+									geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
650
+								}
651 651
 
652
-                            }
653
-                            // show lat lng
654
-                            if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
655
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'");
652
+							}
653
+							// show lat lng
654
+							if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
655
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'");
656 656
 
657
-                                if ($is_column) {
658
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
659
-                                    $meta_field_add .= " DEFAULT '1'";
657
+								if ($is_column) {
658
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
659
+									$meta_field_add .= " DEFAULT '1'";
660 660
 
661
-                                    $wpdb->query($meta_field_add);
662
-                                } else {
663
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
661
+									$wpdb->query($meta_field_add);
662
+								} else {
663
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
664 664
 
665
-                                    $meta_field_add = "VARCHAR( 3 ) NULL";
666
-                                    $meta_field_add .= " DEFAULT '1'";
665
+									$meta_field_add = "VARCHAR( 3 ) NULL";
666
+									$meta_field_add .= " DEFAULT '1'";
667 667
 
668
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
669
-                                }
668
+									geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
669
+								}
670 670
 
671
-                            }
672
-                        }// end extra
671
+							}
672
+						}// end extra
673 673
 
674
-                        break;
674
+						break;
675 675
 
676
-                    case 'checkbox':
677
-                    case 'multiselect':
678
-                    case 'select':
679
-                    case 'taxonomy':
676
+					case 'checkbox':
677
+					case 'multiselect':
678
+					case 'select':
679
+					case 'taxonomy':
680 680
 
681
-                        $op_size = '500';
681
+						$op_size = '500';
682 682
 
683
-                        // only make the field as big as it needs to be.
684
-                        if(isset($option_values) && $option_values && $field_type=='select'){
685
-                            $option_values_arr = explode(',',$option_values);
686
-                            if(is_array($option_values_arr)){
687
-                                $op_max = 0;
688
-                                foreach($option_values_arr as $op_val){
689
-                                    if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
690
-                                }
691
-                                if($op_max){$op_size =$op_max; }
692
-                            }
693
-                        }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
694
-                            if(strlen($option_values)){
695
-                                $op_size =  strlen($option_values);
696
-                            }
697
-                        }
683
+						// only make the field as big as it needs to be.
684
+						if(isset($option_values) && $option_values && $field_type=='select'){
685
+							$option_values_arr = explode(',',$option_values);
686
+							if(is_array($option_values_arr)){
687
+								$op_max = 0;
688
+								foreach($option_values_arr as $op_val){
689
+									if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
690
+								}
691
+								if($op_max){$op_size =$op_max; }
692
+							}
693
+						}elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
694
+							if(strlen($option_values)){
695
+								$op_size =  strlen($option_values);
696
+							}
697
+						}
698 698
 
699
-                        $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL";
699
+						$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL";
700 700
 
701
-                        if ($default_value != '') {
702
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
703
-                        }
701
+						if ($default_value != '') {
702
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
703
+						}
704 704
 
705
-                        $alter_result = $wpdb->query($meta_field_add);
706
-                        if($alter_result===false){
707
-                            return __('Column change failed, you may have too many columns.','geodirectory');
708
-                        }
705
+						$alter_result = $wpdb->query($meta_field_add);
706
+						if($alter_result===false){
707
+							return __('Column change failed, you may have too many columns.','geodirectory');
708
+						}
709 709
 
710
-                        if (isset($request_field['cat_display_type']))
711
-                            $extra_fields = $request_field['cat_display_type'];
710
+						if (isset($request_field['cat_display_type']))
711
+							$extra_fields = $request_field['cat_display_type'];
712 712
 
713
-                        if (isset($request_field['multi_display_type']))
714
-                            $extra_fields = $request_field['multi_display_type'];
713
+						if (isset($request_field['multi_display_type']))
714
+							$extra_fields = $request_field['multi_display_type'];
715 715
 
716 716
 
717
-                        break;
717
+						break;
718 718
 
719
-                    case 'textarea':
720
-                    case 'html':
721
-                    case 'url':
722
-                    case 'file':
719
+					case 'textarea':
720
+					case 'html':
721
+					case 'url':
722
+					case 'file':
723 723
 
724
-                        $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
725
-                        if($alter_result===false){
726
-                            return __('Column change failed, you may have too many columns.','geodirectory');
727
-                        }
728
-                        if (isset($request_field['advanced_editor']))
729
-                            $extra_fields = $request_field['advanced_editor'];
730
-
731
-                        break;
724
+						$alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
725
+						if($alter_result===false){
726
+							return __('Column change failed, you may have too many columns.','geodirectory');
727
+						}
728
+						if (isset($request_field['advanced_editor']))
729
+							$extra_fields = $request_field['advanced_editor'];
730
+
731
+						break;
732 732
 
733
-                    case 'fieldset':
734
-                        // Nothig happend for fieldset
735
-                        break;
733
+					case 'fieldset':
734
+						// Nothig happend for fieldset
735
+						break;
736 736
 
737
-                    default:
738
-                        if ($data_type != 'VARCHAR' && $data_type != '') {
739
-                            if ($data_type == 'FLOAT' && $decimal_point > 0) {
740
-                                $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL";
741
-                            } else {
742
-                                $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL";
743
-                            }
744
-
745
-                            if (is_numeric($default_value) && $default_value != '') {
746
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
747
-                            }
748
-                        } else {
749
-                            $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL";
750
-                            if ($default_value != '') {
751
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
752
-                            }
753
-                        }
754
-
755
-                        $alter_result = $wpdb->query($default_value_add);
756
-                        if($alter_result===false){
757
-                            return __('Column change failed, you may have too many columns.','geodirectory');
758
-                        }
759
-                        break;
760
-                endswitch;
761
-
762
-                $extra_field_query = '';
763
-                if (!empty($extra_fields)) {
764
-                    $extra_field_query = serialize($extra_fields);
765
-                }
766
-
767
-                $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
768
-
769
-                $wpdb->query(
770
-
771
-                    $wpdb->prepare(
772
-
773
-                        "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
737
+					default:
738
+						if ($data_type != 'VARCHAR' && $data_type != '') {
739
+							if ($data_type == 'FLOAT' && $decimal_point > 0) {
740
+								$default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL";
741
+							} else {
742
+								$default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL";
743
+							}
744
+
745
+							if (is_numeric($default_value) && $default_value != '') {
746
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
747
+							}
748
+						} else {
749
+							$default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL";
750
+							if ($default_value != '') {
751
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
752
+							}
753
+						}
754
+
755
+						$alter_result = $wpdb->query($default_value_add);
756
+						if($alter_result===false){
757
+							return __('Column change failed, you may have too many columns.','geodirectory');
758
+						}
759
+						break;
760
+				endswitch;
761
+
762
+				$extra_field_query = '';
763
+				if (!empty($extra_fields)) {
764
+					$extra_field_query = serialize($extra_fields);
765
+				}
766
+
767
+				$decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
768
+
769
+				$wpdb->query(
770
+
771
+					$wpdb->prepare(
772
+
773
+						"update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
774 774
 					post_type = %s,
775 775
 					admin_title = %s,
776 776
 					site_title = %s,
@@ -804,308 +804,308 @@  discard block
 block discarded – undo
804 804
 					for_admin_use = %s
805 805
 					where id = %d",
806 806
 
807
-                        array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use, $cf)
808
-                    )
807
+						array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use, $cf)
808
+					)
809 809
 
810
-                );
810
+				);
811 811
 
812
-                $lastid = trim($cf);
812
+				$lastid = trim($cf);
813 813
 
814 814
 
815
-                $wpdb->query(
816
-                    $wpdb->prepare(
817
-                        "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
815
+				$wpdb->query(
816
+					$wpdb->prepare(
817
+						"update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
818 818
 					 	site_title=%s
819 819
 					where post_type = %s and htmlvar_name = %s",
820
-                        array($site_title, $post_type, $htmlvar_name)
821
-                    )
822
-                );
823
-
824
-
825
-                if ($cat_sort == '')
826
-                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
827
-
828
-
829
-                /**
830
-                 * Called after all custom fields are saved for a post.
831
-                 *
832
-                 * @since 1.0.0
833
-                 * @param int $lastid The post ID.
834
-                 */
835
-                do_action('geodir_after_custom_fields_updated', $lastid);
836
-
837
-            } else {
838
-
839
-                switch ($field_type):
840
-
841
-                    case 'address':
842
-
843
-                        $data_type = '';
844
-
845
-                        if ($htmlvar_name != '') {
846
-                            $prefix = $htmlvar_name . '_';
847
-                        }
848
-                        $old_prefix = $old_html_variable;
849
-
850
-                        //$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL";
851
-
852
-                        $meta_field_add = "VARCHAR( 254 ) NULL";
853
-                        if ($default_value != '') {
854
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
855
-                        }
856
-
857
-                        geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add);
858
-                        //$wpdb->query($meta_field_add);
859
-
860
-
861
-                        if (!empty($extra_fields)) {
820
+						array($site_title, $post_type, $htmlvar_name)
821
+					)
822
+				);
823
+
824
+
825
+				if ($cat_sort == '')
826
+					$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
827
+
828
+
829
+				/**
830
+				 * Called after all custom fields are saved for a post.
831
+				 *
832
+				 * @since 1.0.0
833
+				 * @param int $lastid The post ID.
834
+				 */
835
+				do_action('geodir_after_custom_fields_updated', $lastid);
836
+
837
+			} else {
838
+
839
+				switch ($field_type):
840
+
841
+					case 'address':
842
+
843
+						$data_type = '';
844
+
845
+						if ($htmlvar_name != '') {
846
+							$prefix = $htmlvar_name . '_';
847
+						}
848
+						$old_prefix = $old_html_variable;
849
+
850
+						//$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL";
851
+
852
+						$meta_field_add = "VARCHAR( 254 ) NULL";
853
+						if ($default_value != '') {
854
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
855
+						}
856
+
857
+						geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add);
858
+						//$wpdb->query($meta_field_add);
859
+
860
+
861
+						if (!empty($extra_fields)) {
862 862
 
863
-                            if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
864
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL";
865
-                                $meta_field_add = "VARCHAR( 30 ) NULL";
866
-                                if ($default_value != '') {
867
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
868
-                                }
869
-
870
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
871
-                                //$wpdb->query($meta_field_add);
872
-                            }
873
-                            if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
874
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL";
875
-                                $meta_field_add = "VARCHAR( 30 ) NULL";
876
-                                if ($default_value != '') {
877
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
878
-                                }
879
-
880
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
881
-                                //$wpdb->query($meta_field_add);
882
-                            }
883
-                            if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
884
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL";
885
-
886
-                                $meta_field_add = "VARCHAR( 30 ) NULL";
887
-                                if ($default_value != '') {
888
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
889
-                                }
890
-
891
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
892
-                                //$wpdb->query($meta_field_add);
893
-                            }
894
-                            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
895
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL";
896
-                                $meta_field_add = "VARCHAR( 15 ) NULL";
897
-                                if ($default_value != '') {
898
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
899
-                                }
900
-
901
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
902
-                                //$wpdb->query($meta_field_add);
903
-                            }
904
-                            if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
905
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
906
-                                $meta_field_add = "VARCHAR( 20 ) NULL";
907
-                                if ($default_value != '') {
908
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
909
-                                }
910
-
911
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
912
-                                //$wpdb->query($meta_field_add);
913
-
914
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
915
-
916
-                                $meta_field_add = "VARCHAR( 20 ) NULL";
917
-                                if ($default_value != '') {
918
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
919
-                                }
920
-
921
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
922
-
923
-                                //$wpdb->query($meta_field_add);
924
-                            }
925
-                            if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
926
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
927
-
928
-                                $meta_field_add = "VARCHAR( 15 ) NULL";
929
-                                if ($default_value != '') {
930
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
931
-                                }
932
-
933
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
934
-
935
-                                //$wpdb->query($meta_field_add);
936
-                            }
937
-                            if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
938
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
939
-
940
-                                $meta_field_add = "VARCHAR( 3 ) NULL";
941
-                                if ($default_value != '') {
942
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
943
-                                }
944
-
945
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
946
-
947
-                                //$wpdb->query($meta_field_add);
948
-                            }
949
-                            // show lat lng
950
-                            if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
951
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
952
-
953
-                                $meta_field_add = "VARCHAR( 3 ) NULL";
954
-                                $meta_field_add .= " DEFAULT '1'";
955
-
956
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
957
-                                //$wpdb->query($meta_field_add);
958
-                            }
959
-                        }
960
-
961
-                        break;
962
-
963
-                    case 'checkbox':
964
-                        $data_type = 'TINYINT';
965
-
966
-                        $meta_field_add = $data_type . "( 1 ) NOT NULL ";
967
-                        if ((int)$default_value === 1) {
968
-                            $meta_field_add .= " DEFAULT '1'";
969
-                        }
970
-
971
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
972
-                        if ($add_result === false) {
973
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
974
-                        }
975
-                        break;
976
-                    case 'multiselect':
977
-                    case 'select':
978
-                        $data_type = 'VARCHAR';
979
-                        $op_size = '500';
980
-
981
-                        // only make the field as big as it needs to be.
982
-                        if (isset($option_values) && $option_values && $field_type == 'select') {
983
-                            $option_values_arr = explode(',', $option_values);
984
-
985
-                            if (is_array($option_values_arr)) {
986
-                                $op_max = 0;
987
-
988
-                                foreach ($option_values_arr as $op_val) {
989
-                                    if (strlen($op_val) && strlen($op_val) > $op_max) {
990
-                                        $op_max = strlen($op_val);
991
-                                    }
992
-                                }
993
-
994
-                                if ($op_max) {
995
-                                    $op_size = $op_max;
996
-                                }
997
-                            }
998
-                        } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
999
-                            if (strlen($option_values)) {
1000
-                                $op_size =  strlen($option_values);
1001
-                            }
1002
-
1003
-                            if (isset($request_field['multi_display_type'])) {
1004
-                                $extra_fields = $request_field['multi_display_type'];
1005
-                            }
1006
-                        }
1007
-
1008
-                        $meta_field_add = $data_type . "( $op_size ) NULL ";
1009
-                        if ($default_value != '') {
1010
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
1011
-                        }
1012
-
1013
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1014
-                        if ($add_result === false) {
1015
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1016
-                        }
1017
-                        break;
1018
-                    case 'textarea':
1019
-                    case 'html':
1020
-                    case 'url':
1021
-                    case 'file':
1022
-
1023
-                        $data_type = 'TEXT';
1024
-
1025
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1026
-
1027
-                        $meta_field_add = $data_type . " NULL ";
1028
-                        /*if($default_value != '')
863
+							if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
864
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL";
865
+								$meta_field_add = "VARCHAR( 30 ) NULL";
866
+								if ($default_value != '') {
867
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
868
+								}
869
+
870
+								geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
871
+								//$wpdb->query($meta_field_add);
872
+							}
873
+							if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
874
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL";
875
+								$meta_field_add = "VARCHAR( 30 ) NULL";
876
+								if ($default_value != '') {
877
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
878
+								}
879
+
880
+								geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
881
+								//$wpdb->query($meta_field_add);
882
+							}
883
+							if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
884
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL";
885
+
886
+								$meta_field_add = "VARCHAR( 30 ) NULL";
887
+								if ($default_value != '') {
888
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
889
+								}
890
+
891
+								geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
892
+								//$wpdb->query($meta_field_add);
893
+							}
894
+							if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
895
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL";
896
+								$meta_field_add = "VARCHAR( 15 ) NULL";
897
+								if ($default_value != '') {
898
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
899
+								}
900
+
901
+								geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
902
+								//$wpdb->query($meta_field_add);
903
+							}
904
+							if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
905
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
906
+								$meta_field_add = "VARCHAR( 20 ) NULL";
907
+								if ($default_value != '') {
908
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
909
+								}
910
+
911
+								geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
912
+								//$wpdb->query($meta_field_add);
913
+
914
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
915
+
916
+								$meta_field_add = "VARCHAR( 20 ) NULL";
917
+								if ($default_value != '') {
918
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
919
+								}
920
+
921
+								geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
922
+
923
+								//$wpdb->query($meta_field_add);
924
+							}
925
+							if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
926
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
927
+
928
+								$meta_field_add = "VARCHAR( 15 ) NULL";
929
+								if ($default_value != '') {
930
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
931
+								}
932
+
933
+								geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
934
+
935
+								//$wpdb->query($meta_field_add);
936
+							}
937
+							if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
938
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
939
+
940
+								$meta_field_add = "VARCHAR( 3 ) NULL";
941
+								if ($default_value != '') {
942
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
943
+								}
944
+
945
+								geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
946
+
947
+								//$wpdb->query($meta_field_add);
948
+							}
949
+							// show lat lng
950
+							if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
951
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
952
+
953
+								$meta_field_add = "VARCHAR( 3 ) NULL";
954
+								$meta_field_add .= " DEFAULT '1'";
955
+
956
+								geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
957
+								//$wpdb->query($meta_field_add);
958
+							}
959
+						}
960
+
961
+						break;
962
+
963
+					case 'checkbox':
964
+						$data_type = 'TINYINT';
965
+
966
+						$meta_field_add = $data_type . "( 1 ) NOT NULL ";
967
+						if ((int)$default_value === 1) {
968
+							$meta_field_add .= " DEFAULT '1'";
969
+						}
970
+
971
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
972
+						if ($add_result === false) {
973
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
974
+						}
975
+						break;
976
+					case 'multiselect':
977
+					case 'select':
978
+						$data_type = 'VARCHAR';
979
+						$op_size = '500';
980
+
981
+						// only make the field as big as it needs to be.
982
+						if (isset($option_values) && $option_values && $field_type == 'select') {
983
+							$option_values_arr = explode(',', $option_values);
984
+
985
+							if (is_array($option_values_arr)) {
986
+								$op_max = 0;
987
+
988
+								foreach ($option_values_arr as $op_val) {
989
+									if (strlen($op_val) && strlen($op_val) > $op_max) {
990
+										$op_max = strlen($op_val);
991
+									}
992
+								}
993
+
994
+								if ($op_max) {
995
+									$op_size = $op_max;
996
+								}
997
+							}
998
+						} elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
999
+							if (strlen($option_values)) {
1000
+								$op_size =  strlen($option_values);
1001
+							}
1002
+
1003
+							if (isset($request_field['multi_display_type'])) {
1004
+								$extra_fields = $request_field['multi_display_type'];
1005
+							}
1006
+						}
1007
+
1008
+						$meta_field_add = $data_type . "( $op_size ) NULL ";
1009
+						if ($default_value != '') {
1010
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
1011
+						}
1012
+
1013
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1014
+						if ($add_result === false) {
1015
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1016
+						}
1017
+						break;
1018
+					case 'textarea':
1019
+					case 'html':
1020
+					case 'url':
1021
+					case 'file':
1022
+
1023
+						$data_type = 'TEXT';
1024
+
1025
+						$default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1026
+
1027
+						$meta_field_add = $data_type . " NULL ";
1028
+						/*if($default_value != '')
1029 1029
 					{ $meta_field_add .= " DEFAULT '".$default_value."'"; }*/
1030 1030
 
1031
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1032
-                        if ($add_result === false) {
1033
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1034
-                        }
1031
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1032
+						if ($add_result === false) {
1033
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1034
+						}
1035 1035
 
1036
-                        break;
1036
+						break;
1037 1037
 
1038
-                    case 'datepicker':
1038
+					case 'datepicker':
1039 1039
 
1040
-                        $data_type = 'DATE';
1040
+						$data_type = 'DATE';
1041 1041
 
1042
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1042
+						$default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1043 1043
 
1044
-                        $meta_field_add = $data_type . " NULL ";
1044
+						$meta_field_add = $data_type . " NULL ";
1045 1045
 
1046
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1047
-                        if ($add_result === false) {
1048
-                            return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory');
1049
-                        }
1046
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1047
+						if ($add_result === false) {
1048
+							return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory');
1049
+						}
1050 1050
 
1051
-                        break;
1051
+						break;
1052 1052
 
1053
-                    case 'time':
1053
+					case 'time':
1054 1054
 
1055
-                        $data_type = 'TIME';
1055
+						$data_type = 'TIME';
1056 1056
 
1057
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1057
+						$default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1058 1058
 
1059
-                        $meta_field_add = $data_type . " NULL ";
1059
+						$meta_field_add = $data_type . " NULL ";
1060 1060
 
1061
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1062
-                        if ($add_result === false) {
1063
-                            return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory');
1064
-                        }
1061
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1062
+						if ($add_result === false) {
1063
+							return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory');
1064
+						}
1065 1065
 
1066
-                        break;
1066
+						break;
1067 1067
 
1068
-                    default:
1068
+					default:
1069 1069
 
1070
-                        if ($data_type != 'VARCHAR' && $data_type != '') {
1071
-                            $meta_field_add = $data_type . " NULL ";
1070
+						if ($data_type != 'VARCHAR' && $data_type != '') {
1071
+							$meta_field_add = $data_type . " NULL ";
1072 1072
 
1073
-                            if ($data_type == 'FLOAT' && $decimal_point > 0) {
1074
-                                $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL ";
1075
-                            }
1073
+							if ($data_type == 'FLOAT' && $decimal_point > 0) {
1074
+								$meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL ";
1075
+							}
1076 1076
 
1077
-                            if (is_numeric($default_value) && $default_value != '') {
1078
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
1079
-                                $meta_field_add .= " DEFAULT '" . $default_value . "'";
1080
-                            }
1081
-                        } else {
1082
-                            $meta_field_add = " VARCHAR( 254 ) NULL ";
1077
+							if (is_numeric($default_value) && $default_value != '') {
1078
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
1079
+								$meta_field_add .= " DEFAULT '" . $default_value . "'";
1080
+							}
1081
+						} else {
1082
+							$meta_field_add = " VARCHAR( 254 ) NULL ";
1083 1083
 
1084
-                            if ($default_value != '') {
1085
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
1086
-                                $meta_field_add .= " DEFAULT '" . $default_value . "'";
1087
-                            }
1088
-                        }
1084
+							if ($default_value != '') {
1085
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
1086
+								$meta_field_add .= " DEFAULT '" . $default_value . "'";
1087
+							}
1088
+						}
1089 1089
 
1090
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1091
-                        if ($add_result === false) {
1092
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1093
-                        }
1094
-                        break;
1095
-                endswitch;
1090
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1091
+						if ($add_result === false) {
1092
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1093
+						}
1094
+						break;
1095
+				endswitch;
1096 1096
 
1097
-                $extra_field_query = '';
1098
-                if (!empty($extra_fields)) {
1099
-                    $extra_field_query = serialize($extra_fields);
1100
-                }
1097
+				$extra_field_query = '';
1098
+				if (!empty($extra_fields)) {
1099
+					$extra_field_query = serialize($extra_fields);
1100
+				}
1101 1101
 
1102
-                $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
1102
+				$decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
1103 1103
 
1104
-                $wpdb->query(
1104
+				$wpdb->query(
1105 1105
 
1106
-                    $wpdb->prepare(
1106
+					$wpdb->prepare(
1107 1107
 
1108
-                        "insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1108
+						"insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1109 1109
 					post_type = %s,
1110 1110
 					admin_title = %s,
1111 1111
 					site_title = %s,
@@ -1138,26 +1138,26 @@  discard block
 block discarded – undo
1138 1138
 					validation_msg = %s,
1139 1139
 					for_admin_use = %s ",
1140 1140
 
1141
-                        array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing,$show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use)
1141
+						array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing,$show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use)
1142 1142
 
1143
-                    )
1143
+					)
1144 1144
 
1145
-                );
1145
+				);
1146 1146
 
1147
-                $lastid = $wpdb->insert_id;
1147
+				$lastid = $wpdb->insert_id;
1148 1148
 
1149
-                $lastid = trim($lastid);
1149
+				$lastid = trim($lastid);
1150 1150
 
1151
-            }
1151
+			}
1152 1152
 
1153
-            return (int)$lastid;
1153
+			return (int)$lastid;
1154 1154
 
1155 1155
 
1156
-        } else {
1157
-            return 'HTML Variable Name should be a unique name';
1158
-        }
1156
+		} else {
1157
+			return 'HTML Variable Name should be a unique name';
1158
+		}
1159 1159
 
1160
-    }
1160
+	}
1161 1161
 }
1162 1162
 
1163 1163
 /**
@@ -1172,54 +1172,54 @@  discard block
 block discarded – undo
1172 1172
 function godir_set_field_order($field_ids = array())
1173 1173
 {
1174 1174
 
1175
-    global $wpdb;
1175
+	global $wpdb;
1176 1176
 
1177
-    $count = 0;
1178
-    if (!empty($field_ids)):
1179
-        $post_meta_info = false;
1180
-        foreach ($field_ids as $id) {
1177
+	$count = 0;
1178
+	if (!empty($field_ids)):
1179
+		$post_meta_info = false;
1180
+		foreach ($field_ids as $id) {
1181 1181
 
1182
-            $cf = trim($id, '_');
1182
+			$cf = trim($id, '_');
1183 1183
 
1184
-            $post_meta_info = $wpdb->query(
1185
-                $wpdb->prepare(
1186
-                    "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1184
+			$post_meta_info = $wpdb->query(
1185
+				$wpdb->prepare(
1186
+					"update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1187 1187
 															sort_order=%d 
1188 1188
 															where id= %d",
1189
-                    array($count, $cf)
1190
-                )
1191
-            );
1192
-            $count++;
1193
-        }
1194
-
1195
-        return $post_meta_info;
1196
-    else:
1197
-        return false;
1198
-    endif;
1189
+					array($count, $cf)
1190
+				)
1191
+			);
1192
+			$count++;
1193
+		}
1194
+
1195
+		return $post_meta_info;
1196
+	else:
1197
+		return false;
1198
+	endif;
1199 1199
 }
1200 1200
 
1201 1201
 
1202 1202
 function geodir_get_cf_value($cf){
1203
-    global $gd_session;
1204
-    $value = '';
1205
-    if (is_admin()) {
1206
-        global $post,$gd_session;
1207
-
1208
-        if (isset($_REQUEST['post']))
1209
-            $_REQUEST['pid'] = $_REQUEST['post'];
1210
-    }
1211
-
1212
-    if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
1213
-        $post = $gd_ses_listing;
1214
-        $value = isset($post[$cf['name']]) ? $post[$cf['name']] : '';
1215
-    } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
1216
-        $value = geodir_get_post_meta($_REQUEST['pid'], $cf['name'], true);
1217
-    } else {
1218
-        if ($value == '') {
1219
-            $value = $cf['default'];
1220
-        }
1221
-    }
1222
-    return $value;
1203
+	global $gd_session;
1204
+	$value = '';
1205
+	if (is_admin()) {
1206
+		global $post,$gd_session;
1207
+
1208
+		if (isset($_REQUEST['post']))
1209
+			$_REQUEST['pid'] = $_REQUEST['post'];
1210
+	}
1211
+
1212
+	if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
1213
+		$post = $gd_ses_listing;
1214
+		$value = isset($post[$cf['name']]) ? $post[$cf['name']] : '';
1215
+	} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
1216
+		$value = geodir_get_post_meta($_REQUEST['pid'], $cf['name'], true);
1217
+	} else {
1218
+		if ($value == '') {
1219
+			$value = $cf['default'];
1220
+		}
1221
+	}
1222
+	return $value;
1223 1223
 }
1224 1224
 
1225 1225
 /**
@@ -1238,412 +1238,412 @@  discard block
 block discarded – undo
1238 1238
  * @param string $post_type Optional. The wordpress post type.
1239 1239
  */
1240 1240
 function geodir_get_custom_fields_html($package_id = '', $default = 'custom', $post_type = 'gd_place') {
1241
-    global $is_default, $mapzoom, $gd_session;
1241
+	global $is_default, $mapzoom, $gd_session;
1242 1242
 
1243
-    $listing_type = $post_type;
1243
+	$listing_type = $post_type;
1244 1244
 
1245
-    $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type);
1245
+	$custom_fields = geodir_post_custom_fields($package_id, $default, $post_type);
1246 1246
 
1247
-    foreach ($custom_fields as $key => $val) {
1248
-        $val = stripslashes_deep($val); // strip slashes from labels
1249
-        $name = $val['name'];
1250
-        $type = $val['type'];
1251
-        $is_default = $val['is_default'];
1247
+	foreach ($custom_fields as $key => $val) {
1248
+		$val = stripslashes_deep($val); // strip slashes from labels
1249
+		$name = $val['name'];
1250
+		$type = $val['type'];
1251
+		$is_default = $val['is_default'];
1252 1252
 
1253
-        /* field available to site admin only for edit */
1254
-        $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false;
1255
-        if ($for_admin_use && !is_super_admin()) {
1256
-            continue;
1257
-        }
1253
+		/* field available to site admin only for edit */
1254
+		$for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false;
1255
+		if ($for_admin_use && !is_super_admin()) {
1256
+			continue;
1257
+		}
1258 1258
 
1259
-        if (is_admin()) {
1260
-            global $post;
1259
+		if (is_admin()) {
1260
+			global $post;
1261 1261
 
1262
-            if (isset($_REQUEST['post']))
1263
-                $_REQUEST['pid'] = $_REQUEST['post'];
1264
-        }
1262
+			if (isset($_REQUEST['post']))
1263
+				$_REQUEST['pid'] = $_REQUEST['post'];
1264
+		}
1265 1265
 
1266 1266
         
1267 1267
 
1268
-        /**
1269
-         * Called before the custom fields info is output for submitting a post.
1270
-         *
1271
-         * Used dynamic hook type geodir_before_custom_form_field_$name.
1272
-         *
1273
-         * @since 1.0.0
1274
-         * @param string $listing_type The post post type.
1275
-         * @param int $package_id The price package ID for the post.
1276
-         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1277
-         * @see 'geodir_after_custom_form_field_$name'
1278
-         */
1279
-        do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
1280
-
1281
-
1282
-        $custom_field = $val;
1283
-        $html ='';
1284
-        /**
1285
-         * Filter the output for custom fields.
1286
-         *
1287
-         * Here we can remove or add new functions depending on the field type.
1288
-         *
1289
-         * @param string $html The html to be filtered (blank).
1290
-         * @param array $custom_field The custom field array values.
1291
-         */
1292
-        echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field);
1293
-
1294
-
1295
-
1296
-        /**
1297
-         * Called after the custom fields info is output for submitting a post.
1298
-         *
1299
-         * Used dynamic hook type geodir_after_custom_form_field_$name.
1300
-         *
1301
-         * @since 1.0.0
1302
-         * @param string $listing_type The post post type.
1303
-         * @param int $package_id The price package ID for the post.
1304
-         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1305
-         * @see 'geodir_before_custom_form_field_$name'
1306
-         */
1307
-        do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
1308
-
1309
-    }
1268
+		/**
1269
+		 * Called before the custom fields info is output for submitting a post.
1270
+		 *
1271
+		 * Used dynamic hook type geodir_before_custom_form_field_$name.
1272
+		 *
1273
+		 * @since 1.0.0
1274
+		 * @param string $listing_type The post post type.
1275
+		 * @param int $package_id The price package ID for the post.
1276
+		 * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1277
+		 * @see 'geodir_after_custom_form_field_$name'
1278
+		 */
1279
+		do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
1280
+
1281
+
1282
+		$custom_field = $val;
1283
+		$html ='';
1284
+		/**
1285
+		 * Filter the output for custom fields.
1286
+		 *
1287
+		 * Here we can remove or add new functions depending on the field type.
1288
+		 *
1289
+		 * @param string $html The html to be filtered (blank).
1290
+		 * @param array $custom_field The custom field array values.
1291
+		 */
1292
+		echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field);
1293
+
1294
+
1295
+
1296
+		/**
1297
+		 * Called after the custom fields info is output for submitting a post.
1298
+		 *
1299
+		 * Used dynamic hook type geodir_after_custom_form_field_$name.
1300
+		 *
1301
+		 * @since 1.0.0
1302
+		 * @param string $listing_type The post post type.
1303
+		 * @param int $package_id The price package ID for the post.
1304
+		 * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1305
+		 * @see 'geodir_before_custom_form_field_$name'
1306
+		 */
1307
+		do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
1308
+
1309
+	}
1310 1310
 
1311 1311
 }
1312 1312
 
1313 1313
 
1314 1314
 if (!function_exists('geodir_get_field_infoby')) {
1315
-    /**
1316
-     * Get custom field using key and value.
1317
-     *
1318
-     * @since 1.0.0
1319
-     * @package GeoDirectory
1320
-     * @global object $wpdb WordPress Database object.
1321
-     * @param string $key The key you want to look for.
1322
-     * @param string $value The value of the key you want to look for.
1323
-     * @param string $geodir_post_type The post type.
1324
-     * @return bool|mixed Returns field info when available. otherwise returns false.
1325
-     */
1326
-    function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '')
1327
-    {
1328
-
1329
-        global $wpdb;
1330
-
1331
-        $filter = $wpdb->get_row(
1332
-            $wpdb->prepare(
1333
-                "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'",
1334
-                array($geodir_post_type)
1335
-            )
1336
-        );
1337
-
1338
-        if ($filter) {
1339
-            return $filter;
1340
-        } else {
1341
-            return false;
1342
-        }
1343
-
1344
-    }
1315
+	/**
1316
+	 * Get custom field using key and value.
1317
+	 *
1318
+	 * @since 1.0.0
1319
+	 * @package GeoDirectory
1320
+	 * @global object $wpdb WordPress Database object.
1321
+	 * @param string $key The key you want to look for.
1322
+	 * @param string $value The value of the key you want to look for.
1323
+	 * @param string $geodir_post_type The post type.
1324
+	 * @return bool|mixed Returns field info when available. otherwise returns false.
1325
+	 */
1326
+	function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '')
1327
+	{
1328
+
1329
+		global $wpdb;
1330
+
1331
+		$filter = $wpdb->get_row(
1332
+			$wpdb->prepare(
1333
+				"SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'",
1334
+				array($geodir_post_type)
1335
+			)
1336
+		);
1337
+
1338
+		if ($filter) {
1339
+			return $filter;
1340
+		} else {
1341
+			return false;
1342
+		}
1343
+
1344
+	}
1345 1345
 }
1346 1346
 
1347 1347
 
1348 1348
 function geodir_field_icon_proccess($cf){
1349 1349
 
1350 1350
 
1351
-    if (strpos($cf['field_icon'], 'http') !== false) {
1352
-        $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
1353
-    } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) {
1354
-        $field_icon = '<i class="' . $cf['field_icon'] . '"></i>';
1355
-    }else{
1356
-        $field_icon = $cf['field_icon'];
1357
-    }
1351
+	if (strpos($cf['field_icon'], 'http') !== false) {
1352
+		$field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
1353
+	} elseif (strpos($cf['field_icon'], 'fa fa-') !== false) {
1354
+		$field_icon = '<i class="' . $cf['field_icon'] . '"></i>';
1355
+	}else{
1356
+		$field_icon = $cf['field_icon'];
1357
+	}
1358 1358
 
1359
-    return $field_icon;
1359
+	return $field_icon;
1360 1360
 }
1361 1361
 
1362 1362
 if (!function_exists('geodir_show_listing_info')) {
1363
-    /**
1364
-     * Show listing info depending on field location.
1365
-     *
1366
-     * @since 1.0.0
1367
-     * @since 1.5.7 Custom fields option values added to db translation.
1368
-     *              Changes to display url fields title.
1369
-     * @package GeoDirectory
1370
-     * @global object $wpdb WordPress Database object.
1371
-     * @global object $post The current post object.
1372
-     * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false.
1373
-     *
1374
-     * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc.
1375
-     * @return string Returns listing info html.
1376
-     */
1377
-    function geodir_show_listing_info($fields_location = '') {
1378
-        global $post, $preview, $wpdb, $send_to_friend;
1379
-
1380
-        $payment_info = array();
1381
-        $package_info = array();
1382
-
1383
-        $package_info = geodir_post_package_info($package_info, $post);
1384
-        $post_package_id = $package_info->pid;
1385
-        $p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype();
1386
-        $send_to_friend = false;
1387
-
1388
-        ob_start();
1389
-        $fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location);
1390
-
1391
-        if (!empty($fields_info)) {
1392
-            $post = stripslashes_deep($post); // strip slashes
1363
+	/**
1364
+	 * Show listing info depending on field location.
1365
+	 *
1366
+	 * @since 1.0.0
1367
+	 * @since 1.5.7 Custom fields option values added to db translation.
1368
+	 *              Changes to display url fields title.
1369
+	 * @package GeoDirectory
1370
+	 * @global object $wpdb WordPress Database object.
1371
+	 * @global object $post The current post object.
1372
+	 * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false.
1373
+	 *
1374
+	 * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc.
1375
+	 * @return string Returns listing info html.
1376
+	 */
1377
+	function geodir_show_listing_info($fields_location = '') {
1378
+		global $post, $preview, $wpdb, $send_to_friend;
1379
+
1380
+		$payment_info = array();
1381
+		$package_info = array();
1382
+
1383
+		$package_info = geodir_post_package_info($package_info, $post);
1384
+		$post_package_id = $package_info->pid;
1385
+		$p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype();
1386
+		$send_to_friend = false;
1387
+
1388
+		ob_start();
1389
+		$fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location);
1390
+
1391
+		if (!empty($fields_info)) {
1392
+			$post = stripslashes_deep($post); // strip slashes
1393 1393
             
1394
-            //echo '<div class="geodir-company_info field-group">';
1395
-            global $field_set_start;
1396
-            $field_set_start = 0;
1397
-
1398
-
1399
-
1400
-            foreach ($fields_info as $type) {
1401
-                $type = stripslashes_deep($type); // strip slashes
1402
-                $html = '';
1403
-                $html_var = '';
1404
-                $field_icon = geodir_field_icon_proccess($type);
1405
-                $filed_type = $type['type'];
1406
-
1407
-                /**
1408
-                 * Filter the output for custom fields.
1409
-                 *
1410
-                 * Here we can remove or add new functions depending on the field type.
1411
-                 *
1412
-                 * @param string $html The html to be filtered (blank).
1413
-                 * @param string $fields_location The location the field is to be show.
1414
-                 * @param array $type The array of field values.
1415
-                 */
1416
-                $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
1417
-
1418
-                $variables_array = array();
1419
-
1420
-                if ($fields_location == 'detail' && isset($type['show_as_tab']) && (int)$type['show_as_tab'] == 1 && in_array($type['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
1421
-                    continue;
1422
-                }
1423
-
1424
-                if ($type['type'] != 'fieldset'):
1425
-                    $variables_array['post_id'] = $post->ID;
1426
-                    $variables_array['label'] = __($type['site_title'], 'geodirectory');
1427
-                    $variables_array['value'] = '';
1428
-                    if (isset($post->{$type['htmlvar_name']}))
1429
-                        $variables_array['value'] = $post->{$type['htmlvar_name']};
1430
-                endif;
1431
-
1432
-
1433
-
1434
-                if ($html):
1435
-
1436
-                    /**
1437
-                     * Called before a custom fields is output on the frontend.
1438
-                     *
1439
-                     * @since 1.0.0
1440
-                     * @param string $html_var The HTML variable name for the field.
1441
-                     */
1442
-                    do_action("geodir_before_show_{$html_var}");
1443
-                    /**
1444
-                     * Filter custom field output.
1445
-                     *
1446
-                     * @since 1.0.0
1447
-                     *
1448
-                     * @param string $html_var The HTML variable name for the field.
1449
-                     * @param string $html Custom field unfiltered HTML.
1450
-                     * @param array $variables_array Custom field variables array.
1451
-                     */
1452
-                    if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
1453
-
1454
-                    /**
1455
-                     * Called after a custom fields is output on the frontend.
1456
-                     *
1457
-                     * @since 1.0.0
1458
-                     * @param string $html_var The HTML variable name for the field.
1459
-                     */
1460
-                    do_action("geodir_after_show_{$html_var}");
1461
-
1462
-                endif;
1463
-
1464
-            }
1465
-
1466
-            //echo '</div>';
1467
-
1468
-        }
1469
-
1470
-
1471
-        return $html = ob_get_clean();
1472
-
1473
-    }
1394
+			//echo '<div class="geodir-company_info field-group">';
1395
+			global $field_set_start;
1396
+			$field_set_start = 0;
1397
+
1398
+
1399
+
1400
+			foreach ($fields_info as $type) {
1401
+				$type = stripslashes_deep($type); // strip slashes
1402
+				$html = '';
1403
+				$html_var = '';
1404
+				$field_icon = geodir_field_icon_proccess($type);
1405
+				$filed_type = $type['type'];
1406
+
1407
+				/**
1408
+				 * Filter the output for custom fields.
1409
+				 *
1410
+				 * Here we can remove or add new functions depending on the field type.
1411
+				 *
1412
+				 * @param string $html The html to be filtered (blank).
1413
+				 * @param string $fields_location The location the field is to be show.
1414
+				 * @param array $type The array of field values.
1415
+				 */
1416
+				$html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
1417
+
1418
+				$variables_array = array();
1419
+
1420
+				if ($fields_location == 'detail' && isset($type['show_as_tab']) && (int)$type['show_as_tab'] == 1 && in_array($type['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
1421
+					continue;
1422
+				}
1423
+
1424
+				if ($type['type'] != 'fieldset'):
1425
+					$variables_array['post_id'] = $post->ID;
1426
+					$variables_array['label'] = __($type['site_title'], 'geodirectory');
1427
+					$variables_array['value'] = '';
1428
+					if (isset($post->{$type['htmlvar_name']}))
1429
+						$variables_array['value'] = $post->{$type['htmlvar_name']};
1430
+				endif;
1431
+
1432
+
1433
+
1434
+				if ($html):
1435
+
1436
+					/**
1437
+					 * Called before a custom fields is output on the frontend.
1438
+					 *
1439
+					 * @since 1.0.0
1440
+					 * @param string $html_var The HTML variable name for the field.
1441
+					 */
1442
+					do_action("geodir_before_show_{$html_var}");
1443
+					/**
1444
+					 * Filter custom field output.
1445
+					 *
1446
+					 * @since 1.0.0
1447
+					 *
1448
+					 * @param string $html_var The HTML variable name for the field.
1449
+					 * @param string $html Custom field unfiltered HTML.
1450
+					 * @param array $variables_array Custom field variables array.
1451
+					 */
1452
+					if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
1453
+
1454
+					/**
1455
+					 * Called after a custom fields is output on the frontend.
1456
+					 *
1457
+					 * @since 1.0.0
1458
+					 * @param string $html_var The HTML variable name for the field.
1459
+					 */
1460
+					do_action("geodir_after_show_{$html_var}");
1461
+
1462
+				endif;
1463
+
1464
+			}
1465
+
1466
+			//echo '</div>';
1467
+
1468
+		}
1469
+
1470
+
1471
+		return $html = ob_get_clean();
1472
+
1473
+	}
1474 1474
 }
1475 1475
 
1476 1476
 if (!function_exists('geodir_default_date_format')) {
1477
-    /**
1478
-     * Returns default date format.
1479
-     *
1480
-     * @since 1.0.0
1481
-     * @package GeoDirectory
1482
-     * @return mixed|string|void Returns default date format.
1483
-     */
1484
-    function geodir_default_date_format()
1485
-    {
1486
-        if ($format = get_option('date_format'))
1487
-            return $format;
1488
-        else
1489
-            return 'dd-mm-yy';
1490
-    }
1477
+	/**
1478
+	 * Returns default date format.
1479
+	 *
1480
+	 * @since 1.0.0
1481
+	 * @package GeoDirectory
1482
+	 * @return mixed|string|void Returns default date format.
1483
+	 */
1484
+	function geodir_default_date_format()
1485
+	{
1486
+		if ($format = get_option('date_format'))
1487
+			return $format;
1488
+		else
1489
+			return 'dd-mm-yy';
1490
+	}
1491 1491
 }
1492 1492
 
1493 1493
 if (!function_exists('geodir_get_formated_date')) {
1494
-    /**
1495
-     * Returns formatted date.
1496
-     *
1497
-     * @since 1.0.0
1498
-     * @package GeoDirectory
1499
-     * @param string $date Date string to convert.
1500
-     * @return bool|int|string Returns formatted date.
1501
-     */
1502
-    function geodir_get_formated_date($date)
1503
-    {
1504
-        return mysql2date(get_option('date_format'), $date);
1505
-    }
1494
+	/**
1495
+	 * Returns formatted date.
1496
+	 *
1497
+	 * @since 1.0.0
1498
+	 * @package GeoDirectory
1499
+	 * @param string $date Date string to convert.
1500
+	 * @return bool|int|string Returns formatted date.
1501
+	 */
1502
+	function geodir_get_formated_date($date)
1503
+	{
1504
+		return mysql2date(get_option('date_format'), $date);
1505
+	}
1506 1506
 }
1507 1507
 
1508 1508
 if (!function_exists('geodir_get_formated_time')) {
1509
-    /**
1510
-     * Returns formatted time.
1511
-     *
1512
-     * @since 1.0.0
1513
-     * @package GeoDirectory
1514
-     * @param string $time Time string to convert.
1515
-     * @return bool|int|string Returns formatted time.
1516
-     */
1517
-    function geodir_get_formated_time($time)
1518
-    {
1519
-        return mysql2date(get_option('time_format'), $time, $translate = true);
1520
-    }
1509
+	/**
1510
+	 * Returns formatted time.
1511
+	 *
1512
+	 * @since 1.0.0
1513
+	 * @package GeoDirectory
1514
+	 * @param string $time Time string to convert.
1515
+	 * @return bool|int|string Returns formatted time.
1516
+	 */
1517
+	function geodir_get_formated_time($time)
1518
+	{
1519
+		return mysql2date(get_option('time_format'), $time, $translate = true);
1520
+	}
1521 1521
 }
1522 1522
 
1523 1523
 
1524 1524
 if (!function_exists('geodir_save_post_file_fields')) {
1525
-    /**
1526
-     * Save post file fields
1527
-     *
1528
-     * @since 1.0.0
1529
-     * @since 1.4.7 Added `$extra_fields` parameter.
1530
-     * @package GeoDirectory
1531
-     * @global object $wpdb WordPress Database object.
1532
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1533
-     * @global object $current_user Current user object.
1534
-     * @param int $post_id
1535
-     * @param string $field_id
1536
-     * @param array $post_image
1537
-     * @param array $extra_fields Array of extra fields.
1538
-     */
1539
-    function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array())
1540
-    {
1525
+	/**
1526
+	 * Save post file fields
1527
+	 *
1528
+	 * @since 1.0.0
1529
+	 * @since 1.4.7 Added `$extra_fields` parameter.
1530
+	 * @package GeoDirectory
1531
+	 * @global object $wpdb WordPress Database object.
1532
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1533
+	 * @global object $current_user Current user object.
1534
+	 * @param int $post_id
1535
+	 * @param string $field_id
1536
+	 * @param array $post_image
1537
+	 * @param array $extra_fields Array of extra fields.
1538
+	 */
1539
+	function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array())
1540
+	{
1541 1541
 
1542
-        global $wpdb, $plugin_prefix, $current_user;
1542
+		global $wpdb, $plugin_prefix, $current_user;
1543 1543
 
1544
-        $post_type = get_post_type($post_id);
1545
-        //echo $field_id; exit;
1546
-        $table = $plugin_prefix . $post_type . '_detail';
1544
+		$post_type = get_post_type($post_id);
1545
+		//echo $field_id; exit;
1546
+		$table = $plugin_prefix . $post_type . '_detail';
1547 1547
 
1548
-        $postcurr_images = array();
1549
-        $postcurr_images = geodir_get_post_meta($post_id, $field_id, true);
1550
-        $file_urls = '';
1548
+		$postcurr_images = array();
1549
+		$postcurr_images = geodir_get_post_meta($post_id, $field_id, true);
1550
+		$file_urls = '';
1551 1551
 
1552
-        if (!empty($post_image)) {
1552
+		if (!empty($post_image)) {
1553 1553
 
1554
-            $invalid_files = array();
1554
+			$invalid_files = array();
1555 1555
 
1556
-            //Get and remove all old images of post from database to set by new order
1557
-            $geodir_uploaddir = '';
1558
-            $uploads = wp_upload_dir();
1559
-            $uploads_dir = $uploads['path'];
1556
+			//Get and remove all old images of post from database to set by new order
1557
+			$geodir_uploaddir = '';
1558
+			$uploads = wp_upload_dir();
1559
+			$uploads_dir = $uploads['path'];
1560 1560
 
1561
-            $geodir_uploadpath = $uploads['path'];
1562
-            $geodir_uploadurl = $uploads['url'];
1563
-            $sub_dir = $uploads['subdir'];
1561
+			$geodir_uploadpath = $uploads['path'];
1562
+			$geodir_uploadurl = $uploads['url'];
1563
+			$sub_dir = $uploads['subdir'];
1564 1564
 
1565
-            $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
1565
+			$allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
1566 1566
 
1567
-            for ($m = 0; $m < count($post_image); $m++) {
1567
+			for ($m = 0; $m < count($post_image); $m++) {
1568 1568
 
1569
-                /* --------- start ------- */
1569
+				/* --------- start ------- */
1570 1570
 
1571
-                if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM " . $table . " WHERE $field_id = %s AND post_id = %d", array($post_image[$m], $post_id)))) {
1571
+				if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM " . $table . " WHERE $field_id = %s AND post_id = %d", array($post_image[$m], $post_id)))) {
1572 1572
 
1573 1573
 
1574
-                    $curr_img_url = $post_image[$m];
1575
-                    $image_name_arr = explode('/', $curr_img_url);
1576
-                    $curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
1577
-                    $filename = end($image_name_arr);
1578
-                    $img_name_arr = explode('.', $filename);
1574
+					$curr_img_url = $post_image[$m];
1575
+					$image_name_arr = explode('/', $curr_img_url);
1576
+					$curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
1577
+					$filename = end($image_name_arr);
1578
+					$img_name_arr = explode('.', $filename);
1579 1579
 
1580
-                    $arr_file_type = wp_check_filetype($filename);
1580
+					$arr_file_type = wp_check_filetype($filename);
1581 1581
 
1582
-                    if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
1583
-                        continue;
1584
-                    }
1582
+					if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
1583
+						continue;
1584
+					}
1585 1585
 
1586
-                    $uploaded_file_type = $arr_file_type['type'];
1587
-                    $uploaded_file_ext = $arr_file_type['ext'];
1586
+					$uploaded_file_type = $arr_file_type['type'];
1587
+					$uploaded_file_ext = $arr_file_type['ext'];
1588 1588
 
1589
-                    if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
1590
-                        continue; // Invalid file type.
1591
-                    }
1589
+					if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
1590
+						continue; // Invalid file type.
1591
+					}
1592 1592
 
1593
-                    // Set an array containing a list of acceptable formats
1594
-                    //$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
1593
+					// Set an array containing a list of acceptable formats
1594
+					//$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
1595 1595
 
1596
-                    if (!function_exists('wp_handle_upload'))
1597
-                        require_once(ABSPATH . 'wp-admin/includes/file.php');
1596
+					if (!function_exists('wp_handle_upload'))
1597
+						require_once(ABSPATH . 'wp-admin/includes/file.php');
1598 1598
 
1599
-                    if (!is_dir($geodir_uploadpath))
1600
-                        mkdir($geodir_uploadpath);
1599
+					if (!is_dir($geodir_uploadpath))
1600
+						mkdir($geodir_uploadpath);
1601 1601
 
1602
-                    $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1];
1603
-                    $explode_sub_dir = explode("/", $sub_dir);
1604
-                    if ($curr_img_dir == end($explode_sub_dir)) {
1605
-                        $img_path = $geodir_uploadpath . '/' . $filename;
1606
-                        $img_url = $geodir_uploadurl . '/' . $filename;
1607
-                    } else {
1608
-                        $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1609
-                        $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1610
-                    }
1602
+					$new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1];
1603
+					$explode_sub_dir = explode("/", $sub_dir);
1604
+					if ($curr_img_dir == end($explode_sub_dir)) {
1605
+						$img_path = $geodir_uploadpath . '/' . $filename;
1606
+						$img_url = $geodir_uploadurl . '/' . $filename;
1607
+					} else {
1608
+						$img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1609
+						$img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1610
+					}
1611 1611
 
1612
-                    $uploaded_file = '';
1613
-                    if (file_exists($img_path))
1614
-                        $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1612
+					$uploaded_file = '';
1613
+					if (file_exists($img_path))
1614
+						$uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1615 1615
 
1616
-                    if ($curr_img_dir != $geodir_uploaddir) {
1617
-                        if (file_exists($img_path))
1618
-                            unlink($img_path);
1619
-                    }
1616
+					if ($curr_img_dir != $geodir_uploaddir) {
1617
+						if (file_exists($img_path))
1618
+							unlink($img_path);
1619
+					}
1620 1620
 
1621
-                    if (!empty($uploaded_file))
1622
-                        $file_urls = $geodir_uploadurl . '/' . $new_name;
1621
+					if (!empty($uploaded_file))
1622
+						$file_urls = $geodir_uploadurl . '/' . $new_name;
1623 1623
 
1624
-                } else {
1625
-                    $file_urls = $post_image[$m];
1626
-                }
1627
-            }
1624
+				} else {
1625
+					$file_urls = $post_image[$m];
1626
+				}
1627
+			}
1628 1628
 
1629 1629
 
1630
-        }
1630
+		}
1631 1631
 
1632
-        //Remove all old attachments and temp images
1633
-        if (!empty($postcurr_images)) {
1632
+		//Remove all old attachments and temp images
1633
+		if (!empty($postcurr_images)) {
1634 1634
 
1635
-            if ($file_urls != $postcurr_images) {
1636
-                $invalid_files[] = (object)array('src' => $postcurr_images);
1637
-                $invalid_files = (object)$invalid_files;
1638
-            }
1639
-        }
1635
+			if ($file_urls != $postcurr_images) {
1636
+				$invalid_files[] = (object)array('src' => $postcurr_images);
1637
+				$invalid_files = (object)$invalid_files;
1638
+			}
1639
+		}
1640 1640
 
1641
-        geodir_save_post_meta($post_id, $field_id, $file_urls);
1641
+		geodir_save_post_meta($post_id, $field_id, $file_urls);
1642 1642
 
1643
-        if (!empty($invalid_files))
1644
-            geodir_remove_attachments($invalid_files);
1643
+		if (!empty($invalid_files))
1644
+			geodir_remove_attachments($invalid_files);
1645 1645
 
1646
-    }
1646
+	}
1647 1647
 }
1648 1648
 
1649 1649
 
@@ -1658,76 +1658,76 @@  discard block
 block discarded – undo
1658 1658
  */
1659 1659
 function geodir_custom_upload_mimes($existing_mimes = array())
1660 1660
 {
1661
-    $existing_mimes['wif'] = 'text/plain';
1662
-    $existing_mimes['jpg|jpeg'] = 'image/jpeg';
1663
-    $existing_mimes['gif'] = 'image/gif';
1664
-    $existing_mimes['png'] = 'image/png';
1665
-    $existing_mimes['pdf'] = 'application/pdf';
1666
-    $existing_mimes['txt'] = 'text/text';
1667
-    $existing_mimes['csv'] = 'application/octet-stream';
1668
-    $existing_mimes['doc'] = 'application/msword';
1669
-    $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel';
1670
-    $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
1671
-    $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
1672
-    return $existing_mimes;
1661
+	$existing_mimes['wif'] = 'text/plain';
1662
+	$existing_mimes['jpg|jpeg'] = 'image/jpeg';
1663
+	$existing_mimes['gif'] = 'image/gif';
1664
+	$existing_mimes['png'] = 'image/png';
1665
+	$existing_mimes['pdf'] = 'application/pdf';
1666
+	$existing_mimes['txt'] = 'text/text';
1667
+	$existing_mimes['csv'] = 'application/octet-stream';
1668
+	$existing_mimes['doc'] = 'application/msword';
1669
+	$existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel';
1670
+	$existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
1671
+	$existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
1672
+	return $existing_mimes;
1673 1673
 }
1674 1674
 
1675 1675
 if (!function_exists('geodir_plupload_action')) {
1676 1676
 
1677
-    /**
1678
-     * Get upload directory path details
1679
-     *
1680
-     * @since 1.0.0
1681
-     * @package GeoDirectory
1682
-     * @global object $current_user Current user object.
1683
-     * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'.
1684
-     * @return mixed Returns upload directory details as an array.
1685
-     */
1686
-    function geodir_upload_dir($upload)
1687
-    {
1688
-        global $current_user;
1689
-        $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID;
1690
-        $upload['path'] = $upload['basedir'] . $upload['subdir'];
1691
-        $upload['url'] = $upload['baseurl'] . $upload['subdir'];
1692
-        return $upload;
1693
-    }
1694
-
1695
-    /**
1696
-     * Handles place file and image upload.
1697
-     *
1698
-     * @since 1.0.0
1699
-     * @package GeoDirectory
1700
-     */
1701
-    function geodir_plupload_action()
1702
-    {
1703
-        // check ajax noonce
1704
-        $imgid = $_POST["imgid"];
1705
-
1706
-        check_ajax_referer($imgid . 'pluploadan');
1707
-
1708
-        // handle custom file uploaddir
1709
-        add_filter('upload_dir', 'geodir_upload_dir');
1710
-
1711
-        // change file orinetation if needed
1712
-        $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']);
1713
-
1714
-        // handle file upload
1715
-        $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action'));
1716
-        // remove handle custom file uploaddir
1717
-        remove_filter('upload_dir', 'geodir_upload_dir');
1718
-
1719
-        if(!isset($status['url']) && isset($status['error'])){
1720
-            print_r($status);
1721
-        }
1722
-
1723
-        // send the uploaded file url in response
1724
-        if (isset($status['url'])) {
1725
-            echo $status['url'];
1726
-        } else {
1727
-            echo 'x';
1728
-        }
1729
-        exit;
1730
-    }
1677
+	/**
1678
+	 * Get upload directory path details
1679
+	 *
1680
+	 * @since 1.0.0
1681
+	 * @package GeoDirectory
1682
+	 * @global object $current_user Current user object.
1683
+	 * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'.
1684
+	 * @return mixed Returns upload directory details as an array.
1685
+	 */
1686
+	function geodir_upload_dir($upload)
1687
+	{
1688
+		global $current_user;
1689
+		$upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID;
1690
+		$upload['path'] = $upload['basedir'] . $upload['subdir'];
1691
+		$upload['url'] = $upload['baseurl'] . $upload['subdir'];
1692
+		return $upload;
1693
+	}
1694
+
1695
+	/**
1696
+	 * Handles place file and image upload.
1697
+	 *
1698
+	 * @since 1.0.0
1699
+	 * @package GeoDirectory
1700
+	 */
1701
+	function geodir_plupload_action()
1702
+	{
1703
+		// check ajax noonce
1704
+		$imgid = $_POST["imgid"];
1705
+
1706
+		check_ajax_referer($imgid . 'pluploadan');
1707
+
1708
+		// handle custom file uploaddir
1709
+		add_filter('upload_dir', 'geodir_upload_dir');
1710
+
1711
+		// change file orinetation if needed
1712
+		$fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']);
1713
+
1714
+		// handle file upload
1715
+		$status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action'));
1716
+		// remove handle custom file uploaddir
1717
+		remove_filter('upload_dir', 'geodir_upload_dir');
1718
+
1719
+		if(!isset($status['url']) && isset($status['error'])){
1720
+			print_r($status);
1721
+		}
1722
+
1723
+		// send the uploaded file url in response
1724
+		if (isset($status['url'])) {
1725
+			echo $status['url'];
1726
+		} else {
1727
+			echo 'x';
1728
+		}
1729
+		exit;
1730
+	}
1731 1731
 }
1732 1732
 
1733 1733
 /**
@@ -1742,17 +1742,17 @@  discard block
 block discarded – undo
1742 1742
  */
1743 1743
 function geodir_get_video($post_id)
1744 1744
 {
1745
-    global $wpdb, $plugin_prefix;
1745
+	global $wpdb, $plugin_prefix;
1746 1746
 
1747
-    $post_type = get_post_type($post_id);
1747
+	$post_type = get_post_type($post_id);
1748 1748
 
1749
-    $table = $plugin_prefix . $post_type . '_detail';
1749
+	$table = $plugin_prefix . $post_type . '_detail';
1750 1750
 
1751
-    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id)));
1751
+	$results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id)));
1752 1752
 
1753
-    if ($results) {
1754
-        return $results[0]->geodir_video;
1755
-    }
1753
+	if ($results) {
1754
+		return $results[0]->geodir_video;
1755
+	}
1756 1756
 
1757 1757
 }
1758 1758
 
@@ -1768,40 +1768,40 @@  discard block
 block discarded – undo
1768 1768
  */
1769 1769
 function geodir_get_special_offers($post_id)
1770 1770
 {
1771
-    global $wpdb, $plugin_prefix;
1771
+	global $wpdb, $plugin_prefix;
1772 1772
 
1773
-    $post_type = get_post_type($post_id);
1773
+	$post_type = get_post_type($post_id);
1774 1774
 
1775
-    $table = $plugin_prefix . $post_type . '_detail';
1775
+	$table = $plugin_prefix . $post_type . '_detail';
1776 1776
 
1777
-    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id)));
1777
+	$results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id)));
1778 1778
 
1779
-    if ($results) {
1780
-        return $results[0]->geodir_special_offers;
1781
-    }
1779
+	if ($results) {
1780
+		return $results[0]->geodir_special_offers;
1781
+	}
1782 1782
 
1783 1783
 }
1784 1784
 
1785 1785
 if (!function_exists('geodir_max_upload_size')) {
1786
-    /**
1787
-     * Get max upload file size
1788
-     *
1789
-     * @since 1.0.0
1790
-     * @package GeoDirectory
1791
-     * @return mixed|void Returns max upload file size.
1792
-     */
1793
-    function geodir_max_upload_size()
1794
-    {
1795
-        $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1796
-
1797
-        if ($max_filesize > 0 && $max_filesize < 1) {
1798
-            $max_filesize = (int)($max_filesize * 1024) . 'kb';
1799
-        } else {
1800
-            $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1801
-        }
1802
-        /** Filter documented in geodirectory-functions/general_functions.php **/
1803
-        return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1804
-    }
1786
+	/**
1787
+	 * Get max upload file size
1788
+	 *
1789
+	 * @since 1.0.0
1790
+	 * @package GeoDirectory
1791
+	 * @return mixed|void Returns max upload file size.
1792
+	 */
1793
+	function geodir_max_upload_size()
1794
+	{
1795
+		$max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1796
+
1797
+		if ($max_filesize > 0 && $max_filesize < 1) {
1798
+			$max_filesize = (int)($max_filesize * 1024) . 'kb';
1799
+		} else {
1800
+			$max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1801
+		}
1802
+		/** Filter documented in geodirectory-functions/general_functions.php **/
1803
+		return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1804
+	}
1805 1805
 }
1806 1806
 
1807 1807
 
@@ -1819,33 +1819,33 @@  discard block
 block discarded – undo
1819 1819
  */
1820 1820
 function geodir_add_custom_sort_options($fields, $post_type)
1821 1821
 {
1822
-    global $wpdb;
1822
+	global $wpdb;
1823 1823
 
1824
-    if ($post_type != '') {
1824
+	if ($post_type != '') {
1825 1825
 
1826
-        $all_postypes = geodir_get_posttypes();
1826
+		$all_postypes = geodir_get_posttypes();
1827 1827
 
1828
-        if (in_array($post_type, $all_postypes)) {
1828
+		if (in_array($post_type, $all_postypes)) {
1829 1829
 
1830
-            $custom_fields = $wpdb->get_results(
1831
-                $wpdb->prepare(
1832
-                    "select post_type,data_type,field_type,site_title,htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where post_type = %s and is_active='1' and cat_sort='1' AND field_type != 'address' order by sort_order asc",
1833
-                    array($post_type)
1834
-                ), 'ARRAY_A'
1835
-            );
1830
+			$custom_fields = $wpdb->get_results(
1831
+				$wpdb->prepare(
1832
+					"select post_type,data_type,field_type,site_title,htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where post_type = %s and is_active='1' and cat_sort='1' AND field_type != 'address' order by sort_order asc",
1833
+					array($post_type)
1834
+				), 'ARRAY_A'
1835
+			);
1836 1836
 
1837
-            if (!empty($custom_fields)) {
1837
+			if (!empty($custom_fields)) {
1838 1838
 
1839
-                foreach ($custom_fields as $val) {
1840
-                    $fields[] = $val;
1841
-                }
1842
-            }
1839
+				foreach ($custom_fields as $val) {
1840
+					$fields[] = $val;
1841
+				}
1842
+			}
1843 1843
 
1844
-        }
1844
+		}
1845 1845
 
1846
-    }
1846
+	}
1847 1847
 
1848
-    return $fields;
1848
+	return $fields;
1849 1849
 }
1850 1850
 
1851 1851
 
@@ -1861,66 +1861,66 @@  discard block
 block discarded – undo
1861 1861
 function geodir_get_custom_sort_options($post_type = '')
1862 1862
 {
1863 1863
 
1864
-    global $wpdb;
1865
-
1866
-    if ($post_type != '') {
1867
-
1868
-        $all_postypes = geodir_get_posttypes();
1869
-
1870
-        if (!in_array($post_type, $all_postypes))
1871
-            return false;
1872
-
1873
-        $fields = array();
1874
-
1875
-        $fields[] = array(
1876
-            'post_type' => $post_type,
1877
-            'data_type' => '',
1878
-            'field_type' => 'random',
1879
-            'site_title' => 'Random',
1880
-            'htmlvar_name' => 'post_title'
1881
-        );
1882
-
1883
-        $fields[] = array(
1884
-            'post_type' => $post_type,
1885
-            'data_type' => '',
1886
-            'field_type' => 'datetime',
1887
-            'site_title' => __('Add date', 'geodirectory'),
1888
-            'htmlvar_name' => 'post_date'
1889
-        );
1890
-        $fields[] = array(
1891
-            'post_type' => $post_type,
1892
-            'data_type' => '',
1893
-            'field_type' => 'bigint',
1894
-            'site_title' => __('Review', 'geodirectory'),
1895
-            'htmlvar_name' => 'comment_count'
1896
-        );
1897
-        $fields[] = array(
1898
-            'post_type' => $post_type,
1899
-            'data_type' => '',
1900
-            'field_type' => 'float',
1901
-            'site_title' => __('Rating', 'geodirectory'),
1902
-            'htmlvar_name' => 'overall_rating'
1903
-        );
1904
-        $fields[] = array(
1905
-            'post_type' => $post_type,
1906
-            'data_type' => '',
1907
-            'field_type' => 'text',
1908
-            'site_title' => __('Title', 'geodirectory'),
1909
-            'htmlvar_name' => 'post_title'
1910
-        );
1911
-
1912
-        /**
1913
-         * Hook to add custom sort options.
1914
-         *
1915
-         * @since 1.0.0
1916
-         * @param array $fields Unmodified sort options array.
1917
-         * @param string $post_type Post type.
1918
-         */
1919
-        return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type);
1920
-
1921
-    }
1922
-
1923
-    return false;
1864
+	global $wpdb;
1865
+
1866
+	if ($post_type != '') {
1867
+
1868
+		$all_postypes = geodir_get_posttypes();
1869
+
1870
+		if (!in_array($post_type, $all_postypes))
1871
+			return false;
1872
+
1873
+		$fields = array();
1874
+
1875
+		$fields[] = array(
1876
+			'post_type' => $post_type,
1877
+			'data_type' => '',
1878
+			'field_type' => 'random',
1879
+			'site_title' => 'Random',
1880
+			'htmlvar_name' => 'post_title'
1881
+		);
1882
+
1883
+		$fields[] = array(
1884
+			'post_type' => $post_type,
1885
+			'data_type' => '',
1886
+			'field_type' => 'datetime',
1887
+			'site_title' => __('Add date', 'geodirectory'),
1888
+			'htmlvar_name' => 'post_date'
1889
+		);
1890
+		$fields[] = array(
1891
+			'post_type' => $post_type,
1892
+			'data_type' => '',
1893
+			'field_type' => 'bigint',
1894
+			'site_title' => __('Review', 'geodirectory'),
1895
+			'htmlvar_name' => 'comment_count'
1896
+		);
1897
+		$fields[] = array(
1898
+			'post_type' => $post_type,
1899
+			'data_type' => '',
1900
+			'field_type' => 'float',
1901
+			'site_title' => __('Rating', 'geodirectory'),
1902
+			'htmlvar_name' => 'overall_rating'
1903
+		);
1904
+		$fields[] = array(
1905
+			'post_type' => $post_type,
1906
+			'data_type' => '',
1907
+			'field_type' => 'text',
1908
+			'site_title' => __('Title', 'geodirectory'),
1909
+			'htmlvar_name' => 'post_title'
1910
+		);
1911
+
1912
+		/**
1913
+		 * Hook to add custom sort options.
1914
+		 *
1915
+		 * @since 1.0.0
1916
+		 * @param array $fields Unmodified sort options array.
1917
+		 * @param string $post_type Post type.
1918
+		 */
1919
+		return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type);
1920
+
1921
+	}
1922
+
1923
+	return false;
1924 1924
 }
1925 1925
 
1926 1926
 
@@ -1936,117 +1936,117 @@  discard block
 block discarded – undo
1936 1936
 function godir_set_sort_field_order($field_ids = array())
1937 1937
 {
1938 1938
 
1939
-    global $wpdb;
1939
+	global $wpdb;
1940 1940
 
1941
-    $count = 0;
1942
-    if (!empty($field_ids)):
1943
-        foreach ($field_ids as $id) {
1941
+	$count = 0;
1942
+	if (!empty($field_ids)):
1943
+		foreach ($field_ids as $id) {
1944 1944
 
1945
-            $cf = trim($id, '_');
1945
+			$cf = trim($id, '_');
1946 1946
 
1947
-            $post_meta_info = $wpdb->query(
1948
-                $wpdb->prepare(
1949
-                    "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
1947
+			$post_meta_info = $wpdb->query(
1948
+				$wpdb->prepare(
1949
+					"update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
1950 1950
 															sort_order=%d 
1951 1951
 															where id= %d",
1952
-                    array($count, $cf)
1953
-                )
1954
-            );
1955
-            $count++;
1956
-        }
1957
-
1958
-        return $field_ids;
1959
-    else:
1960
-        return false;
1961
-    endif;
1952
+					array($count, $cf)
1953
+				)
1954
+			);
1955
+			$count++;
1956
+		}
1957
+
1958
+		return $field_ids;
1959
+	else:
1960
+		return false;
1961
+	endif;
1962 1962
 }
1963 1963
 
1964 1964
 
1965 1965
 if (!function_exists('geodir_custom_sort_field_save')) {
1966
-    /**
1967
-     * Save or Update custom sort fields into the database.
1968
-     *
1969
-     * @since 1.0.0
1970
-     * @package GeoDirectory
1971
-     * @global object $wpdb WordPress Database object.
1972
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1973
-     * @param array $request_field {
1974
-     *    Attributes of the Request field.
1975
-     *
1976
-     *    @type string $action Ajax action name.
1977
-     *    @type string $manage_field_type Manage field type Default "sorting_options".
1978
-     *    @type string $create_field Do you want to create this field?.
1979
-     *    @type string $field_ins_upd Field created or updated?.
1980
-     *    @type string $_wpnonce Nonce value.
1981
-     *    @type string $listing_type The Post type.
1982
-     *    @type string $field_type Field Type.
1983
-     *    @type string $field_id Field ID.
1984
-     *    @type string $data_type Data Type.
1985
-     *    @type string $htmlvar_name HTML variable name.
1986
-     *    @type string $site_title Section title which you wish to display in frontend.
1987
-     *    @type string $is_default Is this default sorting?.
1988
-     *    @type string $is_active If not active then the field will not be displayed anywhere.
1989
-     *    @type string $sort_order Sort Order.
1990
-     *
1991
-     * }
1992
-     * @param bool $default Not yet implemented.
1993
-     * @return int Returns the last affected db table row id.
1994
-     */
1995
-    function geodir_custom_sort_field_save($request_field = array(), $default = false)
1996
-    {
1997
-
1998
-        global $wpdb, $plugin_prefix;
1999
-
2000
-        $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
2001
-
2002
-        $cf = trim($result_str, '_');
2003
-
2004
-        /*-------- check dublicate validation --------*/
2005
-
2006
-        $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
2007
-        $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
2008
-
2009
-        $post_type = $request_field['listing_type'];
2010
-        $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : '';
2011
-        $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
2012
-        $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : '';
2013
-        $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
2014
-        $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0;
2015
-        $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0;
2016
-        $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : '';
2017
-        $asc = isset($request_field['asc']) ? $request_field['asc'] : 0;
2018
-        $desc = isset($request_field['desc']) ? $request_field['desc'] : 0;
2019
-        $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : '';
2020
-        $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : '';
2021
-
2022
-        $default_order = '';
2023
-        if ($is_default != '') {
2024
-            $default_order = $is_default;
2025
-            $is_default = '1';
2026
-        }
2027
-
2028
-
2029
-        $check_html_variable = $wpdb->get_var(
2030
-            $wpdb->prepare(
2031
-                "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ",
2032
-                array($cehhtmlvar_name, $post_type, $field_type)
2033
-            )
2034
-        );
2035
-
2036
-        if ($is_default == 1) {
2037
-
2038
-            $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type)));
2039
-
2040
-        }
2041
-
2042
-
2043
-        if (!$check_html_variable) {
2044
-
2045
-            $wpdb->query(
2046
-
2047
-                $wpdb->prepare(
2048
-
2049
-                    "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
1966
+	/**
1967
+	 * Save or Update custom sort fields into the database.
1968
+	 *
1969
+	 * @since 1.0.0
1970
+	 * @package GeoDirectory
1971
+	 * @global object $wpdb WordPress Database object.
1972
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1973
+	 * @param array $request_field {
1974
+	 *    Attributes of the Request field.
1975
+	 *
1976
+	 *    @type string $action Ajax action name.
1977
+	 *    @type string $manage_field_type Manage field type Default "sorting_options".
1978
+	 *    @type string $create_field Do you want to create this field?.
1979
+	 *    @type string $field_ins_upd Field created or updated?.
1980
+	 *    @type string $_wpnonce Nonce value.
1981
+	 *    @type string $listing_type The Post type.
1982
+	 *    @type string $field_type Field Type.
1983
+	 *    @type string $field_id Field ID.
1984
+	 *    @type string $data_type Data Type.
1985
+	 *    @type string $htmlvar_name HTML variable name.
1986
+	 *    @type string $site_title Section title which you wish to display in frontend.
1987
+	 *    @type string $is_default Is this default sorting?.
1988
+	 *    @type string $is_active If not active then the field will not be displayed anywhere.
1989
+	 *    @type string $sort_order Sort Order.
1990
+	 *
1991
+	 * }
1992
+	 * @param bool $default Not yet implemented.
1993
+	 * @return int Returns the last affected db table row id.
1994
+	 */
1995
+	function geodir_custom_sort_field_save($request_field = array(), $default = false)
1996
+	{
1997
+
1998
+		global $wpdb, $plugin_prefix;
1999
+
2000
+		$result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
2001
+
2002
+		$cf = trim($result_str, '_');
2003
+
2004
+		/*-------- check dublicate validation --------*/
2005
+
2006
+		$field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
2007
+		$cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
2008
+
2009
+		$post_type = $request_field['listing_type'];
2010
+		$data_type = isset($request_field['data_type']) ? $request_field['data_type'] : '';
2011
+		$field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
2012
+		$site_title = isset($request_field['site_title']) ? $request_field['site_title'] : '';
2013
+		$htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
2014
+		$sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0;
2015
+		$is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0;
2016
+		$is_default = isset($request_field['is_default']) ? $request_field['is_default'] : '';
2017
+		$asc = isset($request_field['asc']) ? $request_field['asc'] : 0;
2018
+		$desc = isset($request_field['desc']) ? $request_field['desc'] : 0;
2019
+		$asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : '';
2020
+		$desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : '';
2021
+
2022
+		$default_order = '';
2023
+		if ($is_default != '') {
2024
+			$default_order = $is_default;
2025
+			$is_default = '1';
2026
+		}
2027
+
2028
+
2029
+		$check_html_variable = $wpdb->get_var(
2030
+			$wpdb->prepare(
2031
+				"select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ",
2032
+				array($cehhtmlvar_name, $post_type, $field_type)
2033
+			)
2034
+		);
2035
+
2036
+		if ($is_default == 1) {
2037
+
2038
+			$wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type)));
2039
+
2040
+		}
2041
+
2042
+
2043
+		if (!$check_html_variable) {
2044
+
2045
+			$wpdb->query(
2046
+
2047
+				$wpdb->prepare(
2048
+
2049
+					"insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
2050 2050
 				post_type = %s,
2051 2051
 				data_type = %s,
2052 2052
 				field_type = %s,
@@ -2061,23 +2061,23 @@  discard block
 block discarded – undo
2061 2061
 				asc_title = %s,
2062 2062
 				desc_title = %s",
2063 2063
 
2064
-                    array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title)
2065
-                )
2064
+					array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title)
2065
+				)
2066 2066
 
2067
-            );
2067
+			);
2068 2068
 
2069 2069
 
2070
-            $lastid = $wpdb->insert_id;
2070
+			$lastid = $wpdb->insert_id;
2071 2071
 
2072
-            $lastid = trim($lastid);
2072
+			$lastid = trim($lastid);
2073 2073
 
2074
-        } else {
2074
+		} else {
2075 2075
 
2076
-            $wpdb->query(
2076
+			$wpdb->query(
2077 2077
 
2078
-                $wpdb->prepare(
2078
+				$wpdb->prepare(
2079 2079
 
2080
-                    "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
2080
+					"update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
2081 2081
 				post_type = %s,
2082 2082
 				data_type = %s,
2083 2083
 				field_type = %s,
@@ -2093,115 +2093,115 @@  discard block
 block discarded – undo
2093 2093
 				desc_title = %s
2094 2094
 				where id = %d",
2095 2095
 
2096
-                    array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title, $cf)
2097
-                )
2096
+					array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title, $cf)
2097
+				)
2098 2098
 
2099
-            );
2099
+			);
2100 2100
 
2101
-            $lastid = trim($cf);
2101
+			$lastid = trim($cf);
2102 2102
 
2103
-        }
2103
+		}
2104 2104
 
2105 2105
 
2106
-        return (int)$lastid;
2106
+		return (int)$lastid;
2107 2107
 
2108
-    }
2108
+	}
2109 2109
 }
2110 2110
 
2111 2111
 
2112 2112
 if (!function_exists('geodir_custom_sort_field_delete')) {
2113
-    /**
2114
-     * Delete a custom sort field using field id.
2115
-     * @since 1.0.0
2116
-     * @package GeoDirectory
2117
-     * @global object $wpdb WordPress Database object.
2118
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2119
-     * @param string $field_id The field ID.
2120
-     * @return int|string Returns field id when successful deletion, else returns 0.
2121
-     */
2122
-    function geodir_custom_sort_field_delete($field_id = '')
2123
-    {
2124
-
2125
-        global $wpdb, $plugin_prefix;
2126
-        if ($field_id != '') {
2127
-            $cf = trim($field_id, '_');
2128
-
2129
-            $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf)));
2130
-
2131
-            return $field_id;
2132
-
2133
-        } else
2134
-            return 0;
2135
-
2136
-    }
2113
+	/**
2114
+	 * Delete a custom sort field using field id.
2115
+	 * @since 1.0.0
2116
+	 * @package GeoDirectory
2117
+	 * @global object $wpdb WordPress Database object.
2118
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2119
+	 * @param string $field_id The field ID.
2120
+	 * @return int|string Returns field id when successful deletion, else returns 0.
2121
+	 */
2122
+	function geodir_custom_sort_field_delete($field_id = '')
2123
+	{
2124
+
2125
+		global $wpdb, $plugin_prefix;
2126
+		if ($field_id != '') {
2127
+			$cf = trim($field_id, '_');
2128
+
2129
+			$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf)));
2130
+
2131
+			return $field_id;
2132
+
2133
+		} else
2134
+			return 0;
2135
+
2136
+	}
2137 2137
 }
2138 2138
 
2139 2139
 
2140 2140
 if (!function_exists('geodir_custom_sort_field_adminhtml')) {
2141
-    /**
2142
-     * Custom sort field admin html.
2143
-     *
2144
-     * @since 1.0.0
2145
-     * @package GeoDirectory
2146
-     * @global object $wpdb WordPress Database object.
2147
-     * @param string $field_type The form field type.
2148
-     * @param object|int $result_str The custom field results object or row id.
2149
-     * @param string $field_ins_upd When set to "submit" displays form.
2150
-     * @param bool $default when set to true field will be for admin use only.
2151
-     */
2152
-    function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $default = false)
2153
-    {
2154
-        global $wpdb;
2155
-        $cf = $result_str;
2156
-        if (!is_object($cf)) {
2157
-            $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf)));
2158
-        } else {
2159
-            $field_info = $cf;
2160
-            $result_str = $cf->id;
2161
-        }
2162
-
2163
-        $field_info = stripslashes_deep($field_info); // strip slashes
2164
-
2165
-        if (!isset($field_info->post_type)) {
2166
-            $post_type = sanitize_text_field($_REQUEST['listing_type']);
2167
-        } else {
2168
-            $post_type = $field_info->post_type;
2169
-        }
2170
-
2171
-        $field_types = explode('-_-', $field_type);
2172
-        $field_type = $field_types[0];
2173
-        $htmlvar_name = isset($field_types[1]) ? $field_types[1] : '';
2174
-
2175
-        $site_title = '';
2176
-        if ($site_title == '')
2177
-            $site_title = isset($field_info->site_title) ? $field_info->site_title : '';
2178
-
2179
-        if ($site_title == '') {
2180
-            $fields = geodir_get_custom_sort_options($post_type);
2181
-
2182
-            foreach ($fields as $val) {
2183
-                $val = stripslashes_deep($val); // strip slashes
2184
-
2185
-                if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
2186
-                    $site_title = isset($val['site_title']) ? $val['site_title'] : '';
2187
-                }
2188
-            }
2189
-        }
2190
-
2191
-        if ($htmlvar_name == '')
2192
-            $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
2193
-
2194
-        $nonce = wp_create_nonce('custom_fields_' . $result_str);
2195
-
2196
-        ?>
2141
+	/**
2142
+	 * Custom sort field admin html.
2143
+	 *
2144
+	 * @since 1.0.0
2145
+	 * @package GeoDirectory
2146
+	 * @global object $wpdb WordPress Database object.
2147
+	 * @param string $field_type The form field type.
2148
+	 * @param object|int $result_str The custom field results object or row id.
2149
+	 * @param string $field_ins_upd When set to "submit" displays form.
2150
+	 * @param bool $default when set to true field will be for admin use only.
2151
+	 */
2152
+	function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $default = false)
2153
+	{
2154
+		global $wpdb;
2155
+		$cf = $result_str;
2156
+		if (!is_object($cf)) {
2157
+			$field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf)));
2158
+		} else {
2159
+			$field_info = $cf;
2160
+			$result_str = $cf->id;
2161
+		}
2162
+
2163
+		$field_info = stripslashes_deep($field_info); // strip slashes
2164
+
2165
+		if (!isset($field_info->post_type)) {
2166
+			$post_type = sanitize_text_field($_REQUEST['listing_type']);
2167
+		} else {
2168
+			$post_type = $field_info->post_type;
2169
+		}
2170
+
2171
+		$field_types = explode('-_-', $field_type);
2172
+		$field_type = $field_types[0];
2173
+		$htmlvar_name = isset($field_types[1]) ? $field_types[1] : '';
2174
+
2175
+		$site_title = '';
2176
+		if ($site_title == '')
2177
+			$site_title = isset($field_info->site_title) ? $field_info->site_title : '';
2178
+
2179
+		if ($site_title == '') {
2180
+			$fields = geodir_get_custom_sort_options($post_type);
2181
+
2182
+			foreach ($fields as $val) {
2183
+				$val = stripslashes_deep($val); // strip slashes
2184
+
2185
+				if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
2186
+					$site_title = isset($val['site_title']) ? $val['site_title'] : '';
2187
+				}
2188
+			}
2189
+		}
2190
+
2191
+		if ($htmlvar_name == '')
2192
+			$htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
2193
+
2194
+		$nonce = wp_create_nonce('custom_fields_' . $result_str);
2195
+
2196
+		?>
2197 2197
         <li class="text" id="licontainer_<?php echo $result_str;?>">
2198 2198
             <div class="title title<?php echo $result_str;?> gt-fieldset"
2199 2199
                  title="<?php _e('Double Click to toggle and drag-drop to sort', 'geodirectory');?>"
2200 2200
                  ondblclick="show_hide('field_frm<?php echo $result_str;?>')">
2201 2201
                 <?php
2202 2202
 
2203
-                $nonce = wp_create_nonce('custom_fields_' . $result_str);
2204
-                ?>
2203
+				$nonce = wp_create_nonce('custom_fields_' . $result_str);
2204
+				?>
2205 2205
 
2206 2206
                 <div title="<?php _e('Click to remove field', 'geodirectory');?>"
2207 2207
                      onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)"
@@ -2214,17 +2214,17 @@  discard block
 block discarded – undo
2214 2214
 
2215 2215
             <div id="field_frm<?php echo $result_str;?>" class="field_frm"
2216 2216
                  style="display:<?php if ($field_ins_upd == 'submit') {
2217
-                     echo 'block;';
2218
-                 } else {
2219
-                     echo 'none;';
2220
-                 } ?>">
2217
+					 echo 'block;';
2218
+				 } else {
2219
+					 echo 'none;';
2220
+				 } ?>">
2221 2221
                 <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/>
2222 2222
                 <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type;?>"/>
2223 2223
                 <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type;?>"/>
2224 2224
                 <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str;?>"/>
2225 2225
                 <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) {
2226
-                    echo $field_info->data_type;
2227
-                }?>"/>
2226
+					echo $field_info->data_type;
2227
+				}?>"/>
2228 2228
                 <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name;?>"/>
2229 2229
 
2230 2230
 
@@ -2239,19 +2239,19 @@  discard block
 block discarded – undo
2239 2239
                             <td>
2240 2240
                                 <input type="checkbox" name="asc" id="asc"
2241 2241
                                        value="1" <?php if (isset($field_info->sort_asc) && $field_info->sort_asc == '1') {
2242
-                                    echo 'checked="checked"';
2243
-                                } ?>/>
2242
+									echo 'checked="checked"';
2243
+								} ?>/>
2244 2244
 
2245 2245
                                 <input type="text" name="asc_title" id="asc_title"
2246 2246
                                        placeholder="<?php esc_attr_e('Ascending title', 'geodirectory'); ?>"
2247 2247
                                        value="<?php if (isset($field_info->asc_title)) {
2248
-                                           echo esc_attr($field_info->asc_title);
2249
-                                       } ?>" style="width:45%;"/>
2248
+										   echo esc_attr($field_info->asc_title);
2249
+									   } ?>" style="width:45%;"/>
2250 2250
 
2251 2251
                                 <input type="radio" name="is_default"
2252 2252
                                        value="<?php echo $htmlvar_name; ?>_asc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_asc') {
2253
-                                    echo 'checked="checked"';
2254
-                                } ?>/><span><?php _e('Set as default sort.', 'geodirectory'); ?></span>
2253
+									echo 'checked="checked"';
2254
+								} ?>/><span><?php _e('Set as default sort.', 'geodirectory'); ?></span>
2255 2255
 
2256 2256
                                 <br/>
2257 2257
                                 <span><?php _e('Select if you want to show option in sort.', 'geodirectory'); ?></span>
@@ -2263,18 +2263,18 @@  discard block
 block discarded – undo
2263 2263
                             <td>
2264 2264
                                 <input type="checkbox" name="desc" id="desc"
2265 2265
                                        value="1" <?php if (isset($field_info->sort_desc) && $field_info->sort_desc == '1') {
2266
-                                    echo 'checked="checked"';
2267
-                                } ?>/>
2266
+									echo 'checked="checked"';
2267
+								} ?>/>
2268 2268
 
2269 2269
                                 <input type="text" name="desc_title" id="desc_title"
2270 2270
                                        placeholder="<?php esc_attr_e('Descending title', 'geodirectory'); ?>"
2271 2271
                                        value="<?php if (isset($field_info->desc_title)) {
2272
-                                           echo esc_attr($field_info->desc_title);
2273
-                                       } ?>" style="width:45%;"/>
2272
+										   echo esc_attr($field_info->desc_title);
2273
+									   } ?>" style="width:45%;"/>
2274 2274
                                 <input type="radio" name="is_default"
2275 2275
                                        value="<?php echo $htmlvar_name; ?>_desc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_desc') {
2276
-                                    echo 'checked="checked"';
2277
-                                } ?>/><span><?php _e('Set as default sort.', 'geodirectory'); ?></span>
2276
+									echo 'checked="checked"';
2277
+								} ?>/><span><?php _e('Set as default sort.', 'geodirectory'); ?></span>
2278 2278
                                 <br/>
2279 2279
                                 <span><?php _e('Select if you want to show option in sort.', 'geodirectory'); ?></span>
2280 2280
                             </td>
@@ -2297,8 +2297,8 @@  discard block
 block discarded – undo
2297 2297
                             <td align="left">
2298 2298
                                 <input type="checkbox" name="is_default"
2299 2299
                                        value="<?php echo $field_type; ?>"  <?php if (isset($field_info->is_default) && $field_info->is_default == '1') {
2300
-                                    echo 'checked="checked"';
2301
-                                } ?>/>
2300
+									echo 'checked="checked"';
2301
+								} ?>/>
2302 2302
                                 <br/>
2303 2303
                                 <span><?php _e('If field is checked then the field will be use as default sort.', 'geodirectory'); ?></span>
2304 2304
                             </td>
@@ -2312,12 +2312,12 @@  discard block
 block discarded – undo
2312 2312
                             <select name="is_active" id="is_active">
2313 2313
                                 <option
2314 2314
                                     value="1" <?php if (isset($field_info->is_active) && $field_info->is_active == '1') {
2315
-                                    echo 'selected="selected"';
2316
-                                }?>><?php _e('Yes', 'geodirectory');?></option>
2315
+									echo 'selected="selected"';
2316
+								}?>><?php _e('Yes', 'geodirectory');?></option>
2317 2317
                                 <option
2318 2318
                                     value="0" <?php if (isset($field_info->is_active) && $field_info->is_active == '0') {
2319
-                                    echo 'selected="selected"';
2320
-                                }?>><?php _e('No', 'geodirectory');?></option>
2319
+									echo 'selected="selected"';
2320
+								}?>><?php _e('No', 'geodirectory');?></option>
2321 2321
                             </select>
2322 2322
                             <br/>
2323 2323
                             <span><?php _e('Select yes or no. If no is selected then the field will not be displayed anywhere.', 'geodirectory');?></span>
@@ -2328,8 +2328,8 @@  discard block
 block discarded – undo
2328 2328
                         <td><strong><?php _e('Display order :', 'geodirectory');?></strong></td>
2329 2329
                         <td align="left"><input type="text" readonly="readonly" name="sort_order" id="sort_order"
2330 2330
                                                 value="<?php if (isset($field_info->sort_order)) {
2331
-                                                    echo esc_attr($field_info->sort_order);
2332
-                                                }?>" size="50"/>
2331
+													echo esc_attr($field_info->sort_order);
2332
+												}?>" size="50"/>
2333 2333
                             <br/>
2334 2334
                             <span><?php _e('Enter the display order of this field in backend. e.g. 5', 'geodirectory');?></span>
2335 2335
                         </td>
@@ -2352,38 +2352,38 @@  discard block
 block discarded – undo
2352 2352
             </div>
2353 2353
         </li> <?php
2354 2354
 
2355
-    }
2355
+	}
2356 2356
 }
2357 2357
 
2358 2358
 if (!function_exists('check_field_visibility')) {
2359
-    /**
2360
-     * Check field visibility as per price package.
2361
-     *
2362
-     * @since 1.0.0
2363
-     * @package GeoDirectory
2364
-     * @global object $wpdb WordPress Database object.
2365
-     * @global array $geodir_addon_list List of active GeoDirectory extensions.
2366
-     * @param int|string $package_id The package ID.
2367
-     * @param string $field_name The field name.
2368
-     * @param string $post_type Optional. The wordpress post type.
2369
-     * @return bool Returns true when field visible, otherwise false.
2370
-     */
2371
-    function check_field_visibility($package_id, $field_name, $post_type)
2372
-    {
2373
-        global $wpdb, $geodir_addon_list;
2374
-        if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) {
2375
-            return true;
2376
-        }
2377
-        if (!$package_id || !$field_name || !$post_type) {
2378
-            return true;
2379
-        }
2380
-        $sql = $wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int)$package_id));
2381
-
2382
-        if ($wpdb->get_var($sql)) {
2383
-            return true;
2384
-        }
2385
-        return false;
2386
-    }
2359
+	/**
2360
+	 * Check field visibility as per price package.
2361
+	 *
2362
+	 * @since 1.0.0
2363
+	 * @package GeoDirectory
2364
+	 * @global object $wpdb WordPress Database object.
2365
+	 * @global array $geodir_addon_list List of active GeoDirectory extensions.
2366
+	 * @param int|string $package_id The package ID.
2367
+	 * @param string $field_name The field name.
2368
+	 * @param string $post_type Optional. The wordpress post type.
2369
+	 * @return bool Returns true when field visible, otherwise false.
2370
+	 */
2371
+	function check_field_visibility($package_id, $field_name, $post_type)
2372
+	{
2373
+		global $wpdb, $geodir_addon_list;
2374
+		if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) {
2375
+			return true;
2376
+		}
2377
+		if (!$package_id || !$field_name || !$post_type) {
2378
+			return true;
2379
+		}
2380
+		$sql = $wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int)$package_id));
2381
+
2382
+		if ($wpdb->get_var($sql)) {
2383
+			return true;
2384
+		}
2385
+		return false;
2386
+	}
2387 2387
 }
2388 2388
 
2389 2389
 /**
@@ -2398,43 +2398,43 @@  discard block
 block discarded – undo
2398 2398
  */
2399 2399
 function geodir_string_to_options($input = '', $translated = false)
2400 2400
 {
2401
-    $return = array();
2402
-    if ($input != '') {
2403
-        $input = trim($input);
2404
-        $input = rtrim($input, ",");
2405
-        $input = ltrim($input, ",");
2406
-        $input = trim($input);
2407
-    }
2408
-
2409
-    $input_arr = explode(',', $input);
2410
-
2411
-    if (!empty($input_arr)) {
2412
-        foreach ($input_arr as $input_str) {
2413
-            $input_str = trim($input_str);
2414
-
2415
-            if (strpos($input_str, "/") !== false) {
2416
-                $input_str = explode("/", $input_str, 2);
2417
-                $label = trim($input_str[0]);
2418
-                if ($translated && $label != '') {
2419
-                    $label = __($label, 'geodirectory');
2420
-                }
2421
-                $label = ucfirst($label);
2422
-                $value = trim($input_str[1]);
2423
-            } else {
2424
-                if ($translated && $input_str != '') {
2425
-                    $input_str = __($input_str, 'geodirectory');
2426
-                }
2427
-                $label = ucfirst($input_str);
2428
-                $value = $input_str;
2429
-            }
2430
-
2431
-            if ($label != '') {
2432
-                $return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL);
2433
-            }
2434
-        }
2435
-    }
2436
-
2437
-    return $return;
2401
+	$return = array();
2402
+	if ($input != '') {
2403
+		$input = trim($input);
2404
+		$input = rtrim($input, ",");
2405
+		$input = ltrim($input, ",");
2406
+		$input = trim($input);
2407
+	}
2408
+
2409
+	$input_arr = explode(',', $input);
2410
+
2411
+	if (!empty($input_arr)) {
2412
+		foreach ($input_arr as $input_str) {
2413
+			$input_str = trim($input_str);
2414
+
2415
+			if (strpos($input_str, "/") !== false) {
2416
+				$input_str = explode("/", $input_str, 2);
2417
+				$label = trim($input_str[0]);
2418
+				if ($translated && $label != '') {
2419
+					$label = __($label, 'geodirectory');
2420
+				}
2421
+				$label = ucfirst($label);
2422
+				$value = trim($input_str[1]);
2423
+			} else {
2424
+				if ($translated && $input_str != '') {
2425
+					$input_str = __($input_str, 'geodirectory');
2426
+				}
2427
+				$label = ucfirst($input_str);
2428
+				$value = $input_str;
2429
+			}
2430
+
2431
+			if ($label != '') {
2432
+				$return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL);
2433
+			}
2434
+		}
2435
+	}
2436
+
2437
+	return $return;
2438 2438
 }
2439 2439
 
2440 2440
 /**
@@ -2449,59 +2449,59 @@  discard block
 block discarded – undo
2449 2449
  */
2450 2450
 function geodir_string_values_to_options($option_values = '', $translated = false)
2451 2451
 {
2452
-    $options = array();
2453
-    if ($option_values == '') {
2454
-        return NULL;
2455
-    }
2456
-
2457
-    if (strpos($option_values, "{/optgroup}") !== false) {
2458
-        $option_values_arr = explode("{/optgroup}", $option_values);
2459
-
2460
-        foreach ($option_values_arr as $optgroup) {
2461
-            if (strpos($optgroup, "{optgroup}") !== false) {
2462
-                $optgroup_arr = explode("{optgroup}", $optgroup);
2463
-
2464
-                $count = 0;
2465
-                foreach ($optgroup_arr as $optgroup_str) {
2466
-                    $count++;
2467
-                    $optgroup_str = trim($optgroup_str);
2468
-
2469
-                    $optgroup_label = '';
2470
-                    if (strpos($optgroup_str, "|") !== false) {
2471
-                        $optgroup_str_arr = explode("|", $optgroup_str, 2);
2472
-                        $optgroup_label = trim($optgroup_str_arr[0]);
2473
-                        if ($translated && $optgroup_label != '') {
2474
-                            $optgroup_label = __($optgroup_label, 'geodirectory');
2475
-                        }
2476
-                        $optgroup_label = ucfirst($optgroup_label);
2477
-                        $optgroup_str = $optgroup_str_arr[1];
2478
-                    }
2479
-
2480
-                    $optgroup3 = geodir_string_to_options($optgroup_str, $translated);
2481
-
2482
-                    if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) {
2483
-                        $optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start'));
2484
-                        $optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end'));
2485
-                        $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end);
2486
-                    }
2487
-                    $options = array_merge($options, $optgroup3);
2488
-                }
2489
-            } else {
2490
-                $optgroup1 = geodir_string_to_options($optgroup, $translated);
2491
-                $options = array_merge($options, $optgroup1);
2492
-            }
2493
-        }
2494
-    } else {
2495
-        $options = geodir_string_to_options($option_values, $translated);
2496
-    }
2497
-
2498
-    return $options;
2452
+	$options = array();
2453
+	if ($option_values == '') {
2454
+		return NULL;
2455
+	}
2456
+
2457
+	if (strpos($option_values, "{/optgroup}") !== false) {
2458
+		$option_values_arr = explode("{/optgroup}", $option_values);
2459
+
2460
+		foreach ($option_values_arr as $optgroup) {
2461
+			if (strpos($optgroup, "{optgroup}") !== false) {
2462
+				$optgroup_arr = explode("{optgroup}", $optgroup);
2463
+
2464
+				$count = 0;
2465
+				foreach ($optgroup_arr as $optgroup_str) {
2466
+					$count++;
2467
+					$optgroup_str = trim($optgroup_str);
2468
+
2469
+					$optgroup_label = '';
2470
+					if (strpos($optgroup_str, "|") !== false) {
2471
+						$optgroup_str_arr = explode("|", $optgroup_str, 2);
2472
+						$optgroup_label = trim($optgroup_str_arr[0]);
2473
+						if ($translated && $optgroup_label != '') {
2474
+							$optgroup_label = __($optgroup_label, 'geodirectory');
2475
+						}
2476
+						$optgroup_label = ucfirst($optgroup_label);
2477
+						$optgroup_str = $optgroup_str_arr[1];
2478
+					}
2479
+
2480
+					$optgroup3 = geodir_string_to_options($optgroup_str, $translated);
2481
+
2482
+					if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) {
2483
+						$optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start'));
2484
+						$optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end'));
2485
+						$optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end);
2486
+					}
2487
+					$options = array_merge($options, $optgroup3);
2488
+				}
2489
+			} else {
2490
+				$optgroup1 = geodir_string_to_options($optgroup, $translated);
2491
+				$options = array_merge($options, $optgroup1);
2492
+			}
2493
+		}
2494
+	} else {
2495
+		$options = geodir_string_to_options($option_values, $translated);
2496
+	}
2497
+
2498
+	return $options;
2499 2499
 }
2500 2500
 
2501 2501
 
2502 2502
 function geodir_cfa_data_type_text($output,$result_str,$cf,$field_info){
2503
-    ob_start();
2504
-    ?>
2503
+	ob_start();
2504
+	?>
2505 2505
     <li>
2506 2506
         <label for="data_type""><?php _e('Field Data Type ? :', 'geodirectory'); ?></label>
2507 2507
         <div class="gd-cf-input-wrap">
@@ -2510,16 +2510,16 @@  discard block
 block discarded – undo
2510 2510
                     onchange="javascript:gd_data_type_changed(this, '<?php echo $result_str; ?>');">
2511 2511
                 <option
2512 2512
                     value="XVARCHAR" <?php if (isset($field_info->data_type) && $field_info->data_type == 'VARCHAR') {
2513
-                    echo 'selected="selected"';
2514
-                } ?>><?php _e('CHARACTER', 'geodirectory'); ?></option>
2513
+					echo 'selected="selected"';
2514
+				} ?>><?php _e('CHARACTER', 'geodirectory'); ?></option>
2515 2515
                 <option
2516 2516
                     value="INT" <?php if (isset($field_info->data_type) && $field_info->data_type == 'INT') {
2517
-                    echo 'selected="selected"';
2518
-                } ?>><?php _e('NUMBER', 'geodirectory'); ?></option>
2517
+					echo 'selected="selected"';
2518
+				} ?>><?php _e('NUMBER', 'geodirectory'); ?></option>
2519 2519
                 <option
2520 2520
                     value="FLOAT" <?php if (isset($field_info->data_type) && $field_info->data_type == 'FLOAT') {
2521
-                    echo 'selected="selected"';
2522
-                } ?>><?php _e('DECIMAL', 'geodirectory'); ?></option>
2521
+					echo 'selected="selected"';
2522
+				} ?>><?php _e('DECIMAL', 'geodirectory'); ?></option>
2523 2523
             </select>
2524 2524
             <br/> <span><?php _e('Select Custom Field type', 'geodirectory'); ?></span>
2525 2525
 
@@ -2532,8 +2532,8 @@  discard block
 block discarded – undo
2532 2532
             <select name="decimal_point" id="decimal_point">
2533 2533
                 <option value=""><?php echo _e('Select', 'geodirectory'); ?></option>
2534 2534
                 <?php for ($i = 1; $i <= 10; $i++) {
2535
-                    $decimal_point = isset($field_info->decimal_point) ? $field_info->decimal_point : '';
2536
-                    $selected = $i == $decimal_point ? 'selected="selected"' : ''; ?>
2535
+					$decimal_point = isset($field_info->decimal_point) ? $field_info->decimal_point : '';
2536
+					$selected = $i == $decimal_point ? 'selected="selected"' : ''; ?>
2537 2537
                     <option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?></option>
2538 2538
                 <?php } ?>
2539 2539
             </select>
@@ -2542,8 +2542,8 @@  discard block
 block discarded – undo
2542 2542
     </li>
2543 2543
 <?php
2544 2544
 
2545
-    $output = ob_get_clean();
2546
-    return $output;
2545
+	$output = ob_get_clean();
2546
+	return $output;
2547 2547
 }
2548 2548
 add_filter('geodir_cfa_data_type_text','geodir_cfa_data_type_text',10,4);
2549 2549
 
@@ -2581,9 +2581,9 @@  discard block
 block discarded – undo
2581 2581
 
2582 2582
 
2583 2583
 function geodir_cfa_advanced_editor_geodir_special_offers($output,$result_str,$cf,$field_info){
2584
-    if($field_info->htmlvar_name != 'geodir_special_offers'){return '';}
2585
-    ob_start();
2586
-    ?>
2584
+	if($field_info->htmlvar_name != 'geodir_special_offers'){return '';}
2585
+	ob_start();
2586
+	?>
2587 2587
     <li>
2588 2588
         <label for="advanced_editor" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Show advanced editor :', 'geodirectory'); ?>
2589 2589
             <div class="gdcf-tooltip">
@@ -2594,13 +2594,13 @@  discard block
 block discarded – undo
2594 2594
         <div class="gd-cf-input-wrap">
2595 2595
 
2596 2596
             <?php
2597
-            $selected = '';
2598
-            if (isset($field_info->extra_fields))
2599
-                $advanced_editor = unserialize($field_info->extra_fields);
2597
+			$selected = '';
2598
+			if (isset($field_info->extra_fields))
2599
+				$advanced_editor = unserialize($field_info->extra_fields);
2600 2600
 
2601
-            if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor))
2602
-                $selected = 'checked="checked"';
2603
-            ?>
2601
+			if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor))
2602
+				$selected = 'checked="checked"';
2603
+			?>
2604 2604
 
2605 2605
             <input type="checkbox" name="advanced_editor[]" id="advanced_editor"
2606 2606
                    value="1" <?php echo $selected; ?>/>
@@ -2609,22 +2609,22 @@  discard block
 block discarded – undo
2609 2609
     </li>
2610 2610
     <?php
2611 2611
 
2612
-    $output = ob_get_clean();
2613
-    return $output;
2612
+	$output = ob_get_clean();
2613
+	return $output;
2614 2614
 }
2615 2615
 add_filter('geodir_cfa_advanced_editor_textarea','geodir_cfa_advanced_editor_geodir_special_offers',10,4);
2616 2616
 
2617 2617
 
2618 2618
 function geodir_cfa_validation_pattern_text($output,$result_str,$cf,$field_info){
2619
-    ob_start();
2620
-
2621
-    $value = '';
2622
-    if (isset($field_info->validation_pattern)) {
2623
-        $value = esc_attr($field_info->validation_pattern);
2624
-    }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
2625
-        $value = esc_attr($cf['defaults']['validation_pattern']);
2626
-    }
2627
-    ?>
2619
+	ob_start();
2620
+
2621
+	$value = '';
2622
+	if (isset($field_info->validation_pattern)) {
2623
+		$value = esc_attr($field_info->validation_pattern);
2624
+	}elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
2625
+		$value = esc_attr($cf['defaults']['validation_pattern']);
2626
+	}
2627
+	?>
2628 2628
     <li>
2629 2629
         <label for="validation_pattern" class="gd-cf-tooltip-wrap">
2630 2630
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Pattern:', 'geodirectory'); ?>
@@ -2638,13 +2638,13 @@  discard block
 block discarded – undo
2638 2638
         </div>
2639 2639
     </li>
2640 2640
     <?php
2641
-    $value = '';
2642
-    if (isset($field_info->validation_msg)) {
2643
-        $value = esc_attr($field_info->validation_msg);
2644
-    }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
2645
-        $value = esc_attr($cf['defaults']['validation_msg']);
2646
-    }
2647
-    ?>
2641
+	$value = '';
2642
+	if (isset($field_info->validation_msg)) {
2643
+		$value = esc_attr($field_info->validation_msg);
2644
+	}elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
2645
+		$value = esc_attr($cf['defaults']['validation_msg']);
2646
+	}
2647
+	?>
2648 2648
     <li>
2649 2649
         <label for="validation_msg" class="gd-cf-tooltip-wrap">
2650 2650
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Message:', 'geodirectory'); ?>
@@ -2659,21 +2659,21 @@  discard block
 block discarded – undo
2659 2659
     </li>
2660 2660
     <?php
2661 2661
 
2662
-    $output = ob_get_clean();
2663
-    return $output;
2662
+	$output = ob_get_clean();
2663
+	return $output;
2664 2664
 }
2665 2665
 add_filter('geodir_cfa_validation_pattern_text','geodir_cfa_validation_pattern_text',10,4);
2666 2666
 
2667 2667
 
2668 2668
 function geodir_cfa_htmlvar_name_taxonomy($output,$result_str,$cf,$field_info){
2669
-    ob_start();
2670
-    global $post_type;
2671
-
2672
-    if (!isset($field_info->post_type)) {
2673
-        $post_type = sanitize_text_field($_REQUEST['listing_type']);
2674
-    } else
2675
-        $post_type = $field_info->post_type;
2676
-    ?>
2669
+	ob_start();
2670
+	global $post_type;
2671
+
2672
+	if (!isset($field_info->post_type)) {
2673
+		$post_type = sanitize_text_field($_REQUEST['listing_type']);
2674
+	} else
2675
+		$post_type = $field_info->post_type;
2676
+	?>
2677 2677
     <li style="display: none;">
2678 2678
         <label for="htmlvar_name" class="gd-cf-tooltip-wrap">
2679 2679
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Select taxonomy:', 'geodirectory'); ?>
@@ -2684,15 +2684,15 @@  discard block
 block discarded – undo
2684 2684
         <div class="gd-cf-input-wrap">
2685 2685
             <select name="htmlvar_name" id="htmlvar_name">
2686 2686
                 <?php
2687
-                $gd_taxonomy = geodir_get_taxonomies($post_type);
2687
+				$gd_taxonomy = geodir_get_taxonomies($post_type);
2688 2688
 
2689
-                foreach ($gd_taxonomy as $gd_tax) {
2690
-                    ?>
2689
+				foreach ($gd_taxonomy as $gd_tax) {
2690
+					?>
2691 2691
                     <option <?php if (isset($field_info->htmlvar_name) && $field_info->htmlvar_name == $gd_tax) {
2692
-                        echo 'selected="selected"';
2693
-                    }?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php
2694
-                }
2695
-                ?>
2692
+						echo 'selected="selected"';
2693
+					}?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php
2694
+				}
2695
+				?>
2696 2696
             </select>
2697 2697
         </div>
2698 2698
     </li>
@@ -2708,47 +2708,47 @@  discard block
 block discarded – undo
2708 2708
 
2709 2709
             <select name="cat_display_type" id="cat_display_type">
2710 2710
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'ajax_chained') {
2711
-                    echo 'selected="selected"';
2712
-                }?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option>
2711
+					echo 'selected="selected"';
2712
+				}?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option>
2713 2713
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') {
2714
-                    echo 'selected="selected"';
2715
-                }?> value="select"><?php _e('Select', 'geodirectory');?></option>
2714
+					echo 'selected="selected"';
2715
+				}?> value="select"><?php _e('Select', 'geodirectory');?></option>
2716 2716
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'multiselect') {
2717
-                    echo 'selected="selected"';
2718
-                }?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option>
2717
+					echo 'selected="selected"';
2718
+				}?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option>
2719 2719
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') {
2720
-                    echo 'selected="selected"';
2721
-                }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
2720
+					echo 'selected="selected"';
2721
+				}?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
2722 2722
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') {
2723
-                    echo 'selected="selected"';
2724
-                }?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
2723
+					echo 'selected="selected"';
2724
+				}?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
2725 2725
             </select>
2726 2726
         </div>
2727 2727
     </li>
2728 2728
     <?php
2729 2729
 
2730
-    $output = ob_get_clean();
2731
-    return $output;
2730
+	$output = ob_get_clean();
2731
+	return $output;
2732 2732
 }
2733 2733
 add_filter('geodir_cfa_htmlvar_name_taxonomy','geodir_cfa_htmlvar_name_taxonomy',10,4);
2734 2734
 
2735 2735
 
2736 2736
 function geodir_cfa_extra_fields_address($output,$result_str,$cf,$field_info){
2737 2737
 
2738
-    ob_start();
2739
-    if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
2740
-        $address = unserialize($field_info->extra_fields);
2741
-    }
2742
-    ?>
2738
+	ob_start();
2739
+	if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
2740
+		$address = unserialize($field_info->extra_fields);
2741
+	}
2742
+	?>
2743 2743
     <?php
2744
-    /**
2745
-     * Called on the add custom fields settings page before the address field is output.
2746
-     *
2747
-     * @since 1.0.0
2748
-     * @param array $address The address settings array.
2749
-     * @param object $field_info Extra fields info.
2750
-     */
2751
-    do_action('geodir_address_extra_admin_fields', $address, $field_info); ?>
2744
+	/**
2745
+	 * Called on the add custom fields settings page before the address field is output.
2746
+	 *
2747
+	 * @since 1.0.0
2748
+	 * @param array $address The address settings array.
2749
+	 * @param object $field_info Extra fields info.
2750
+	 */
2751
+	do_action('geodir_address_extra_admin_fields', $address, $field_info); ?>
2752 2752
 
2753 2753
     <li>
2754 2754
         <label for="show_zip" class="gd-cf-tooltip-wrap">
@@ -2761,14 +2761,14 @@  discard block
 block discarded – undo
2761 2761
 
2762 2762
             <input type="radio" id="show_zip_yes<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-enabled"  value="1"
2763 2763
                 <?php if (isset($address['show_zip']) && $address['show_zip'] == '1') {
2764
-                    echo 'checked';
2765
-                } ?>/>
2764
+					echo 'checked';
2765
+				} ?>/>
2766 2766
             <label onclick="show_hide_radio(this,'show','cf-zip-lable');" for="show_zip_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2767 2767
 
2768 2768
             <input type="radio" id="show_zip_no<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-disabled" value="0"
2769 2769
                 <?php if ((isset($address['show_zip']) && !$address['show_zip']) || !isset($address['show_zip'])) {
2770
-                    echo 'checked';
2771
-                } ?>/>
2770
+					echo 'checked';
2771
+				} ?>/>
2772 2772
             <label onclick="show_hide_radio(this,'hide','cf-zip-lable');" for="show_zip_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2773 2773
 
2774 2774
 
@@ -2785,8 +2785,8 @@  discard block
 block discarded – undo
2785 2785
         <div class="gd-cf-input-wrap">
2786 2786
             <input type="text" name="extra[zip_lable]" id="zip_lable"
2787 2787
                    value="<?php if (isset($address['zip_lable'])) {
2788
-                       echo esc_attr($address['zip_lable']);
2789
-                   }?>"/>
2788
+					   echo esc_attr($address['zip_lable']);
2789
+				   }?>"/>
2790 2790
         </div>
2791 2791
     </li>
2792 2792
 
@@ -2803,8 +2803,8 @@  discard block
 block discarded – undo
2803 2803
         <div class="gd-cf-input-wrap">
2804 2804
             <input type="text" name="extra[map_lable]" id="map_lable"
2805 2805
                    value="<?php if (isset($address['map_lable'])) {
2806
-                       echo esc_attr($address['map_lable']);
2807
-                   }?>"/>
2806
+					   echo esc_attr($address['map_lable']);
2807
+				   }?>"/>
2808 2808
         </div>
2809 2809
     </li>
2810 2810
 
@@ -2819,14 +2819,14 @@  discard block
 block discarded – undo
2819 2819
 
2820 2820
             <input type="radio" id="show_mapzoom_yes<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-enabled"  value="1"
2821 2821
                 <?php if (isset($address['show_mapzoom']) && $address['show_mapzoom'] == '1') {
2822
-                    echo 'checked';
2823
-                } ?>/>
2822
+					echo 'checked';
2823
+				} ?>/>
2824 2824
             <label for="show_mapzoom_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2825 2825
 
2826 2826
             <input type="radio" id="show_mapzoom_no<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-disabled" value="0"
2827 2827
                 <?php if ((isset($address['show_mapzoom']) && !$address['show_mapzoom']) || !isset($address['show_mapzoom'])) {
2828
-                    echo 'checked';
2829
-                } ?>/>
2828
+					echo 'checked';
2829
+				} ?>/>
2830 2830
             <label for="show_mapzoom_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2831 2831
 
2832 2832
         </div>
@@ -2843,14 +2843,14 @@  discard block
 block discarded – undo
2843 2843
 
2844 2844
             <input type="radio" id="show_mapview_yes<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-enabled"  value="1"
2845 2845
                 <?php if (isset($address['show_mapview']) && $address['show_mapview'] == '1') {
2846
-                    echo 'checked';
2847
-                } ?>/>
2846
+					echo 'checked';
2847
+				} ?>/>
2848 2848
             <label for="show_mapview_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2849 2849
 
2850 2850
             <input type="radio" id="show_mapview_no<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-disabled" value="0"
2851 2851
                 <?php if ((isset($address['show_mapview']) && !$address['show_mapview']) || !isset($address['show_mapview'])) {
2852
-                    echo 'checked';
2853
-                } ?>/>
2852
+					echo 'checked';
2853
+				} ?>/>
2854 2854
             <label for="show_mapview_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2855 2855
 
2856 2856
         </div>
@@ -2867,8 +2867,8 @@  discard block
 block discarded – undo
2867 2867
         <div class="gd-cf-input-wrap">
2868 2868
             <input type="text" name="extra[mapview_lable]" id="mapview_lable"
2869 2869
                    value="<?php if (isset($address['mapview_lable'])) {
2870
-                       echo esc_attr($address['mapview_lable']);
2871
-                   }?>"/>
2870
+					   echo esc_attr($address['mapview_lable']);
2871
+				   }?>"/>
2872 2872
         </div>
2873 2873
     </li>
2874 2874
     <li>
@@ -2882,29 +2882,29 @@  discard block
 block discarded – undo
2882 2882
 
2883 2883
             <input type="radio" id="show_latlng_yes<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-enabled"  value="1"
2884 2884
                 <?php if (isset($address['show_latlng']) && $address['show_latlng'] == '1') {
2885
-                    echo 'checked';
2886
-                } ?>/>
2885
+					echo 'checked';
2886
+				} ?>/>
2887 2887
             <label for="show_latlng_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2888 2888
 
2889 2889
             <input type="radio" id="show_latlng_no<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-disabled" value="0"
2890 2890
                 <?php if ((isset($address['show_latlng']) && !$address['show_latlng']) || !isset($address['show_latlng'])) {
2891
-                    echo 'checked';
2892
-                } ?>/>
2891
+					echo 'checked';
2892
+				} ?>/>
2893 2893
             <label for="show_latlng_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2894 2894
 
2895 2895
         </div>
2896 2896
     </li>
2897 2897
     <?php
2898 2898
 
2899
-    $output = ob_get_clean();
2900
-    return $output;
2899
+	$output = ob_get_clean();
2900
+	return $output;
2901 2901
 }
2902 2902
 add_filter('geodir_cfa_extra_fields_address','geodir_cfa_extra_fields_address',10,4);
2903 2903
 
2904 2904
 
2905 2905
 function geodir_cfa_extra_fields_multiselect($output,$result_str,$cf,$field_info){
2906
-    ob_start();
2907
-    ?>
2906
+	ob_start();
2907
+	?>
2908 2908
     <li>
2909 2909
         <label for="multi_display_type" class="gd-cf-tooltip-wrap">
2910 2910
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Multiselect display type :', 'geodirectory'); ?>
@@ -2916,14 +2916,14 @@  discard block
 block discarded – undo
2916 2916
 
2917 2917
             <select name="multi_display_type" id="multi_display_type">
2918 2918
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') {
2919
-                    echo 'selected="selected"';
2920
-                }?> value="select"><?php _e('Select', 'geodirectory');?></option>
2919
+					echo 'selected="selected"';
2920
+				}?> value="select"><?php _e('Select', 'geodirectory');?></option>
2921 2921
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') {
2922
-                    echo 'selected="selected"';
2923
-                }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
2922
+					echo 'selected="selected"';
2923
+				}?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
2924 2924
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') {
2925
-                    echo 'selected="selected"';
2926
-                }?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
2925
+					echo 'selected="selected"';
2926
+				}?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
2927 2927
             </select>
2928 2928
 
2929 2929
             <br/>
@@ -2931,15 +2931,15 @@  discard block
 block discarded – undo
2931 2931
     </li>
2932 2932
     <?php
2933 2933
 
2934
-    $output = ob_get_clean();
2935
-    return $output;
2934
+	$output = ob_get_clean();
2935
+	return $output;
2936 2936
 }
2937 2937
 add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_multiselect',10,4);
2938 2938
 
2939 2939
 
2940 2940
 function geodir_cfa_extra_fields_smr($output,$result_str,$cf,$field_info){
2941
-    ob_start();
2942
-    ?>
2941
+	ob_start();
2942
+	?>
2943 2943
     <li>
2944 2944
         <label for="option_values" class="gd-cf-tooltip-wrap">
2945 2945
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Option Values :', 'geodirectory'); ?>
@@ -2960,16 +2960,16 @@  discard block
 block discarded – undo
2960 2960
         <div class="gd-cf-input-wrap">
2961 2961
             <input type="text" name="option_values" id="option_values"
2962 2962
                    value="<?php if (isset($field_info->option_values)) {
2963
-                       echo esc_attr($field_info->option_values);
2964
-                   }?>"/>
2963
+					   echo esc_attr($field_info->option_values);
2964
+				   }?>"/>
2965 2965
             <br/>
2966 2966
 
2967 2967
         </div>
2968 2968
     </li>
2969 2969
     <?php
2970 2970
 
2971
-    $output = ob_get_clean();
2972
-    return $output;
2971
+	$output = ob_get_clean();
2972
+	return $output;
2973 2973
 }
2974 2974
 add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_smr',10,4);
2975 2975
 add_filter('geodir_cfa_extra_fields_select','geodir_cfa_extra_fields_smr',10,4);
@@ -2977,11 +2977,11 @@  discard block
 block discarded – undo
2977 2977
 
2978 2978
 
2979 2979
 function geodir_cfa_extra_fields_datepicker($output,$result_str,$cf,$field_info){
2980
-    ob_start();
2981
-    if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
2982
-        $extra = unserialize($field_info->extra_fields);
2983
-    }
2984
-    ?>
2980
+	ob_start();
2981
+	if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
2982
+		$extra = unserialize($field_info->extra_fields);
2983
+	}
2984
+	?>
2985 2985
     <li>
2986 2986
         <label for="date_format" class="gd-cf-tooltip-wrap">
2987 2987
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Date Format :', 'geodirectory'); ?>
@@ -2991,52 +2991,52 @@  discard block
 block discarded – undo
2991 2991
         </label>
2992 2992
         <div class="gd-cf-input-wrap" style="overflow:inherit;">
2993 2993
             <?php
2994
-            $date_formats = array(
2995
-                'm/d/Y',
2996
-                'd/m/Y',
2997
-                'Y/m/d',
2998
-                'm-d-Y',
2999
-                'd-m-Y',
3000
-                'Y-m-d',
3001
-                'F j, Y',
3002
-            );
3003
-            /**
3004
-             * Filter the custom field date format options.
3005
-             *
3006
-             * @since 1.6.5
3007
-             * @param array $date_formats The PHP date format array.
3008
-             */
3009
-            $date_formats = apply_filters('geodir_date_formats',$date_formats);
3010
-            ?>
2994
+			$date_formats = array(
2995
+				'm/d/Y',
2996
+				'd/m/Y',
2997
+				'Y/m/d',
2998
+				'm-d-Y',
2999
+				'd-m-Y',
3000
+				'Y-m-d',
3001
+				'F j, Y',
3002
+			);
3003
+			/**
3004
+			 * Filter the custom field date format options.
3005
+			 *
3006
+			 * @since 1.6.5
3007
+			 * @param array $date_formats The PHP date format array.
3008
+			 */
3009
+			$date_formats = apply_filters('geodir_date_formats',$date_formats);
3010
+			?>
3011 3011
             <select name="extra[date_format]" id="date_format">
3012 3012
                 <?php
3013
-                foreach($date_formats as $format){
3014
-                    $selected = '';
3015
-                    if(esc_attr($extra['date_format'])==$format){
3016
-                        $selected = "selected='selected'";
3017
-                    }
3018
-                    echo "<option $selected value='$format'>$format       (".date_i18n( $format, time()).")</option>";
3019
-                }
3020
-                ?>
3013
+				foreach($date_formats as $format){
3014
+					$selected = '';
3015
+					if(esc_attr($extra['date_format'])==$format){
3016
+						$selected = "selected='selected'";
3017
+					}
3018
+					echo "<option $selected value='$format'>$format       (".date_i18n( $format, time()).")</option>";
3019
+				}
3020
+				?>
3021 3021
             </select>
3022 3022
 
3023 3023
         </div>
3024 3024
     </li>
3025 3025
     <?php
3026 3026
 
3027
-    $output = ob_get_clean();
3028
-    return $output;
3027
+	$output = ob_get_clean();
3028
+	return $output;
3029 3029
 }
3030 3030
 add_filter('geodir_cfa_extra_fields_datepicker','geodir_cfa_extra_fields_datepicker',10,4);
3031 3031
 
3032 3032
 
3033 3033
 function geodir_cfa_extra_fields_file($output,$result_str,$cf,$field_info){
3034
-    ob_start();
3035
-    $allowed_file_types = geodir_allowed_mime_types();
3034
+	ob_start();
3035
+	$allowed_file_types = geodir_allowed_mime_types();
3036 3036
 
3037
-    $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : '';
3038
-    $gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*');
3039
-    ?>
3037
+	$extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : '';
3038
+	$gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*');
3039
+	?>
3040 3040
     <li>
3041 3041
         <label for="gd_file_types" class="gd-cf-tooltip-wrap">
3042 3042
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Allowed file types :', 'geodirectory'); ?>
@@ -3059,7 +3059,7 @@  discard block
 block discarded – undo
3059 3059
     </li>
3060 3060
     <?php
3061 3061
 
3062
-    $output = ob_get_clean();
3063
-    return $output;
3062
+	$output = ob_get_clean();
3063
+	return $output;
3064 3064
 }
3065 3065
 add_filter('geodir_cfa_extra_fields_file','geodir_cfa_extra_fields_file',10,4);
3066 3066
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/custom_field_html.php 1 patch
Indentation   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
 global $post_type;
19 19
 
20 20
 if (!isset($field_info->post_type)) {
21
-    $post_type = sanitize_text_field($_REQUEST['listing_type']);
21
+	$post_type = sanitize_text_field($_REQUEST['listing_type']);
22 22
 } else
23
-    $post_type = $field_info->post_type;
23
+	$post_type = $field_info->post_type;
24 24
 
25 25
 $cf_arr = geodir_custom_fields($post_type);
26 26
 $cf = (isset($cf_arr[$field_type_key])) ? $cf_arr[$field_type_key] : '';
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 $field_admin_title = '';
33 33
 if (isset($field_info->admin_title))
34
-    $field_admin_title = $field_info->admin_title;
34
+	$field_admin_title = $field_info->admin_title;
35 35
 
36 36
 $default = isset($field_info->is_admin) ? $field_info->is_admin : '';
37 37
 
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 //print_r($field_info);
52 52
 
53 53
 if (isset($cf['icon']) && strpos($cf['icon'], 'fa fa-') !== false) {
54
-    $field_icon = '<i class="'.$cf['icon'].'" aria-hidden="true"></i>';
54
+	$field_icon = '<i class="'.$cf['icon'].'" aria-hidden="true"></i>';
55 55
 }elseif(isset($cf['icon']) && $cf['icon']){
56
-    $field_icon = '<b style="background-image: url("'.$cf['icon'].'")"></b>';
56
+	$field_icon = '<b style="background-image: url("'.$cf['icon'].'")"></b>';
57 57
 }else{
58
-    $field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>';
58
+	$field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>';
59 59
 }
60 60
 
61 61
 ?>
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
          ondblclick="show_hide('field_frm<?php echo $result_str; ?>')">
66 66
         <?php
67 67
 
68
-        $nonce = wp_create_nonce('custom_fields_' . $result_str);
69
-        ?>
68
+		$nonce = wp_create_nonce('custom_fields_' . $result_str);
69
+		?>
70 70
 
71 71
         <?php if ($default): ?>
72 72
             <div title="<?php _e('Default field, should not be removed.', 'geodirectory'); ?>" class="handlediv move gd-default-remove"><i class="fa fa-times" aria-hidden="true"></i></div>
@@ -75,37 +75,37 @@  discard block
 block discarded – undo
75 75
                  onclick="delete_field('<?php echo $result_str; ?>', '<?php echo $nonce; ?>')"
76 76
                  class="handlediv close"><i class="fa fa-times" aria-hidden="true"></i></div>
77 77
         <?php endif;
78
-        if ($field_type == 'fieldset') {
79
-            ?>
78
+		if ($field_type == 'fieldset') {
79
+			?>
80 80
             <i class="fa fa-long-arrow-left " aria-hidden="true"></i>
81 81
             <i class="fa fa-long-arrow-right " aria-hidden="true"></i>
82 82
             <b style="cursor:pointer;"
83 83
                onclick="show_hide('field_frm<?php echo $result_str;?>')"><?php echo geodir_ucwords(__('Fieldset:', 'geodirectory') . ' ' . $field_admin_title);?></b>
84 84
         <?php
85
-        } else {echo $field_icon;
86
-            ?>
85
+		} else {echo $field_icon;
86
+			?>
87 87
             <b style="cursor:pointer;"
88 88
                onclick="show_hide('field_frm<?php echo $result_str;?>')"><?php echo geodir_ucwords(' ' . $field_admin_title . ' (' . $field_type . ')');?></b>
89 89
         <?php
90
-        }
91
-        ?>
90
+		}
91
+		?>
92 92
     </div>
93 93
 
94 94
     <form><!-- we need to wrap in a fom so we can use radio buttons with same name -->
95 95
     <div id="field_frm<?php echo $result_str; ?>" class="field_frm"
96 96
          style="display:<?php if ($field_ins_upd == 'submit') {
97
-             echo 'block;';
98
-         } else {
99
-             echo 'none;';
100
-         } ?>">
97
+			 echo 'block;';
98
+		 } else {
99
+			 echo 'none;';
100
+		 } ?>">
101 101
         <input type="hidden" name="_wpnonce" value="<?php echo esc_attr($nonce); ?>"/>
102 102
         <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type; ?>"/>
103 103
         <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type; ?>"/>
104 104
         <input type="hidden" name="field_type_key" id="field_type_key" value="<?php echo $field_type_key; ?>"/>
105 105
         <input type="hidden" name="field_id" id="field_id" value="<?php echo esc_attr($result_str); ?>"/>
106 106
         <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) {
107
-            echo $field_info->data_type;
108
-        } ?>"/>
107
+			echo $field_info->data_type;
108
+		} ?>"/>
109 109
         <input type="hidden" name="is_active" id="is_active" value="1"/>
110 110
 
111 111
         <input type="hidden" name="is_default" value="<?php echo $field_info->is_default;?>" /><?php // show in sidebar value?>
@@ -117,37 +117,37 @@  discard block
 block discarded – undo
117 117
 
118 118
             <?php
119 119
 
120
-            // data_type
121
-            if(has_filter("geodir_cfa_data_type_{$field_type}")){
120
+			// data_type
121
+			if(has_filter("geodir_cfa_data_type_{$field_type}")){
122 122
 
123
-                echo apply_filters("geodir_cfa_data_type_{$field_type}",'',$result_str,$cf,$field_info);
123
+				echo apply_filters("geodir_cfa_data_type_{$field_type}",'',$result_str,$cf,$field_info);
124 124
 
125
-            }else{
126
-                $value = '';
127
-                if (isset($field_info->data_type)) {
128
-                    $value = esc_attr($field_info->data_type);
129
-                }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
130
-                    $value = $cf['defaults']['data_type'];
131
-                }
132
-                ?>
125
+			}else{
126
+				$value = '';
127
+				if (isset($field_info->data_type)) {
128
+					$value = esc_attr($field_info->data_type);
129
+				}elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
130
+					$value = $cf['defaults']['data_type'];
131
+				}
132
+				?>
133 133
                 <input type="hidden" name="data_type" id="data_type" value="<?php echo $value;?>"/>
134 134
             <?php
135
-            }
135
+			}
136 136
 
137 137
 
138
-            // admin_title
139
-            if(has_filter("geodir_cfa_admin_title_{$field_type}")){
138
+			// admin_title
139
+			if(has_filter("geodir_cfa_admin_title_{$field_type}")){
140 140
 
141
-                echo apply_filters("geodir_cfa_admin_title_{$field_type}",'',$result_str,$cf,$field_info);
141
+				echo apply_filters("geodir_cfa_admin_title_{$field_type}",'',$result_str,$cf,$field_info);
142 142
 
143
-            }else{
144
-                $value = '';
145
-                if (isset($field_info->admin_title)) {
146
-                    $value = esc_attr($field_info->admin_title);
147
-                }elseif(isset($cf['defaults']['admin_title']) && $cf['defaults']['admin_title']){
148
-                    $value = $cf['defaults']['admin_title'];
149
-                }
150
-                ?>
143
+			}else{
144
+				$value = '';
145
+				if (isset($field_info->admin_title)) {
146
+					$value = esc_attr($field_info->admin_title);
147
+				}elseif(isset($cf['defaults']['admin_title']) && $cf['defaults']['admin_title']){
148
+					$value = $cf['defaults']['admin_title'];
149
+				}
150
+				?>
151 151
                 <li>
152 152
                     <label for="admin_title" class="gd-cf-tooltip-wrap">
153 153
                         <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Admin title :', 'geodirectory'); ?>
@@ -161,22 +161,22 @@  discard block
 block discarded – undo
161 161
                     </div>
162 162
                 </li>
163 163
                 <?php
164
-            }
164
+			}
165 165
 
166 166
 
167
-            // site_title
168
-            if(has_filter("geodir_cfa_site_title_{$field_type}")){
167
+			// site_title
168
+			if(has_filter("geodir_cfa_site_title_{$field_type}")){
169 169
 
170
-                echo apply_filters("geodir_cfa_site_title_{$field_type}",'',$result_str,$cf,$field_info);
170
+				echo apply_filters("geodir_cfa_site_title_{$field_type}",'',$result_str,$cf,$field_info);
171 171
 
172
-            }else{
173
-                $value = '';
174
-                if (isset($field_info->site_title)) {
175
-                    $value = esc_attr($field_info->site_title);
176
-                }elseif(isset($cf['defaults']['site_title']) && $cf['defaults']['site_title']){
177
-                    $value = $cf['defaults']['site_title'];
178
-                }
179
-                ?>
172
+			}else{
173
+				$value = '';
174
+				if (isset($field_info->site_title)) {
175
+					$value = esc_attr($field_info->site_title);
176
+				}elseif(isset($cf['defaults']['site_title']) && $cf['defaults']['site_title']){
177
+					$value = $cf['defaults']['site_title'];
178
+				}
179
+				?>
180 180
                 <li>
181 181
                     <label for="site_title" class="gd-cf-tooltip-wrap"> <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Frontend title :', 'geodirectory'); ?>
182 182
                         <div class="gdcf-tooltip">
@@ -189,22 +189,22 @@  discard block
 block discarded – undo
189 189
                     </div>
190 190
                 </li>
191 191
                 <?php
192
-            }
192
+			}
193 193
 
194 194
 
195
-            // admin_desc
196
-            if(has_filter("geodir_cfa_admin_desc_{$field_type}")){
195
+			// admin_desc
196
+			if(has_filter("geodir_cfa_admin_desc_{$field_type}")){
197 197
 
198
-                echo apply_filters("geodir_cfa_admin_desc_{$field_type}",'',$result_str,$cf,$field_info);
198
+				echo apply_filters("geodir_cfa_admin_desc_{$field_type}",'',$result_str,$cf,$field_info);
199 199
 
200
-            }else{
201
-                $value = '';
202
-                if (isset($field_info->admin_desc)) {
203
-                    $value = esc_attr($field_info->admin_desc);
204
-                }elseif(isset($cf['defaults']['admin_desc']) && $cf['defaults']['admin_desc']){
205
-                    $value = $cf['defaults']['admin_desc'];
206
-                }
207
-                ?>
200
+			}else{
201
+				$value = '';
202
+				if (isset($field_info->admin_desc)) {
203
+					$value = esc_attr($field_info->admin_desc);
204
+				}elseif(isset($cf['defaults']['admin_desc']) && $cf['defaults']['admin_desc']){
205
+					$value = $cf['defaults']['admin_desc'];
206
+				}
207
+				?>
208 208
                 <li>
209 209
                     <label for="admin_desc" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Frontend description :', 'geodirectory'); ?>
210 210
                         <div class="gdcf-tooltip">
@@ -216,23 +216,23 @@  discard block
 block discarded – undo
216 216
                     </div>
217 217
                 </li>
218 218
                 <?php
219
-            }
219
+			}
220 220
 
221 221
 
222 222
 
223
-            // htmlvar_name
224
-            if(has_filter("geodir_cfa_htmlvar_name_{$field_type}")){
223
+			// htmlvar_name
224
+			if(has_filter("geodir_cfa_htmlvar_name_{$field_type}")){
225 225
 
226
-                echo apply_filters("geodir_cfa_htmlvar_name_{$field_type}",'',$result_str,$cf,$field_info);
226
+				echo apply_filters("geodir_cfa_htmlvar_name_{$field_type}",'',$result_str,$cf,$field_info);
227 227
 
228
-            }else{
229
-                $value = '';
230
-                if (isset($field_info->htmlvar_name)) {
231
-                    $value = esc_attr($field_info->htmlvar_name);
232
-                }elseif(isset($cf['defaults']['htmlvar_name']) && $cf['defaults']['htmlvar_name']){
233
-                    $value = $cf['defaults']['htmlvar_name'];
234
-                }
235
-                ?>
228
+			}else{
229
+				$value = '';
230
+				if (isset($field_info->htmlvar_name)) {
231
+					$value = esc_attr($field_info->htmlvar_name);
232
+				}elseif(isset($cf['defaults']['htmlvar_name']) && $cf['defaults']['htmlvar_name']){
233
+					$value = $cf['defaults']['htmlvar_name'];
234
+				}
235
+				?>
236 236
                 <li>
237 237
                     <label for="htmlvar_name" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('HTML variable name :', 'geodirectory');?>
238 238
                         <div class="gdcf-tooltip">
@@ -242,29 +242,29 @@  discard block
 block discarded – undo
242 242
                     <div class="gd-cf-input-wrap">
243 243
                         <input type="text" name="htmlvar_name" id="htmlvar_name" pattern="[a-zA-Z0-9]+" title="<?php _e('Must not contain spaces or special characters', 'geodirectory');?>"
244 244
                                value="<?php if ($value) {
245
-                                   echo preg_replace('/geodir_/', '', $value, 1);
246
-                               }?>" <?php if ($default) {
247
-                            echo 'readonly="readonly"';
248
-                        }?> />
245
+								   echo preg_replace('/geodir_/', '', $value, 1);
246
+							   }?>" <?php if ($default) {
247
+							echo 'readonly="readonly"';
248
+						}?> />
249 249
                     </div>
250 250
                 </li>
251 251
                 <?php
252
-            }
252
+			}
253 253
 
254 254
 
255
-            // is_active
256
-            if(has_filter("geodir_cfa_is_active_{$field_type}")){
255
+			// is_active
256
+			if(has_filter("geodir_cfa_is_active_{$field_type}")){
257 257
 
258
-                echo apply_filters("geodir_cfa_is_active_{$field_type}",'',$result_str,$cf,$field_info);
258
+				echo apply_filters("geodir_cfa_is_active_{$field_type}",'',$result_str,$cf,$field_info);
259 259
 
260
-            }else{
261
-                $value = '';
262
-                if (isset($field_info->is_active)) {
263
-                    $value = esc_attr($field_info->is_active);
264
-                }elseif(isset($cf['defaults']['is_active']) && $cf['defaults']['is_active']){
265
-                    $value = $cf['defaults']['is_active'];
266
-                }
267
-                ?>
260
+			}else{
261
+				$value = '';
262
+				if (isset($field_info->is_active)) {
263
+					$value = esc_attr($field_info->is_active);
264
+				}elseif(isset($cf['defaults']['is_active']) && $cf['defaults']['is_active']){
265
+					$value = $cf['defaults']['is_active'];
266
+				}
267
+				?>
268 268
                 <li <?php echo $field_display; ?>>
269 269
                     <label for="is_active" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Is active :', 'geodirectory'); ?>
270 270
                         <div class="gdcf-tooltip">
@@ -275,35 +275,35 @@  discard block
 block discarded – undo
275 275
 
276 276
                         <input type="radio" id="is_active_yes<?php echo $radio_id;?>" name="is_active" class="gdri-enabled"  value="1"
277 277
                             <?php if ($value == '1') {
278
-                                echo 'checked';
279
-                            } ?>/>
278
+								echo 'checked';
279
+							} ?>/>
280 280
                         <label for="is_active_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
281 281
 
282 282
                         <input type="radio" id="is_active_no<?php echo $radio_id;?>" name="is_active" class="gdri-disabled" value="0"
283 283
                             <?php if ($value == '0' || !$value) {
284
-                                echo 'checked';
285
-                            } ?>/>
284
+								echo 'checked';
285
+							} ?>/>
286 286
                         <label for="is_active_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
287 287
 
288 288
                     </div>
289 289
                 </li>
290 290
                 <?php
291
-            }
291
+			}
292 292
 
293 293
 
294
-            // for_admin_use
295
-            if(has_filter("geodir_cfa_for_admin_use_{$field_type}")){
294
+			// for_admin_use
295
+			if(has_filter("geodir_cfa_for_admin_use_{$field_type}")){
296 296
 
297
-                echo apply_filters("geodir_cfa_for_admin_use_{$field_type}",'',$result_str,$cf,$field_info);
297
+				echo apply_filters("geodir_cfa_for_admin_use_{$field_type}",'',$result_str,$cf,$field_info);
298 298
 
299
-            }else{
300
-                $value = '';
301
-                if (isset($field_info->for_admin_use)) {
302
-                    $value = esc_attr($field_info->for_admin_use);
303
-                }elseif(isset($cf['defaults']['for_admin_use']) && $cf['defaults']['for_admin_use']){
304
-                    $value = $cf['defaults']['for_admin_use'];
305
-                }
306
-                ?>
299
+			}else{
300
+				$value = '';
301
+				if (isset($field_info->for_admin_use)) {
302
+					$value = esc_attr($field_info->for_admin_use);
303
+				}elseif(isset($cf['defaults']['for_admin_use']) && $cf['defaults']['for_admin_use']){
304
+					$value = $cf['defaults']['for_admin_use'];
305
+				}
306
+				?>
307 307
                 <li>
308 308
                     <label for="for_admin_use" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('For admin use only? :', 'geodirectory'); ?>
309 309
                         <div class="gdcf-tooltip">
@@ -314,47 +314,47 @@  discard block
 block discarded – undo
314 314
 
315 315
                         <input type="radio" id="for_admin_use_yes<?php echo $radio_id;?>" name="for_admin_use" class="gdri-enabled"  value="1"
316 316
                             <?php if ($value == '1') {
317
-                                echo 'checked';
318
-                            } ?>/>
317
+								echo 'checked';
318
+							} ?>/>
319 319
                         <label for="for_admin_use_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
320 320
 
321 321
                         <input type="radio" id="for_admin_use_no<?php echo $radio_id;?>" name="for_admin_use" class="gdri-disabled" value="0"
322 322
                             <?php if ($value == '0' || !$value) {
323
-                                echo 'checked';
324
-                            } ?>/>
323
+								echo 'checked';
324
+							} ?>/>
325 325
                         <label for="for_admin_use_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
326 326
 
327 327
                     </div>
328 328
                 </li>
329 329
                 <?php
330
-            }
330
+			}
331 331
 
332 332
 
333
-            // default_value
334
-            if(has_filter("geodir_cfa_default_value_{$field_type}")){
333
+			// default_value
334
+			if(has_filter("geodir_cfa_default_value_{$field_type}")){
335 335
 
336
-                echo apply_filters("geodir_cfa_default_value_{$field_type}",'',$result_str,$cf,$field_info);
336
+				echo apply_filters("geodir_cfa_default_value_{$field_type}",'',$result_str,$cf,$field_info);
337 337
 
338
-            }else{
339
-                $value = '';
340
-                if (isset($field_info->default_value)) {
341
-                    $value = esc_attr($field_info->default_value);
342
-                }elseif(isset($cf['defaults']['default_value']) && $cf['defaults']['default_value']){
343
-                    $value = $cf['defaults']['default_value'];
344
-                }
345
-                ?>
338
+			}else{
339
+				$value = '';
340
+				if (isset($field_info->default_value)) {
341
+					$value = esc_attr($field_info->default_value);
342
+				}elseif(isset($cf['defaults']['default_value']) && $cf['defaults']['default_value']){
343
+					$value = $cf['defaults']['default_value'];
344
+				}
345
+				?>
346 346
                 <li>
347 347
                     <label for="default_value" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Default value :', 'geodirectory');?>
348 348
                         <div class="gdcf-tooltip">
349 349
                             <?php
350
-                            if ($field_type == 'checkbox') {
351
-                                _e('Should the checkbox be checked by default?', 'geodirectory');
352
-                            } else if ($field_type == 'email') {
353
-                                _e('A default value for the field, usually blank. Ex: [email protected]', 'geodirectory');
354
-                            } else {
355
-                                _e('A default value for the field, usually blank. (for "link" this will be used as the link text)', 'geodirectory');
356
-                            }
357
-                            ?>
350
+							if ($field_type == 'checkbox') {
351
+								_e('Should the checkbox be checked by default?', 'geodirectory');
352
+							} else if ($field_type == 'email') {
353
+								_e('A default value for the field, usually blank. Ex: [email protected]', 'geodirectory');
354
+							} else {
355
+								_e('A default value for the field, usually blank. (for "link" this will be used as the link text)', 'geodirectory');
356
+							}
357
+							?>
358 358
                         </div>
359 359
                     </label>
360 360
                     <div class="gd-cf-input-wrap">
@@ -371,22 +371,22 @@  discard block
 block discarded – undo
371 371
                     </div>
372 372
                 </li>
373 373
                 <?php
374
-            }
374
+			}
375 375
 
376 376
 
377
-            // show_in
378
-            if(has_filter("geodir_cfa_show_in_{$field_type}")){
377
+			// show_in
378
+			if(has_filter("geodir_cfa_show_in_{$field_type}")){
379 379
 
380
-                echo apply_filters("geodir_cfa_show_in_{$field_type}",'',$result_str,$cf,$field_info);
380
+				echo apply_filters("geodir_cfa_show_in_{$field_type}",'',$result_str,$cf,$field_info);
381 381
 
382
-            }else{
383
-                $value = '';
384
-                if (isset($field_info->show_in)) {
385
-                    $value = esc_attr($field_info->show_in);
386
-                }elseif(isset($cf['defaults']['show_in']) && $cf['defaults']['show_in']){
387
-                    $value = esc_attr($cf['defaults']['show_in']);
388
-                }
389
-                ?>
382
+			}else{
383
+				$value = '';
384
+				if (isset($field_info->show_in)) {
385
+					$value = esc_attr($field_info->show_in);
386
+				}elseif(isset($cf['defaults']['show_in']) && $cf['defaults']['show_in']){
387
+					$value = esc_attr($cf['defaults']['show_in']);
388
+				}
389
+				?>
390 390
                 <li>
391 391
                     <label for="show_in" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Show in what locations?:', 'geodirectory'); ?>
392 392
                         <div class="gdcf-tooltip">
@@ -397,42 +397,42 @@  discard block
 block discarded – undo
397 397
 
398 398
                         <?php
399 399
 
400
-                        /*
400
+						/*
401 401
 						 * We wrap the key values in [] so we can search the DB easier with a LIKE query.
402 402
 						 */
403
-                        $show_in_locations = array(
404
-                            "[detail]" => __("Details page sidebar", 'geodirectory'),
405
-                            "[moreinfo]" => __("More info tab", 'geodirectory'),
406
-                            "[listing]" => __("Listings page", 'geodirectory'),
407
-                            "[owntab]" => __("Details page own tab", 'geodirectory'),
408
-                            "[mapbubble]" => __("Map bubble", 'geodirectory'),
409
-                        );
410
-
411
-                        /**
412
-                         * Filter the locations array for where to display custom fields.
413
-                         *
414
-                         * @since 1.6.6
415
-                         * @param array $show_in_locations The array of locations and descriptions.
416
-                         * @param object $field_info The field being displayed info.
417
-                         * @param string $field_info The type of field.
418
-                         */
419
-                        $show_in_locations = apply_filters('geodir_show_in_locations',$show_in_locations,$field_info,$field_type);
403
+						$show_in_locations = array(
404
+							"[detail]" => __("Details page sidebar", 'geodirectory'),
405
+							"[moreinfo]" => __("More info tab", 'geodirectory'),
406
+							"[listing]" => __("Listings page", 'geodirectory'),
407
+							"[owntab]" => __("Details page own tab", 'geodirectory'),
408
+							"[mapbubble]" => __("Map bubble", 'geodirectory'),
409
+						);
410
+
411
+						/**
412
+						 * Filter the locations array for where to display custom fields.
413
+						 *
414
+						 * @since 1.6.6
415
+						 * @param array $show_in_locations The array of locations and descriptions.
416
+						 * @param object $field_info The field being displayed info.
417
+						 * @param string $field_info The type of field.
418
+						 */
419
+						$show_in_locations = apply_filters('geodir_show_in_locations',$show_in_locations,$field_info,$field_type);
420 420
 
421 421
 
422
-                        // remove some locations for some field types
422
+						// remove some locations for some field types
423 423
 
424
-                        // don't show new tab option for some types
424
+						// don't show new tab option for some types
425 425
 
426
-                        if (in_array($field_type, array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
427
-                        }else{
428
-                            unset($show_in_locations['[owntab]']);
429
-                        }
426
+						if (in_array($field_type, array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
427
+						}else{
428
+							unset($show_in_locations['[owntab]']);
429
+						}
430 430
 
431
-                        if(!$display_on_listing){
432
-                            unset($show_in_locations['[listings]']);
433
-                        }
431
+						if(!$display_on_listing){
432
+							unset($show_in_locations['[listings]']);
433
+						}
434 434
 
435
-                        ?>
435
+						?>
436 436
 
437 437
                         <select multiple="multiple" name="show_in[]"
438 438
                                 id="show_in"
@@ -442,38 +442,38 @@  discard block
 block discarded – undo
442 442
                                 option-ajaxchosen="false">
443 443
                             <?php
444 444
 
445
-                            $show_in_values = explode(',',$value);
445
+							$show_in_values = explode(',',$value);
446 446
 
447
-                            foreach( $show_in_locations as $key => $val){
448
-                                $selected = '';
447
+							foreach( $show_in_locations as $key => $val){
448
+								$selected = '';
449 449
 
450
-                                if(is_array($show_in_values) && in_array($key,$show_in_values ) ){
451
-                                    $selected = 'selected';
452
-                                }
450
+								if(is_array($show_in_values) && in_array($key,$show_in_values ) ){
451
+									$selected = 'selected';
452
+								}
453 453
 
454
-                                ?>
454
+								?>
455 455
                                 <option  value="<?php echo $key;?>" <?php echo $selected;?>><?php echo $val;?></option>
456 456
                                 <?php
457
-                            }
458
-                            ?>
457
+							}
458
+							?>
459 459
                         </select>
460 460
                     </div>
461 461
                 </li>
462 462
                 <?php
463
-            }
463
+			}
464 464
 
465 465
 
466
-            // advanced_editor
467
-            if(has_filter("geodir_cfa_advanced_editor_{$field_type}")){
466
+			// advanced_editor
467
+			if(has_filter("geodir_cfa_advanced_editor_{$field_type}")){
468 468
 
469
-                echo apply_filters("geodir_cfa_advanced_editor_{$field_type}",'',$result_str,$cf,$field_info);
469
+				echo apply_filters("geodir_cfa_advanced_editor_{$field_type}",'',$result_str,$cf,$field_info);
470 470
 
471
-            }
471
+			}
472 472
 
473 473
 
474 474
 
475 475
 
476
-            ?>
476
+			?>
477 477
 
478 478
 
479 479
             <?php // @todo this does not seem to be used for anything, it can be removed or replaced ?>
@@ -486,38 +486,38 @@  discard block
 block discarded – undo
486 486
 
487 487
             <?php
488 488
 
489
-            $pricearr = array();
490
-            if (isset($field_info->packages) && $field_info->packages != '') {
491
-                $pricearr = explode(',', trim($field_info->packages, ','));
492
-            } else {
493
-                $package_info = array();
489
+			$pricearr = array();
490
+			if (isset($field_info->packages) && $field_info->packages != '') {
491
+				$pricearr = explode(',', trim($field_info->packages, ','));
492
+			} else {
493
+				$package_info = array();
494 494
 
495
-                $package_info = geodir_post_package_info($package_info, '', $post_type);
496
-                $pricearr[] = $package_info->pid;
497
-            }
495
+				$package_info = geodir_post_package_info($package_info, '', $post_type);
496
+				$pricearr[] = $package_info->pid;
497
+			}
498 498
 
499
-            ob_start()
500
-            ?>
499
+			ob_start()
500
+			?>
501 501
 
502 502
             <select style="display:none" name="show_on_pkg[]" id="show_on_pkg" multiple="multiple">
503 503
                 <?php
504
-                if (!empty($pricearr)) {
505
-                    foreach ($pricearr as $val) {
506
-                        ?>
504
+				if (!empty($pricearr)) {
505
+					foreach ($pricearr as $val) {
506
+						?>
507 507
                         <option selected="selected" value="<?php echo esc_attr($val); ?>" ><?php echo $val; ?></option><?php
508
-                    }
509
-                }
510
-                ?>
508
+					}
509
+				}
510
+				?>
511 511
             </select>
512 512
 
513 513
             <?php
514
-            $html = ob_get_clean();
514
+			$html = ob_get_clean();
515 515
 
516 516
 			/**
517 517
 			 * Filter the price packages list.
518 518
 			 *
519 519
 			 * Filter the price packages list in custom field form in admin
520
-             * custom fields settings.
520
+			 * custom fields settings.
521 521
 			 *
522 522
 			 * @since 1.0.0
523 523
 			 *
@@ -526,25 +526,25 @@  discard block
 block discarded – undo
526 526
 			 */
527 527
 			echo $html = apply_filters('geodir_packages_list_on_custom_fields', $html, $field_info);
528 528
 
529
-            ?>
529
+			?>
530 530
 
531 531
 
532 532
 
533 533
             <?php
534 534
 
535
-            // is_required
536
-            if(has_filter("geodir_cfa_is_required_{$field_type}")){
535
+			// is_required
536
+			if(has_filter("geodir_cfa_is_required_{$field_type}")){
537 537
 
538
-                echo apply_filters("geodir_cfa_is_required_{$field_type}",'',$result_str,$cf,$field_info);
538
+				echo apply_filters("geodir_cfa_is_required_{$field_type}",'',$result_str,$cf,$field_info);
539 539
 
540
-            }else{
541
-                $value = '';
542
-                if (isset($field_info->is_required)) {
543
-                    $value = esc_attr($field_info->is_required);
544
-                }elseif(isset($cf['defaults']['is_required']) && $cf['defaults']['is_required']){
545
-                    $value = $cf['defaults']['is_required'];
546
-                }
547
-                ?>
540
+			}else{
541
+				$value = '';
542
+				if (isset($field_info->is_required)) {
543
+					$value = esc_attr($field_info->is_required);
544
+				}elseif(isset($cf['defaults']['is_required']) && $cf['defaults']['is_required']){
545
+					$value = $cf['defaults']['is_required'];
546
+				}
547
+				?>
548 548
                 <li>
549 549
                     <label for="is_required" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Is required :', 'geodirectory'); ?>
550 550
                         <div class="gdcf-tooltip">
@@ -556,14 +556,14 @@  discard block
 block discarded – undo
556 556
 
557 557
                         <input type="radio" id="is_required_yes<?php echo $radio_id;?>" name="is_required" class="gdri-enabled"  value="1"
558 558
                             <?php if ($value == '1') {
559
-                                echo 'checked';
560
-                            } ?>/>
559
+								echo 'checked';
560
+							} ?>/>
561 561
                         <label onclick="show_hide_radio(this,'show','cf-is-required-msg');" for="is_required_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
562 562
 
563 563
                         <input type="radio" id="is_required_no<?php echo $radio_id;?>" name="is_required" class="gdri-disabled" value="0"
564 564
                             <?php if ($value == '0' || !$value) {
565
-                                echo 'checked';
566
-                            } ?>/>
565
+								echo 'checked';
566
+							} ?>/>
567 567
                         <label onclick="show_hide_radio(this,'hide','cf-is-required-msg');" for="is_required_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
568 568
 
569 569
                     </div>
@@ -571,21 +571,21 @@  discard block
 block discarded – undo
571 571
                 </li>
572 572
 
573 573
                 <?php
574
-            }
574
+			}
575 575
 
576
-            // required_msg
577
-            if(has_filter("geodir_cfa_required_msg_{$field_type}")){
576
+			// required_msg
577
+			if(has_filter("geodir_cfa_required_msg_{$field_type}")){
578 578
 
579
-                echo apply_filters("geodir_cfa_required_msg_{$field_type}",'',$result_str,$cf,$field_info);
579
+				echo apply_filters("geodir_cfa_required_msg_{$field_type}",'',$result_str,$cf,$field_info);
580 580
 
581
-            }else{
582
-                $value = '';
583
-                if (isset($field_info->required_msg)) {
584
-                    $value = esc_attr($field_info->required_msg);
585
-                }elseif(isset($cf['defaults']['required_msg']) && $cf['defaults']['required_msg']){
586
-                    $value = $cf['defaults']['required_msg'];
587
-                }
588
-                ?>
581
+			}else{
582
+				$value = '';
583
+				if (isset($field_info->required_msg)) {
584
+					$value = esc_attr($field_info->required_msg);
585
+				}elseif(isset($cf['defaults']['required_msg']) && $cf['defaults']['required_msg']){
586
+					$value = $cf['defaults']['required_msg'];
587
+				}
588
+				?>
589 589
                 <li class="cf-is-required-msg"<?php if ((isset($field_info->is_required) && $field_info->is_required == '0') || !isset($field_info->is_required)) {echo "style='display:none;'";}?>>
590 590
                     <label for="required_msg" class="gd-cf-tooltip-wrap">
591 591
                         <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Required message:', 'geodirectory'); ?>
@@ -599,38 +599,38 @@  discard block
 block discarded – undo
599 599
                     </div>
600 600
                 </li>
601 601
                 <?php
602
-            }
602
+			}
603 603
 
604 604
 
605
-            // required_msg
606
-            if(has_filter("geodir_cfa_validation_pattern_{$field_type}")){
605
+			// required_msg
606
+			if(has_filter("geodir_cfa_validation_pattern_{$field_type}")){
607 607
 
608
-                echo apply_filters("geodir_cfa_validation_pattern_{$field_type}",'',$result_str,$cf,$field_info);
608
+				echo apply_filters("geodir_cfa_validation_pattern_{$field_type}",'',$result_str,$cf,$field_info);
609 609
 
610
-            }
610
+			}
611 611
 
612 612
 
613
-            // extra_fields
614
-            if(has_filter("geodir_cfa_extra_fields_{$field_type}")){
613
+			// extra_fields
614
+			if(has_filter("geodir_cfa_extra_fields_{$field_type}")){
615 615
 
616
-                echo apply_filters("geodir_cfa_extra_fields_{$field_type}",'',$result_str,$cf,$field_info);
616
+				echo apply_filters("geodir_cfa_extra_fields_{$field_type}",'',$result_str,$cf,$field_info);
617 617
 
618
-            }
618
+			}
619 619
 
620 620
 
621
-            // field_icon
622
-            if(has_filter("geodir_cfa_field_icon_{$field_type}")){
621
+			// field_icon
622
+			if(has_filter("geodir_cfa_field_icon_{$field_type}")){
623 623
 
624
-                echo apply_filters("geodir_cfa_field_icon_{$field_type}",'',$result_str,$cf,$field_info);
624
+				echo apply_filters("geodir_cfa_field_icon_{$field_type}",'',$result_str,$cf,$field_info);
625 625
 
626
-            }else{
627
-                $value = '';
628
-                if (isset($field_info->field_icon)) {
629
-                    $value = esc_attr($field_info->field_icon);
630
-                }elseif(isset($cf['defaults']['field_icon']) && $cf['defaults']['field_icon']){
631
-                    $value = $cf['defaults']['field_icon'];
632
-                }
633
-                ?>
626
+			}else{
627
+				$value = '';
628
+				if (isset($field_info->field_icon)) {
629
+					$value = esc_attr($field_info->field_icon);
630
+				}elseif(isset($cf['defaults']['field_icon']) && $cf['defaults']['field_icon']){
631
+					$value = $cf['defaults']['field_icon'];
632
+				}
633
+				?>
634 634
                 <li>
635 635
                     <h3><?php echo __('Custom css', 'geodirectory'); ?></h3>
636 636
 
@@ -648,22 +648,22 @@  discard block
 block discarded – undo
648 648
 
649 649
                 </li>
650 650
                 <?php
651
-            }
651
+			}
652 652
 
653 653
 
654
-            // css_class
655
-            if(has_filter("geodir_cfa_css_class_{$field_type}")){
654
+			// css_class
655
+			if(has_filter("geodir_cfa_css_class_{$field_type}")){
656 656
 
657
-                echo apply_filters("geodir_cfa_css_class_{$field_type}",'',$result_str,$cf,$field_info);
657
+				echo apply_filters("geodir_cfa_css_class_{$field_type}",'',$result_str,$cf,$field_info);
658 658
 
659
-            }else{
660
-                $value = '';
661
-                if (isset($field_info->css_class)) {
662
-                    $value = esc_attr($field_info->css_class);
663
-                }elseif(isset($cf['defaults']['css_class']) && $cf['defaults']['css_class']){
664
-                    $value = $cf['defaults']['css_class'];
665
-                }
666
-                ?>
659
+			}else{
660
+				$value = '';
661
+				if (isset($field_info->css_class)) {
662
+					$value = esc_attr($field_info->css_class);
663
+				}elseif(isset($cf['defaults']['css_class']) && $cf['defaults']['css_class']){
664
+					$value = $cf['defaults']['css_class'];
665
+				}
666
+				?>
667 667
                 <li>
668 668
 
669 669
                     <label for="css_class" class="gd-cf-tooltip-wrap">
@@ -675,47 +675,47 @@  discard block
 block discarded – undo
675 675
                     <div class="gd-cf-input-wrap">
676 676
                         <input type="text" name="css_class" id="css_class"
677 677
                                value="<?php if (isset($field_info->css_class)) {
678
-                                   echo esc_attr($field_info->css_class);
679
-                               }?>"/>
678
+								   echo esc_attr($field_info->css_class);
679
+							   }?>"/>
680 680
                     </div>
681 681
                 </li>
682 682
                 <?php
683
-            }
683
+			}
684 684
 
685 685
 
686
-            // cat_sort
687
-            if(has_filter("geodir_cfa_cat_sort_{$field_type}")){
686
+			// cat_sort
687
+			if(has_filter("geodir_cfa_cat_sort_{$field_type}")){
688 688
 
689
-                echo apply_filters("geodir_cfa_cat_sort_{$field_type}",'',$result_str,$cf,$field_info);
689
+				echo apply_filters("geodir_cfa_cat_sort_{$field_type}",'',$result_str,$cf,$field_info);
690 690
 
691
-            }else{
692
-                $value = '';
693
-                $hide_cat_sort  ='';
694
-                if (isset($field_info->cat_sort)) {
695
-                    $value = esc_attr($field_info->cat_sort);
696
-                }elseif(isset($cf['defaults']['cat_sort']) && $cf['defaults']['cat_sort']){
697
-                    $value = $cf['defaults']['cat_sort'];
698
-                    $hide_cat_sort = ($value===false) ? "style='display:none;'" : '';
699
-                }
691
+			}else{
692
+				$value = '';
693
+				$hide_cat_sort  ='';
694
+				if (isset($field_info->cat_sort)) {
695
+					$value = esc_attr($field_info->cat_sort);
696
+				}elseif(isset($cf['defaults']['cat_sort']) && $cf['defaults']['cat_sort']){
697
+					$value = $cf['defaults']['cat_sort'];
698
+					$hide_cat_sort = ($value===false) ? "style='display:none;'" : '';
699
+				}
700 700
 
701
-                $hide_cat_sort = ($cf['defaults']['cat_sort']===false) ? "style='display:none;'" : '';
702
-                ?>
701
+				$hide_cat_sort = ($cf['defaults']['cat_sort']===false) ? "style='display:none;'" : '';
702
+				?>
703 703
                 <li <?php echo $hide_cat_sort ;?>>
704 704
                     <h3><?php
705
-                        /**
706
-                         * Filter the section title.
707
-                         *
708
-                         * Filter the section title in custom field form in admin
709
-                         * custom fields settings.
710
-                         *
711
-                         * @since 1.0.0
712
-                         *
713
-                         * @param string $title Title of the section.
714
-                         * @param string $field_type Current field type.
715
-                         */
716
-                        echo apply_filters('geodir_advance_custom_fields_heading', __('Posts sort options', 'geodirectory'), $field_type);
717
-
718
-                        ?></h3>
705
+						/**
706
+						 * Filter the section title.
707
+						 *
708
+						 * Filter the section title in custom field form in admin
709
+						 * custom fields settings.
710
+						 *
711
+						 * @since 1.0.0
712
+						 *
713
+						 * @param string $title Title of the section.
714
+						 * @param string $field_type Current field type.
715
+						 */
716
+						echo apply_filters('geodir_advance_custom_fields_heading', __('Posts sort options', 'geodirectory'), $field_type);
717
+
718
+						?></h3>
719 719
                     <label for="cat_sort" class="gd-cf-tooltip-wrap">
720 720
                         <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Include this field in sorting options :', 'geodirectory'); ?>
721 721
                         <div class="gdcf-tooltip">
@@ -727,40 +727,40 @@  discard block
 block discarded – undo
727 727
 
728 728
                         <input type="radio" id="cat_sort_yes<?php echo $radio_id;?>" name="cat_sort" class="gdri-enabled"  value="1"
729 729
                             <?php if ($value == '1') {
730
-                                echo 'checked';
731
-                            } ?>/>
730
+								echo 'checked';
731
+							} ?>/>
732 732
                         <label for="cat_sort_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
733 733
 
734 734
                         <input type="radio" id="cat_sort_no<?php echo $radio_id;?>" name="cat_sort" class="gdri-disabled" value="0"
735 735
                             <?php if (!$value) {
736
-                                echo 'checked';
737
-                            } ?>/>
736
+								echo 'checked';
737
+							} ?>/>
738 738
                         <label for="cat_sort_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
739 739
 
740 740
                     </div>
741 741
                 </li>
742 742
                 <?php
743
-            }
744
-
745
-
746
-
747
-            switch ($field_type):
748
-                case 'html':
749
-                case 'file':
750
-                case 'url':
751
-                case 'fieldset':
752
-                    break;
753
-                default:
754
-
755
-                    /**
756
-                     * Called at the end of the advanced custom fields settings page loop.
757
-                     *
758
-                     * Can be used to add or deal with different settings types.
759
-                     *
760
-                     * @since 1.0.0
761
-                     * @param object $field_info The current fields info.
762
-                     */
763
-                    do_action('geodir_advance_custom_fields', $field_info);?>
743
+			}
744
+
745
+
746
+
747
+			switch ($field_type):
748
+				case 'html':
749
+				case 'file':
750
+				case 'url':
751
+				case 'fieldset':
752
+					break;
753
+				default:
754
+
755
+					/**
756
+					 * Called at the end of the advanced custom fields settings page loop.
757
+					 *
758
+					 * Can be used to add or deal with different settings types.
759
+					 *
760
+					 * @since 1.0.0
761
+					 * @param object $field_info The current fields info.
762
+					 */
763
+					do_action('geodir_advance_custom_fields', $field_info);?>
764 764
 
765 765
 
766 766
                 <?php endswitch; ?>
Please login to merge, or discard this patch.
geodirectory-admin/admin_hooks_actions.php 1 patch
Indentation   +1446 added lines, -1446 removed lines patch added patch discarded remove patch
@@ -10,33 +10,33 @@  discard block
 block discarded – undo
10 10
 
11 11
 add_action('admin_init', 'geodir_admin_init');
12 12
 if (!function_exists('geodir_admin_init')) {
13
-    /**
14
-     * Adds GD setting pages in admin.
15
-     *
16
-     * @since 1.0.0
17
-     * @package GeoDirectory
18
-     * @global string $current_tab The current settings tab name.
19
-     */
20
-    function geodir_admin_init()
21
-    {
22
-
23
-        if (is_admin()):
24
-            global $current_tab;
25
-            geodir_redirect_to_admin_panel_on_installed();
26
-            $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
-            if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
-                geodir_handle_option_form_submit($current_tab); // located in admin function.php
29
-            /**
30
-             * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31
-             *
32
-             * @since 1.0.0
33
-             */
34
-            do_action('admin_panel_init');
35
-            add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
36
-
37
-
38
-        endif;
39
-    }
13
+	/**
14
+	 * Adds GD setting pages in admin.
15
+	 *
16
+	 * @since 1.0.0
17
+	 * @package GeoDirectory
18
+	 * @global string $current_tab The current settings tab name.
19
+	 */
20
+	function geodir_admin_init()
21
+	{
22
+
23
+		if (is_admin()):
24
+			global $current_tab;
25
+			geodir_redirect_to_admin_panel_on_installed();
26
+			$current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
+			if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
+				geodir_handle_option_form_submit($current_tab); // located in admin function.php
29
+			/**
30
+			 * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31
+			 *
32
+			 * @since 1.0.0
33
+			 */
34
+			do_action('admin_panel_init');
35
+			add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
36
+
37
+
38
+		endif;
39
+	}
40 40
 }
41 41
 
42 42
 /**
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function geodir_redirect_to_admin_panel_on_installed()
49 49
 {
50
-    if (get_option('geodir_installation_redirect', false)) {
51
-        delete_option('geodir_installation_redirect');
52
-        wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
53
-    }
50
+	if (get_option('geodir_installation_redirect', false)) {
51
+		delete_option('geodir_installation_redirect');
52
+		wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
53
+	}
54 54
 }
55 55
 
56 56
 /**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function geodir_get_admin_option_form($current_tab)
64 64
 {
65
-    geodir_admin_option_form($current_tab);// defined in admin template tags.php
65
+	geodir_admin_option_form($current_tab);// defined in admin template tags.php
66 66
 }
67 67
 
68 68
 
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
  */
86 86
 function geodir_conditional_admin_script_load()
87 87
 {
88
-    global $pagenow;
88
+	global $pagenow;
89 89
 	
90 90
 	// Get the current post type
91 91
 	$post_type = geodir_admin_current_post_type();
92 92
 	$geodir_post_types = geodir_get_posttypes();
93 93
     
94 94
 	if ((isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') || (($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') && $post_type && in_array($post_type, $geodir_post_types)) || ($pagenow == 'edit-tags.php' || $pagenow == 'term.php' || $pagenow == 'edit-comments.php' || $pagenow == 'comment.php')) {
95
-        add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
96
-        add_action('admin_enqueue_scripts', 'geodir_admin_styles');
97
-        add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
98
-    }
95
+		add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
96
+		add_action('admin_enqueue_scripts', 'geodir_admin_styles');
97
+		add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
98
+	}
99 99
 
100
-    add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
100
+	add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
101 101
 
102 102
 }
103 103
 
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function create_default_admin_main_nav()
133 133
 {
134
-    add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
135
-    add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
136
-    add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
137
-    add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
138
-    add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
139
-    //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
134
+	add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
135
+	add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
136
+	add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
137
+	add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
138
+	add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
139
+	//add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
140 140
 
141 141
 }
142 142
 
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
  */
150 150
 function geodir_admin_list_columns()
151 151
 {
152
-    if ($post_types = geodir_get_posttypes()) {
152
+	if ($post_types = geodir_get_posttypes()) {
153 153
 
154
-        foreach ($post_types as $post_type):
155
-            add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
156
-            //Filter-Payment-Manager to show Package
157
-            add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
154
+		foreach ($post_types as $post_type):
155
+			add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
156
+			//Filter-Payment-Manager to show Package
157
+			add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
158 158
 
159
-            add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
160
-        endforeach;
161
-    }
159
+			add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
160
+		endforeach;
161
+	}
162 162
 }
163 163
 
164 164
 /**
@@ -171,15 +171,15 @@  discard block
 block discarded – undo
171 171
  */
172 172
 function geodir_default_admin_main_tabs($tabs)
173 173
 {
174
-    return $tabs = array(
175
-        'general_settings' => array('label' => __('General', 'geodirectory')),
176
-        'design_settings' => array('label' => __('Design', 'geodirectory')),
177
-        'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
178
-        'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
179
-        'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
180
-        'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
181
-
182
-    );
174
+	return $tabs = array(
175
+		'general_settings' => array('label' => __('General', 'geodirectory')),
176
+		'design_settings' => array('label' => __('Design', 'geodirectory')),
177
+		'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
178
+		'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
179
+		'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
180
+		'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
181
+
182
+	);
183 183
 }
184 184
 
185 185
 add_action('do_meta_boxes', 'geodir_remove_image_box');
@@ -192,16 +192,16 @@  discard block
 block discarded – undo
192 192
  */
193 193
 function geodir_remove_image_box()
194 194
 {
195
-    global $post;
195
+	global $post;
196 196
 
197
-    $geodir_posttypes = geodir_get_posttypes();
197
+	$geodir_posttypes = geodir_get_posttypes();
198 198
 
199
-    if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
199
+	if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
200 200
 
201
-        remove_meta_box('postimagediv', $post->post_type, 'side');
202
-        remove_meta_box('revisionsdiv', $post->post_type, 'normal');
201
+		remove_meta_box('postimagediv', $post->post_type, 'side');
202
+		remove_meta_box('revisionsdiv', $post->post_type, 'normal');
203 203
 
204
-    endif;
204
+	endif;
205 205
 
206 206
 }
207 207
 
@@ -216,26 +216,26 @@  discard block
 block discarded – undo
216 216
  */
217 217
 function geodir_meta_box_add()
218 218
 {
219
-    global $post;
219
+	global $post;
220 220
 
221
-    $geodir_post_types = geodir_get_posttypes('array');
222
-    $geodir_posttypes = array_keys($geodir_post_types);
221
+	$geodir_post_types = geodir_get_posttypes('array');
222
+	$geodir_posttypes = array_keys($geodir_post_types);
223 223
 
224
-    if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
224
+	if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
225 225
 
226
-        $geodir_posttype = $post->post_type;
227
-        $post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']);
226
+		$geodir_posttype = $post->post_type;
227
+		$post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']);
228 228
 
229
-        // Filter-Payment-Manager
229
+		// Filter-Payment-Manager
230 230
 
231
-        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
231
+		add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
232 232
 
233
-        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
233
+		add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
234 234
 
235
-        // no need of this box as all fields moved to main information box
236
-        //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
235
+		// no need of this box as all fields moved to main information box
236
+		//add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
237 237
 
238
-    endif;
238
+	endif;
239 239
 
240 240
 }
241 241
 
@@ -259,23 +259,23 @@  discard block
 block discarded – undo
259 259
 function geodir_hide_post_taxonomy_meta_boxes()
260 260
 {
261 261
 
262
-    $geodir_post_types = get_option('geodir_post_types');
262
+	$geodir_post_types = get_option('geodir_post_types');
263 263
 
264
-    if (!empty($geodir_post_types)) {
265
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
264
+	if (!empty($geodir_post_types)) {
265
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
266 266
 
267
-            $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
267
+			$gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
268 268
 
269
-            if(!empty($gd_taxonomy)) {
270
-                foreach ($gd_taxonomy as $tax) {
269
+			if(!empty($gd_taxonomy)) {
270
+				foreach ($gd_taxonomy as $tax) {
271 271
 
272
-                    remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
272
+					remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
273 273
 
274
-                }
275
-            }
274
+				}
275
+			}
276 276
 
277
-        }
278
-    }
277
+		}
278
+	}
279 279
 }
280 280
 
281 281
 add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict');
@@ -289,12 +289,12 @@  discard block
 block discarded – undo
289 289
  */
290 290
 function geodir_add_listing_map_restrict($map_restirct)
291 291
 {
292
-    if (is_admin()) {
293
-        if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
294
-            $map_restirct = false;
295
-        }
296
-    }
297
-    return $map_restirct;
292
+	if (is_admin()) {
293
+		if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
294
+			$map_restirct = false;
295
+		}
296
+	}
297
+	return $map_restirct;
298 298
 }
299 299
 
300 300
 
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
 function geodir_enable_editor_on_notifications($notification)
314 314
 {
315 315
 
316
-    if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
316
+	if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
317 317
 
318
-        foreach ($notification as $key => $value) {
319
-            if ($value['type'] == 'textarea')
320
-                $notification[$key]['type'] = 'editor';
321
-        }
318
+		foreach ($notification as $key => $value) {
319
+			if ($value['type'] == 'textarea')
320
+				$notification[$key]['type'] = 'editor';
321
+		}
322 322
 
323
-    }
323
+	}
324 324
 
325
-    return $notification;
325
+	return $notification;
326 326
 }
327 327
 
328 328
 
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
 function geodir_enable_editor_on_design_settings($design_setting)
340 340
 {
341 341
 
342
-    if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
342
+	if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
343 343
 
344
-        foreach ($design_setting as $key => $value) {
345
-            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
346
-                $design_setting[$key]['type'] = 'editor';
347
-        }
344
+		foreach ($design_setting as $key => $value) {
345
+			if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
346
+				$design_setting[$key]['type'] = 'editor';
347
+		}
348 348
 
349
-    }
349
+	}
350 350
 
351
-    return $design_setting;
351
+	return $design_setting;
352 352
 }
353 353
 
354 354
 /* ----------- START MANAGE CUSTOM FIELDS ---------------- */
@@ -369,16 +369,16 @@  discard block
 block discarded – undo
369 369
 function geodir_manage_available_fields($sub_tab)
370 370
 {
371 371
 
372
-    switch ($sub_tab) {
373
-        case 'custom_fields':
374
-            geodir_custom_available_fields();
375
-            break;
372
+	switch ($sub_tab) {
373
+		case 'custom_fields':
374
+			geodir_custom_available_fields();
375
+			break;
376 376
 
377
-        case 'sorting_options':
378
-            geodir_sorting_options_available_fields();
379
-            break;
377
+		case 'sorting_options':
378
+			geodir_sorting_options_available_fields();
379
+			break;
380 380
 
381
-    }
381
+	}
382 382
 }
383 383
 
384 384
 
@@ -394,16 +394,16 @@  discard block
 block discarded – undo
394 394
 function geodir_manage_selected_fields($sub_tab)
395 395
 {
396 396
 
397
-    switch ($sub_tab) {
398
-        case 'custom_fields':
399
-            geodir_custom_selected_fields();
400
-            break;
397
+	switch ($sub_tab) {
398
+		case 'custom_fields':
399
+			geodir_custom_selected_fields();
400
+			break;
401 401
 
402
-        case 'sorting_options':
403
-            geodir_sorting_options_selected_fields();
404
-            break;
402
+		case 'sorting_options':
403
+			geodir_sorting_options_selected_fields();
404
+			break;
405 405
 
406
-    }
406
+	}
407 407
 }
408 408
 
409 409
 /**
@@ -415,27 +415,27 @@  discard block
 block discarded – undo
415 415
  */
416 416
 function geodir_sorting_options_available_fields()
417 417
 {
418
-    global $wpdb;
419
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
420
-    ?>
418
+	global $wpdb;
419
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
420
+	?>
421 421
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
422 422
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
423 423
     <ul>
424 424
     <?php
425
-        $sort_options = geodir_get_custom_sort_options($listing_type);
425
+		$sort_options = geodir_get_custom_sort_options($listing_type);
426 426
         
427
-        foreach ($sort_options as $key => $val) {
428
-            $val = stripslashes_deep($val); // strip slashes
429
-
430
-            $check_html_variable = $wpdb->get_var(
431
-                $wpdb->prepare(
432
-                    "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
433
-                    array($val['htmlvar_name'], $listing_type, $val['field_type'])
434
-                )
435
-            );
427
+		foreach ($sort_options as $key => $val) {
428
+			$val = stripslashes_deep($val); // strip slashes
429
+
430
+			$check_html_variable = $wpdb->get_var(
431
+				$wpdb->prepare(
432
+					"SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
433
+					array($val['htmlvar_name'], $listing_type, $val['field_type'])
434
+				)
435
+			);
436 436
             
437
-            $display = $check_html_variable ? ' style="display:none;"' : '';
438
-            ?>
437
+			$display = $check_html_variable ? ' style="display:none;"' : '';
438
+			?>
439 439
             <li <?php echo $display;?>>
440 440
             <a id="gt-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>"
441 441
                title="<?php echo $val['site_title'];?>"
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
                href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory');?></a>
444 444
             </li>
445 445
             <?php
446
-        }
447
-    ?>
446
+		}
447
+	?>
448 448
     </ul>
449 449
     <?php
450 450
 }
@@ -458,28 +458,28 @@  discard block
 block discarded – undo
458 458
  */
459 459
 function geodir_sorting_options_selected_fields()
460 460
 {
461
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
462
-    ?>
461
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
462
+	?>
463 463
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
464 464
     <ul class="core">
465 465
     <?php 
466
-        global $wpdb;
466
+		global $wpdb;
467 467
         
468
-        $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)));
468
+		$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)));
469 469
 
470
-        if (!empty($fields)) {
471
-            foreach ($fields as $field) {
472
-                //$result_str = $field->id;
473
-                $result_str = $field;
474
-                $field_type = $field->field_type;
475
-                $field_ins_upd = 'display';
470
+		if (!empty($fields)) {
471
+			foreach ($fields as $field) {
472
+				//$result_str = $field->id;
473
+				$result_str = $field;
474
+				$field_type = $field->field_type;
475
+				$field_ins_upd = 'display';
476 476
 
477
-                $default = false;
477
+				$default = false;
478 478
 
479
-                geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
480
-            }
481
-        }
482
-    ?>
479
+				geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
480
+			}
481
+		}
482
+	?>
483 483
     </ul>
484 484
     <?php
485 485
 }
@@ -493,137 +493,137 @@  discard block
 block discarded – undo
493 493
  */
494 494
 function geodir_custom_fields($post_type=''){
495 495
     
496
-    $custom_fields = array(
497
-        'text' => array(
498
-            'field_type'  =>  'text',
499
-            'class' =>  'gd-text',
500
-            'icon'  =>  'fa fa-minus',
501
-            'name'  =>  __('Text', 'geodirectory'),
502
-            'description' =>  __('Add any sort of text field, text or numbers', 'geodirectory')
503
-        ),
504
-        'datepicker' => array(
505
-            'field_type'  =>  'datepicker',
506
-            'class' =>  'gd-datepicker',
507
-            'icon'  =>  'fa fa-calendar',
508
-            'name'  =>  __('Date', 'geodirectory'),
509
-            'description' =>  __('Adds a date picker.', 'geodirectory')
510
-        ),
511
-        'textarea' => array(
512
-            'field_type'  =>  'textarea',
513
-            'class' =>  'gd-textarea',
514
-            'icon'  =>  'fa fa-bars',
515
-            'name'  =>  __('Textarea', 'geodirectory'),
516
-            'description' =>  __('Adds a textarea', 'geodirectory')
517
-        ),
518
-        'time' => array(
519
-            'field_type'  =>  'time',
520
-            'class' =>  'gd-time',
521
-            'icon' =>  'fa fa-clock-o',
522
-            'name'  =>  __('Time', 'geodirectory'),
523
-            'description' =>  __('Adds a time picker', 'geodirectory')
524
-        ),
525
-        'checkbox' => array(
526
-            'field_type'  =>  'checkbox',
527
-            'class' =>  'gd-checkbox',
528
-            'icon' =>  'fa fa-check-square-o',
529
-            'name'  =>  __('Checkbox', 'geodirectory'),
530
-            'description' =>  __('Adds a checkbox', 'geodirectory')
531
-        ),
532
-        'phone' => array(
533
-            'field_type'  =>  'phone',
534
-            'class' =>  'gd-phone',
535
-            'icon' =>  'fa fa-phone',
536
-            'name'  =>  __('Phone', 'geodirectory'),
537
-            'description' =>  __('Adds a phone input', 'geodirectory')
538
-        ),
539
-        'radio' => array(
540
-            'field_type'  =>  'radio',
541
-            'class' =>  'gd-radio',
542
-            'icon' =>  'fa fa-dot-circle-o',
543
-            'name'  =>  __('Radio', 'geodirectory'),
544
-            'description' =>  __('Adds a radio input', 'geodirectory')
545
-        ),
546
-        'email' => array(
547
-            'field_type'  =>  'email',
548
-            'class' =>  'gd-email',
549
-            'icon' =>  'fa fa-envelope-o',
550
-            'name'  =>  __('Email', 'geodirectory'),
551
-            'description' =>  __('Adds a email input', 'geodirectory')
552
-        ),
553
-        'select' => array(
554
-            'field_type'  =>  'select',
555
-            'class' =>  'gd-select',
556
-            'icon' =>  'fa fa-caret-square-o-down',
557
-            'name'  =>  __('Select', 'geodirectory'),
558
-            'description' =>  __('Adds a select input', 'geodirectory')
559
-        ),
560
-        'multiselect' => array(
561
-            'field_type'  =>  'multiselect',
562
-            'class' =>  'gd-multiselect',
563
-            'icon' =>  'fa fa-caret-square-o-down',
564
-            'name'  =>  __('Multi Select', 'geodirectory'),
565
-            'description' =>  __('Adds a multiselect input', 'geodirectory')
566
-        ),
567
-        'url' => array(
568
-            'field_type'  =>  'url',
569
-            'class' =>  'gd-url',
570
-            'icon' =>  'fa fa-link',
571
-            'name'  =>  __('URL', 'geodirectory'),
572
-            'description' =>  __('Adds a url input', 'geodirectory')
573
-        ),
574
-        'html' => array(
575
-            'field_type'  =>  'html',
576
-            'class' =>  'gd-html',
577
-            'icon' =>  'fa fa-code',
578
-            'name'  =>  __('HTML', 'geodirectory'),
579
-            'description' =>  __('Adds a html input textarea', 'geodirectory')
580
-        ),
581
-        'file' => array(
582
-            'field_type'  =>  'file',
583
-            'class' =>  'gd-file',
584
-            'icon' =>  'fa fa-file',
585
-            'name'  =>  __('File Upload', 'geodirectory'),
586
-            'description' =>  __('Adds a file input', 'geodirectory')
587
-        )
588
-    );
589
-
590
-    /**
591
-     * Filter the custom fields array to be able to add or remove items.
592
-     * 
593
-     * @since 1.6.6
594
-     *
595
-     * @param array $custom_fields {
596
-     *     The custom fields array to be filtered.
597
-     *
598
-     *     @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file.
599
-     *     @type string $class The class for the field in backend.
600
-     *     @type string $icon Can be font-awesome class name or icon image url.
601
-     *     @type string $name The name of the field.
602
-     *     @type string $description A short description about the field.
603
-     *     @type array $defaults {
604
-     *                    Optional. Used to set the default value of the field.
605
-     *
606
-     *                    @type string data_type The SQL data type for the field.
607
-     *                    @type string admin_title The admin title for the field.
608
-     *                    @type string site_title This will be the title for the field on the frontend.
609
-     *                    @type string admin_desc This will be shown below the field on the add listing form.
610
-     *                    @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.
611
-     *                    @type bool is_active If false the field will not be displayed anywhere.
612
-     *                    @type bool for_admin_use If true then only site admin can see and edit this field.
613
-     *                    @type string default_value The default value for the input on the add listing page.
614
-     *                    @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble]
615
-     *                    @type bool is_required If true the field will be required on the add listing page.
616
-     *                    @type string validation_pattern HTML5 validation pattern (text input only by default).
617
-     *                    @type string validation_msg HTML5 validation message (text input only by default).
618
-     *                    @type string required_msg Required warning message.
619
-     *                    @type string field_icon Icon url or font awesome class.
620
-     *                    @type string css_class Field custom css class for field custom style.
621
-     *                    @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.
622
-     *     }
623
-     * }
624
-     * @param string $post_type The post type requested.
625
-     */
626
-    return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
496
+	$custom_fields = array(
497
+		'text' => array(
498
+			'field_type'  =>  'text',
499
+			'class' =>  'gd-text',
500
+			'icon'  =>  'fa fa-minus',
501
+			'name'  =>  __('Text', 'geodirectory'),
502
+			'description' =>  __('Add any sort of text field, text or numbers', 'geodirectory')
503
+		),
504
+		'datepicker' => array(
505
+			'field_type'  =>  'datepicker',
506
+			'class' =>  'gd-datepicker',
507
+			'icon'  =>  'fa fa-calendar',
508
+			'name'  =>  __('Date', 'geodirectory'),
509
+			'description' =>  __('Adds a date picker.', 'geodirectory')
510
+		),
511
+		'textarea' => array(
512
+			'field_type'  =>  'textarea',
513
+			'class' =>  'gd-textarea',
514
+			'icon'  =>  'fa fa-bars',
515
+			'name'  =>  __('Textarea', 'geodirectory'),
516
+			'description' =>  __('Adds a textarea', 'geodirectory')
517
+		),
518
+		'time' => array(
519
+			'field_type'  =>  'time',
520
+			'class' =>  'gd-time',
521
+			'icon' =>  'fa fa-clock-o',
522
+			'name'  =>  __('Time', 'geodirectory'),
523
+			'description' =>  __('Adds a time picker', 'geodirectory')
524
+		),
525
+		'checkbox' => array(
526
+			'field_type'  =>  'checkbox',
527
+			'class' =>  'gd-checkbox',
528
+			'icon' =>  'fa fa-check-square-o',
529
+			'name'  =>  __('Checkbox', 'geodirectory'),
530
+			'description' =>  __('Adds a checkbox', 'geodirectory')
531
+		),
532
+		'phone' => array(
533
+			'field_type'  =>  'phone',
534
+			'class' =>  'gd-phone',
535
+			'icon' =>  'fa fa-phone',
536
+			'name'  =>  __('Phone', 'geodirectory'),
537
+			'description' =>  __('Adds a phone input', 'geodirectory')
538
+		),
539
+		'radio' => array(
540
+			'field_type'  =>  'radio',
541
+			'class' =>  'gd-radio',
542
+			'icon' =>  'fa fa-dot-circle-o',
543
+			'name'  =>  __('Radio', 'geodirectory'),
544
+			'description' =>  __('Adds a radio input', 'geodirectory')
545
+		),
546
+		'email' => array(
547
+			'field_type'  =>  'email',
548
+			'class' =>  'gd-email',
549
+			'icon' =>  'fa fa-envelope-o',
550
+			'name'  =>  __('Email', 'geodirectory'),
551
+			'description' =>  __('Adds a email input', 'geodirectory')
552
+		),
553
+		'select' => array(
554
+			'field_type'  =>  'select',
555
+			'class' =>  'gd-select',
556
+			'icon' =>  'fa fa-caret-square-o-down',
557
+			'name'  =>  __('Select', 'geodirectory'),
558
+			'description' =>  __('Adds a select input', 'geodirectory')
559
+		),
560
+		'multiselect' => array(
561
+			'field_type'  =>  'multiselect',
562
+			'class' =>  'gd-multiselect',
563
+			'icon' =>  'fa fa-caret-square-o-down',
564
+			'name'  =>  __('Multi Select', 'geodirectory'),
565
+			'description' =>  __('Adds a multiselect input', 'geodirectory')
566
+		),
567
+		'url' => array(
568
+			'field_type'  =>  'url',
569
+			'class' =>  'gd-url',
570
+			'icon' =>  'fa fa-link',
571
+			'name'  =>  __('URL', 'geodirectory'),
572
+			'description' =>  __('Adds a url input', 'geodirectory')
573
+		),
574
+		'html' => array(
575
+			'field_type'  =>  'html',
576
+			'class' =>  'gd-html',
577
+			'icon' =>  'fa fa-code',
578
+			'name'  =>  __('HTML', 'geodirectory'),
579
+			'description' =>  __('Adds a html input textarea', 'geodirectory')
580
+		),
581
+		'file' => array(
582
+			'field_type'  =>  'file',
583
+			'class' =>  'gd-file',
584
+			'icon' =>  'fa fa-file',
585
+			'name'  =>  __('File Upload', 'geodirectory'),
586
+			'description' =>  __('Adds a file input', 'geodirectory')
587
+		)
588
+	);
589
+
590
+	/**
591
+	 * Filter the custom fields array to be able to add or remove items.
592
+	 * 
593
+	 * @since 1.6.6
594
+	 *
595
+	 * @param array $custom_fields {
596
+	 *     The custom fields array to be filtered.
597
+	 *
598
+	 *     @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file.
599
+	 *     @type string $class The class for the field in backend.
600
+	 *     @type string $icon Can be font-awesome class name or icon image url.
601
+	 *     @type string $name The name of the field.
602
+	 *     @type string $description A short description about the field.
603
+	 *     @type array $defaults {
604
+	 *                    Optional. Used to set the default value of the field.
605
+	 *
606
+	 *                    @type string data_type The SQL data type for the field.
607
+	 *                    @type string admin_title The admin title for the field.
608
+	 *                    @type string site_title This will be the title for the field on the frontend.
609
+	 *                    @type string admin_desc This will be shown below the field on the add listing form.
610
+	 *                    @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.
611
+	 *                    @type bool is_active If false the field will not be displayed anywhere.
612
+	 *                    @type bool for_admin_use If true then only site admin can see and edit this field.
613
+	 *                    @type string default_value The default value for the input on the add listing page.
614
+	 *                    @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble]
615
+	 *                    @type bool is_required If true the field will be required on the add listing page.
616
+	 *                    @type string validation_pattern HTML5 validation pattern (text input only by default).
617
+	 *                    @type string validation_msg HTML5 validation message (text input only by default).
618
+	 *                    @type string required_msg Required warning message.
619
+	 *                    @type string field_icon Icon url or font awesome class.
620
+	 *                    @type string css_class Field custom css class for field custom style.
621
+	 *                    @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.
622
+	 *     }
623
+	 * }
624
+	 * @param string $post_type The post type requested.
625
+	 */
626
+	return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
627 627
 }
628 628
 
629 629
 /**
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
  */
635 635
 function geodir_custom_available_fields()
636 636
 {
637
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
638
-    ?>
637
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
638
+	?>
639 639
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
640 640
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
641 641
     <ul class="full gd-cf-tooltip-wrap">
@@ -652,30 +652,30 @@  discard block
 block discarded – undo
652 652
     </ul>
653 653
     <ul>
654 654
         <?php
655
-        $cfs = geodir_custom_fields($listing_type);
655
+		$cfs = geodir_custom_fields($listing_type);
656 656
 
657
-        foreach($cfs as $id=>$cf){
658
-            ?>
657
+		foreach($cfs as $id=>$cf){
658
+			?>
659 659
             <li   class="gd-cf-tooltip-wrap">
660 660
                 <?php
661
-                if(isset($cf['description']) && $cf['description']){
662
-                   echo '<div class="gdcf-tooltip">'.$cf['description'].'</div>';
663
-                }?>
661
+				if(isset($cf['description']) && $cf['description']){
662
+				   echo '<div class="gdcf-tooltip">'.$cf['description'].'</div>';
663
+				}?>
664 664
 
665 665
                 <a id="gd-<?php echo $id;?>" data-field-type-key="<?php echo $id;?>"  data-field-type="<?php echo $cf['field_type'];?>" class="gd-draggable-form-items <?php echo $cf['class'];?>" href="javascript:void(0);">
666 666
                     <?php if (isset($cf['icon']) && strpos($cf['icon'], 'fa fa-') !== false) {
667
-                        echo '<i class="'.$cf['icon'].'" aria-hidden="true"></i>';
668
-                    }elseif(isset($cf['icon']) && $cf['icon'] ){
669
-                        echo '<b style="background-image: url("'.$cf['icon'].'")"></b>';
670
-                    }else{
671
-                        echo '<i class="fa fa-cog" aria-hidden="true"></i>';
672
-                    }?>
667
+						echo '<i class="'.$cf['icon'].'" aria-hidden="true"></i>';
668
+					}elseif(isset($cf['icon']) && $cf['icon'] ){
669
+						echo '<b style="background-image: url("'.$cf['icon'].'")"></b>';
670
+					}else{
671
+						echo '<i class="fa fa-cog" aria-hidden="true"></i>';
672
+					}?>
673 673
                     <?php echo $cf['name'];?>
674 674
                 </a>
675 675
             </li>
676 676
         <?php
677
-        }
678
-        ?>
677
+		}
678
+		?>
679 679
 
680 680
 
681 681
     </ul>
@@ -694,26 +694,26 @@  discard block
 block discarded – undo
694 694
  */
695 695
 function geodir_custom_selected_fields()
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="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
700 700
     <ul class="core">
701 701
     <?php 
702
-        global $wpdb;
703
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
704
-
705
-        if (!empty($fields)) {
706
-            foreach ($fields as $field) {
707
-                //$result_str = $field->id;
708
-                $result_str = $field;
709
-                $field_type = $field->field_type;
710
-                $field_type_key = $field->field_type_key;
711
-                $field_ins_upd = 'display';
712
-
713
-                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key);
714
-            }
715
-        }
716
-        ?></ul>
702
+		global $wpdb;
703
+		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
704
+
705
+		if (!empty($fields)) {
706
+			foreach ($fields as $field) {
707
+				//$result_str = $field->id;
708
+				$result_str = $field;
709
+				$field_type = $field->field_type;
710
+				$field_type_key = $field->field_type_key;
711
+				$field_ins_upd = 'display';
712
+
713
+				geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key);
714
+			}
715
+		}
716
+		?></ul>
717 717
 <?php
718 718
 
719 719
 }
@@ -732,16 +732,16 @@  discard block
 block discarded – undo
732 732
 function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type)
733 733
 {
734 734
 
735
-    switch ($sub_tab) {
736
-        case 'custom_fields':
737
-            $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
738
-            break;
735
+	switch ($sub_tab) {
736
+		case 'custom_fields':
737
+			$heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
738
+			break;
739 739
 
740
-        case 'sorting_options':
741
-            $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
742
-            break;
743
-    }
744
-    return $heading;
740
+		case 'sorting_options':
741
+			$heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
742
+			break;
743
+	}
744
+	return $heading;
745 745
 }
746 746
 
747 747
 
@@ -759,16 +759,16 @@  discard block
 block discarded – undo
759 759
 function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type)
760 760
 {
761 761
 
762
-    switch ($sub_tab) {
763
-        case 'custom_fields':
764
-            $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
765
-            break;
762
+	switch ($sub_tab) {
763
+		case 'custom_fields':
764
+			$heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
765
+			break;
766 766
 
767
-        case 'sorting_options':
768
-            $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
769
-            break;
770
-    }
771
-    return $heading;
767
+		case 'sorting_options':
768
+			$heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
769
+			break;
770
+	}
771
+	return $heading;
772 772
 }
773 773
 
774 774
 
@@ -786,16 +786,16 @@  discard block
 block discarded – undo
786 786
 function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type)
787 787
 {
788 788
 
789
-    switch ($sub_tab) {
790
-        case 'custom_fields':
791
-            $note = sprintf(__('Click on any box below to add a field of that type on add %s listing form. You must be use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type));;
792
-            break;
789
+	switch ($sub_tab) {
790
+		case 'custom_fields':
791
+			$note = sprintf(__('Click on any box below to add a field of that type on add %s listing form. You must be use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type));;
792
+			break;
793 793
 
794
-        case 'sorting_options':
795
-            $note = sprintf(__('Click on any box below to make it appear in 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));
796
-            break;
797
-    }
798
-    return $note;
794
+		case 'sorting_options':
795
+			$note = sprintf(__('Click on any box below to make it appear in 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));
796
+			break;
797
+	}
798
+	return $note;
799 799
 }
800 800
 
801 801
 
@@ -813,16 +813,16 @@  discard block
 block discarded – undo
813 813
 function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type)
814 814
 {
815 815
 
816
-    switch ($sub_tab) {
817
-        case 'custom_fields':
818
-            $heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
819
-            break;
816
+	switch ($sub_tab) {
817
+		case 'custom_fields':
818
+			$heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
819
+			break;
820 820
 
821
-        case 'sorting_options':
822
-            $heading = sprintf(__('List of fields those will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
823
-            break;
824
-    }
825
-    return $heading;
821
+		case 'sorting_options':
822
+			$heading = sprintf(__('List of fields those will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
823
+			break;
824
+	}
825
+	return $heading;
826 826
 }
827 827
 
828 828
 
@@ -840,16 +840,16 @@  discard block
 block discarded – undo
840 840
 function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type)
841 841
 {
842 842
 
843
-    switch ($sub_tab) {
844
-        case 'custom_fields':
845
-            $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));;
846
-            break;
843
+	switch ($sub_tab) {
844
+		case 'custom_fields':
845
+			$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));;
846
+			break;
847 847
 
848
-        case 'sorting_options':
849
-            $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));
850
-            break;
851
-    }
852
-    return $note;
848
+		case 'sorting_options':
849
+			$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));
850
+			break;
851
+	}
852
+	return $note;
853 853
 }
854 854
 
855 855
 
@@ -865,16 +865,16 @@  discard block
 block discarded – undo
865 865
  */
866 866
 function geodir_remove_unnecessary_fields()
867 867
 {
868
-    global $wpdb, $plugin_prefix;
868
+	global $wpdb, $plugin_prefix;
869 869
 
870
-    if (!get_option('geodir_remove_unnecessary_fields')) {
870
+	if (!get_option('geodir_remove_unnecessary_fields')) {
871 871
 
872
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
873
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
872
+		if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
873
+			$wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
874 874
 
875
-        update_option('geodir_remove_unnecessary_fields', '1');
875
+		update_option('geodir_remove_unnecessary_fields', '1');
876 876
 
877
-    }
877
+	}
878 878
 
879 879
 }
880 880
 
@@ -892,25 +892,25 @@  discard block
 block discarded – undo
892 892
  */
893 893
 function geodir_admin_ajax_handler()
894 894
 {
895
-    if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
896
-        $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
897
-        switch ($geodir_admin_ajax_action) {
898
-            case 'diagnosis' :
899
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
900
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
901
-                call_user_func('geodir_diagnose_' . $diagnose_this);
902
-                exit();
903
-                break;
904
-
905
-            case 'diagnosis-fix' :
906
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
907
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
908
-                call_user_func('geodir_diagnose_' . $diagnose_this);
909
-                exit();
910
-                break;
911
-        }
912
-    }
913
-    exit();
895
+	if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
896
+		$geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
897
+		switch ($geodir_admin_ajax_action) {
898
+			case 'diagnosis' :
899
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
900
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
901
+				call_user_func('geodir_diagnose_' . $diagnose_this);
902
+				exit();
903
+				break;
904
+
905
+			case 'diagnosis-fix' :
906
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
907
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
908
+				call_user_func('geodir_diagnose_' . $diagnose_this);
909
+				exit();
910
+				break;
911
+		}
912
+	}
913
+	exit();
914 914
 }
915 915
 
916 916
 
@@ -928,127 +928,127 @@  discard block
 block discarded – undo
928 928
  */
929 929
 function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix)
930 930
 {
931
-    global $wpdb;
932
-    //$filter_arr['output_str'] .='###'.$table.'###';
933
-    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
934
-        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
935
-        $filter_arr['is_error_during_diagnose'] = true;
936
-
937
-    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
938
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
939
-        $filter_arr['is_error_during_diagnose'] = true;
940
-        $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>";
941
-        $filter_arr['is_error_during_diagnose'] = true;
942
-
943
-        if ($fix) {
944
-            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
945
-            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
946
-
947
-            if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
948
-                //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
949
-
950
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
951
-
952
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
953
-                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
954
-                } else {
955
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
956
-                }
957
-
958
-            } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
959
-
960
-                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
961
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
962
-
963
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
964
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
965
-                } else {
966
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
967
-                }
968
-
969
-            } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
970
-
971
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
972
-
973
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
974
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
975
-                } else {
976
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
977
-                }
978
-
979
-            }
980
-
981
-        }
982
-
983
-
984
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
985
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
986
-        $filter_arr['is_error_during_diagnose'] = true;
987
-
988
-        if ($fix) {
989
-            if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
990
-                if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
991
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
992
-                } else {
993
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
994
-                }
995
-
996
-            } 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
997
-                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
998
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
999
-                } else {
1000
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1001
-                }
1002
-                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1003
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1004
-                } else {
1005
-                    $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>";
1006
-                }
1007
-            } else {// else rename the original table to _ms_bak
1008
-                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1009
-                    $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>";
1010
-                } else {
1011
-                    $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>";
1012
-                }
1013
-            }
1014
-        }
1015
-
1016
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1017
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
1018
-        $filter_arr['is_error_during_diagnose'] = true;
1019
-
1020
-        if ($fix) {
1021
-            // if original table exists but new does not, rename
1022
-            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1023
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1024
-            } else {
1025
-                $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>";
1026
-            }
1027
-
1028
-        }
1029
-
1030
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1031
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
1032
-        $filter_arr['is_error_during_diagnose'] = true;
1033
-
1034
-        if ($fix) {
1035
-            // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
1036
-            delete_option('geodirlocation_db_version');
1037
-            delete_option('geodirevents_db_version');
1038
-            delete_option('geodir_reviewrating_db_version');
1039
-            delete_option('gdevents_db_version');
1040
-            delete_option('geodirectory_db_version');
1041
-            delete_option('geodirclaim_db_version');
1042
-            delete_option('geodir_custom_posts_db_version');
1043
-            delete_option('geodir_reviewratings_db_version');
1044
-            delete_option('geodiradvancesearch_db_version');
1045
-            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
1046
-        }
1047
-
1048
-    } else {
1049
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
1050
-    }
1051
-    return $filter_arr;
931
+	global $wpdb;
932
+	//$filter_arr['output_str'] .='###'.$table.'###';
933
+	if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
934
+		$filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
935
+		$filter_arr['is_error_during_diagnose'] = true;
936
+
937
+	} elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
938
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
939
+		$filter_arr['is_error_during_diagnose'] = true;
940
+		$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>";
941
+		$filter_arr['is_error_during_diagnose'] = true;
942
+
943
+		if ($fix) {
944
+			$ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
945
+			$new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
946
+
947
+			if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
948
+				//$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
949
+
950
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
951
+
952
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
953
+					$filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
954
+				} else {
955
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
956
+				}
957
+
958
+			} elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
959
+
960
+				$wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
961
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
962
+
963
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
964
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
965
+				} else {
966
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
967
+				}
968
+
969
+			} elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
970
+
971
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
972
+
973
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
974
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
975
+				} else {
976
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
977
+				}
978
+
979
+			}
980
+
981
+		}
982
+
983
+
984
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
985
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
986
+		$filter_arr['is_error_during_diagnose'] = true;
987
+
988
+		if ($fix) {
989
+			if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
990
+				if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
991
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
992
+				} else {
993
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
994
+				}
995
+
996
+			} 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
997
+				if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
998
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
999
+				} else {
1000
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1001
+				}
1002
+				if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1003
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1004
+				} else {
1005
+					$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>";
1006
+				}
1007
+			} else {// else rename the original table to _ms_bak
1008
+				if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1009
+					$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>";
1010
+				} else {
1011
+					$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>";
1012
+				}
1013
+			}
1014
+		}
1015
+
1016
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1017
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
1018
+		$filter_arr['is_error_during_diagnose'] = true;
1019
+
1020
+		if ($fix) {
1021
+			// if original table exists but new does not, rename
1022
+			if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1023
+				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1024
+			} else {
1025
+				$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>";
1026
+			}
1027
+
1028
+		}
1029
+
1030
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1031
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
1032
+		$filter_arr['is_error_during_diagnose'] = true;
1033
+
1034
+		if ($fix) {
1035
+			// if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
1036
+			delete_option('geodirlocation_db_version');
1037
+			delete_option('geodirevents_db_version');
1038
+			delete_option('geodir_reviewrating_db_version');
1039
+			delete_option('gdevents_db_version');
1040
+			delete_option('geodirectory_db_version');
1041
+			delete_option('geodirclaim_db_version');
1042
+			delete_option('geodir_custom_posts_db_version');
1043
+			delete_option('geodir_reviewratings_db_version');
1044
+			delete_option('geodiradvancesearch_db_version');
1045
+			$filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
1046
+		}
1047
+
1048
+	} else {
1049
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
1050
+	}
1051
+	return $filter_arr;
1052 1052
 }
1053 1053
 
1054 1054
 
@@ -1062,53 +1062,53 @@  discard block
 block discarded – undo
1062 1062
  */
1063 1063
 function geodir_diagnose_tags_sync()
1064 1064
 {
1065
-    global $wpdb, $plugin_prefix;
1066
-    $fix = isset($_POST['fix']) ? true : false;
1067
-
1068
-    //if($fix){echo 'true';}else{echo 'false';}
1069
-    $is_error_during_diagnose = false;
1070
-    $output_str = '';
1071
-
1072
-
1073
-    $all_postypes = geodir_get_posttypes();
1074
-
1075
-    if (!empty($all_postypes)) {
1076
-        foreach ($all_postypes as $key) {
1077
-            // update each GD CPT
1078
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
1079
-
1080
-            if (!empty($posts)) {
1081
-
1082
-                foreach ($posts as $p) {
1083
-                    $p->post_type = $key;
1084
-                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1085
-                    if (empty($raw_tags)) {
1086
-                        $post_tags = '';
1087
-                    } else {
1088
-                        $post_tags = implode(",", $raw_tags);
1089
-                    }
1090
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1091
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1092
-
1093
-                }
1094
-                $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1095
-            }
1096
-
1097
-        }
1098
-
1099
-    }
1100
-
1101
-    if ($is_error_during_diagnose) {
1102
-        $info_div_class = "geodir_problem_info";
1103
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1104
-    } else {
1105
-        $info_div_class = "geodir_noproblem_info";
1106
-        $fix_button_txt = '';
1107
-    }
1108
-    echo "<ul class='$info_div_class'>";
1109
-    echo $output_str;
1110
-    echo $fix_button_txt;
1111
-    echo "</ul>";
1065
+	global $wpdb, $plugin_prefix;
1066
+	$fix = isset($_POST['fix']) ? true : false;
1067
+
1068
+	//if($fix){echo 'true';}else{echo 'false';}
1069
+	$is_error_during_diagnose = false;
1070
+	$output_str = '';
1071
+
1072
+
1073
+	$all_postypes = geodir_get_posttypes();
1074
+
1075
+	if (!empty($all_postypes)) {
1076
+		foreach ($all_postypes as $key) {
1077
+			// update each GD CPT
1078
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
1079
+
1080
+			if (!empty($posts)) {
1081
+
1082
+				foreach ($posts as $p) {
1083
+					$p->post_type = $key;
1084
+					$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1085
+					if (empty($raw_tags)) {
1086
+						$post_tags = '';
1087
+					} else {
1088
+						$post_tags = implode(",", $raw_tags);
1089
+					}
1090
+					$tablename = $plugin_prefix . $p->post_type . '_detail';
1091
+					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1092
+
1093
+				}
1094
+				$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1095
+			}
1096
+
1097
+		}
1098
+
1099
+	}
1100
+
1101
+	if ($is_error_during_diagnose) {
1102
+		$info_div_class = "geodir_problem_info";
1103
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1104
+	} else {
1105
+		$info_div_class = "geodir_noproblem_info";
1106
+		$fix_button_txt = '';
1107
+	}
1108
+	echo "<ul class='$info_div_class'>";
1109
+	echo $output_str;
1110
+	echo $fix_button_txt;
1111
+	echo "</ul>";
1112 1112
 
1113 1113
 }
1114 1114
 
@@ -1124,75 +1124,75 @@  discard block
 block discarded – undo
1124 1124
  */
1125 1125
 function geodir_diagnose_cats_sync()
1126 1126
 {
1127
-    global $wpdb, $plugin_prefix;
1128
-    $fix = isset($_POST['fix']) ? true : false;
1127
+	global $wpdb, $plugin_prefix;
1128
+	$fix = isset($_POST['fix']) ? true : false;
1129 1129
 
1130
-    //if($fix){echo 'true';}else{echo 'false';}
1131
-    $is_error_during_diagnose = false;
1132
-    $output_str = '';
1130
+	//if($fix){echo 'true';}else{echo 'false';}
1131
+	$is_error_during_diagnose = false;
1132
+	$output_str = '';
1133 1133
 
1134 1134
 
1135
-    $all_postypes = geodir_get_posttypes();
1135
+	$all_postypes = geodir_get_posttypes();
1136 1136
 
1137
-    if (!empty($all_postypes)) {
1138
-        foreach ($all_postypes as $key) {
1139
-            // update each GD CTP
1140
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
1137
+	if (!empty($all_postypes)) {
1138
+		foreach ($all_postypes as $key) {
1139
+			// update each GD CTP
1140
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
1141 1141
 
1142
-            if (!empty($posts)) {
1142
+			if (!empty($posts)) {
1143 1143
 
1144
-                foreach ($posts as $p) {
1145
-                    $p->post_type = $key;
1146
-                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
1144
+				foreach ($posts as $p) {
1145
+					$p->post_type = $key;
1146
+					$raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
1147 1147
 
1148
-                    if (empty($raw_cats)) {
1149
-                        $post_categories = get_post_meta($p->post_id, 'post_categories', true);
1148
+					if (empty($raw_cats)) {
1149
+						$post_categories = get_post_meta($p->post_id, 'post_categories', true);
1150 1150
 
1151
-                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1152
-                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1153
-                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1154
-                                if (is_numeric($cat_part)) {
1155
-                                    $raw_cats[] = (int)$cat_part;
1156
-                                }
1157
-                            }
1151
+						if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1152
+							$post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1153
+							foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1154
+								if (is_numeric($cat_part)) {
1155
+									$raw_cats[] = (int)$cat_part;
1156
+								}
1157
+							}
1158 1158
 
1159
-                        }
1159
+						}
1160 1160
 
1161
-                        if (!empty($raw_cats)) {
1162
-                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1161
+						if (!empty($raw_cats)) {
1162
+							$term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1163 1163
 
1164
-                        }
1164
+						}
1165 1165
 
1166
-                    }
1166
+					}
1167 1167
 
1168 1168
 
1169
-                    if (empty($raw_cats)) {
1170
-                        $post_cats = '';
1171
-                    } else {
1172
-                        $post_cats = ',' . implode(",", $raw_cats) . ',';
1173
-                    }
1174
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1175
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1176
-                }
1169
+					if (empty($raw_cats)) {
1170
+						$post_cats = '';
1171
+					} else {
1172
+						$post_cats = ',' . implode(",", $raw_cats) . ',';
1173
+					}
1174
+					$tablename = $plugin_prefix . $p->post_type . '_detail';
1175
+					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1176
+				}
1177 1177
 
1178
-            }
1179
-            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1178
+			}
1179
+			$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1180 1180
 
1181
-        }
1181
+		}
1182 1182
 
1183
-    }
1183
+	}
1184 1184
 
1185
-    if ($is_error_during_diagnose) {
1186
-        $info_div_class = "geodir_problem_info";
1187
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1188
-    } else {
1189
-        $info_div_class = "geodir_noproblem_info";
1190
-        $fix_button_txt = '';
1191
-    }
1192
-    echo "<ul class='$info_div_class'>";
1193
-    echo $output_str;
1194
-    echo $fix_button_txt;
1195
-    echo "</ul>";
1185
+	if ($is_error_during_diagnose) {
1186
+		$info_div_class = "geodir_problem_info";
1187
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1188
+	} else {
1189
+		$info_div_class = "geodir_noproblem_info";
1190
+		$fix_button_txt = '';
1191
+	}
1192
+	echo "<ul class='$info_div_class'>";
1193
+	echo $output_str;
1194
+	echo $fix_button_txt;
1195
+	echo "</ul>";
1196 1196
 
1197 1197
 }
1198 1198
 
@@ -1206,61 +1206,61 @@  discard block
 block discarded – undo
1206 1206
  */
1207 1207
 function geodir_diagnose_version_clear()
1208 1208
 {
1209
-    global $wpdb, $plugin_prefix;
1210
-    $fix = isset($_POST['fix']) ? true : false;
1211
-
1212
-    //if($fix){echo 'true';}else{echo 'false';}
1213
-    $is_error_during_diagnose = false;
1214
-    $output_str = '';
1215
-
1216
-
1217
-    $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1218
-        'Payment Manager' => 'geodir_payments_db_version',
1219
-        'GeoDirectory Framework' => 'gdf_db_version',
1220
-        'Advanced Search' => 'geodiradvancesearch_db_version',
1221
-        'Review Rating Manager' => 'geodir_reviewratings_db_version',
1222
-        'Claim Manager' => 'geodirclaim_db_version',
1223
-        'CPT Manager' => 'geodir_custom_posts_db_version',
1224
-        'Location Manager' => 'geodirlocation_db_version',
1225
-        'Payment Manager' => 'geodir_payments_db_version',
1226
-        'Events Manager' => 'geodirevents_db_version',
1227
-    );
1228
-
1229
-    /**
1230
-     * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1231
-     *
1232
-     * @since 1.0.0
1233
-     * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1234
-     */
1235
-    $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1236
-
1237
-    if (!empty($ver_arr)) {
1238
-        foreach ($ver_arr as $key => $val) {
1239
-            if (delete_option($val)) {
1240
-                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1241
-            } else {
1242
-                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1243
-            }
1244
-
1245
-        }
1246
-
1247
-        if ($output_str) {
1248
-            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1249
-        }
1250
-
1251
-    }
1252
-
1253
-    if ($is_error_during_diagnose) {
1254
-        $info_div_class = "geodir_problem_info";
1255
-        $fix_button_txt = "";
1256
-    } else {
1257
-        $info_div_class = "geodir_noproblem_info";
1258
-        $fix_button_txt = '';
1259
-    }
1260
-    echo "<ul class='$info_div_class'>";
1261
-    echo $output_str;
1262
-    echo $fix_button_txt;
1263
-    echo "</ul>";
1209
+	global $wpdb, $plugin_prefix;
1210
+	$fix = isset($_POST['fix']) ? true : false;
1211
+
1212
+	//if($fix){echo 'true';}else{echo 'false';}
1213
+	$is_error_during_diagnose = false;
1214
+	$output_str = '';
1215
+
1216
+
1217
+	$gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1218
+		'Payment Manager' => 'geodir_payments_db_version',
1219
+		'GeoDirectory Framework' => 'gdf_db_version',
1220
+		'Advanced Search' => 'geodiradvancesearch_db_version',
1221
+		'Review Rating Manager' => 'geodir_reviewratings_db_version',
1222
+		'Claim Manager' => 'geodirclaim_db_version',
1223
+		'CPT Manager' => 'geodir_custom_posts_db_version',
1224
+		'Location Manager' => 'geodirlocation_db_version',
1225
+		'Payment Manager' => 'geodir_payments_db_version',
1226
+		'Events Manager' => 'geodirevents_db_version',
1227
+	);
1228
+
1229
+	/**
1230
+	 * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1231
+	 *
1232
+	 * @since 1.0.0
1233
+	 * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1234
+	 */
1235
+	$ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1236
+
1237
+	if (!empty($ver_arr)) {
1238
+		foreach ($ver_arr as $key => $val) {
1239
+			if (delete_option($val)) {
1240
+				$output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1241
+			} else {
1242
+				$output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1243
+			}
1244
+
1245
+		}
1246
+
1247
+		if ($output_str) {
1248
+			$output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1249
+		}
1250
+
1251
+	}
1252
+
1253
+	if ($is_error_during_diagnose) {
1254
+		$info_div_class = "geodir_problem_info";
1255
+		$fix_button_txt = "";
1256
+	} else {
1257
+		$info_div_class = "geodir_noproblem_info";
1258
+		$fix_button_txt = '';
1259
+	}
1260
+	echo "<ul class='$info_div_class'>";
1261
+	echo $output_str;
1262
+	echo $fix_button_txt;
1263
+	echo "</ul>";
1264 1264
 
1265 1265
 }
1266 1266
 
@@ -1274,59 +1274,59 @@  discard block
 block discarded – undo
1274 1274
  */
1275 1275
 function geodir_diagnose_ratings()
1276 1276
 {
1277
-    global $wpdb;
1278
-    $fix = isset($_POST['fix']) ? true : false;
1279
-
1280
-    //if($fix){echo 'true';}else{echo 'false';}
1281
-    $is_error_during_diagnose = false;
1282
-    $output_str = '';
1283
-
1284
-    // check review locations
1285
-    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")) {
1286
-        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1287
-        $is_error_during_diagnose = true;
1288
-
1289
-        if ($fix) {
1290
-            if (geodir_fix_review_location()) {
1291
-                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1292
-            } else {
1293
-                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1294
-            }
1295
-        }
1296
-
1297
-    } else {
1298
-        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1299
-    }
1300
-
1301
-    // check review content
1302
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1303
-        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1304
-        $is_error_during_diagnose = true;
1305
-
1306
-        if ($fix) {
1307
-            if (geodir_fix_review_content()) {
1308
-                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1309
-            } else {
1310
-                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1311
-            }
1312
-        }
1313
-
1314
-    } else {
1315
-        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1316
-    }
1317
-
1318
-
1319
-    if ($is_error_during_diagnose) {
1320
-        $info_div_class = "geodir_problem_info";
1321
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1322
-    } else {
1323
-        $info_div_class = "geodir_noproblem_info";
1324
-        $fix_button_txt = '';
1325
-    }
1326
-    echo "<ul class='$info_div_class'>";
1327
-    echo $output_str;
1328
-    echo $fix_button_txt;
1329
-    echo "</ul>";
1277
+	global $wpdb;
1278
+	$fix = isset($_POST['fix']) ? true : false;
1279
+
1280
+	//if($fix){echo 'true';}else{echo 'false';}
1281
+	$is_error_during_diagnose = false;
1282
+	$output_str = '';
1283
+
1284
+	// check review locations
1285
+	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")) {
1286
+		$output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1287
+		$is_error_during_diagnose = true;
1288
+
1289
+		if ($fix) {
1290
+			if (geodir_fix_review_location()) {
1291
+				$output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1292
+			} else {
1293
+				$output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1294
+			}
1295
+		}
1296
+
1297
+	} else {
1298
+		$output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1299
+	}
1300
+
1301
+	// check review content
1302
+	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1303
+		$output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1304
+		$is_error_during_diagnose = true;
1305
+
1306
+		if ($fix) {
1307
+			if (geodir_fix_review_content()) {
1308
+				$output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1309
+			} else {
1310
+				$output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1311
+			}
1312
+		}
1313
+
1314
+	} else {
1315
+		$output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1316
+	}
1317
+
1318
+
1319
+	if ($is_error_during_diagnose) {
1320
+		$info_div_class = "geodir_problem_info";
1321
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1322
+	} else {
1323
+		$info_div_class = "geodir_noproblem_info";
1324
+		$fix_button_txt = '';
1325
+	}
1326
+	echo "<ul class='$info_div_class'>";
1327
+	echo $output_str;
1328
+	echo $fix_button_txt;
1329
+	echo "</ul>";
1330 1330
 
1331 1331
 }
1332 1332
 
@@ -1340,57 +1340,57 @@  discard block
 block discarded – undo
1340 1340
  */
1341 1341
 function geodir_diagnose_multisite_conversion()
1342 1342
 {
1343
-    global $wpdb;
1344
-    $fix = isset($_POST['fix']) ? true : false;
1345
-    //if($fix){echo 'true';}else{echo 'false';}
1346
-    $is_error_during_diagnose = false;
1347
-    $output_str = '';
1348
-
1349
-    $filter_arr = array();
1350
-    $filter_arr['output_str'] = $output_str;
1351
-    $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1352
-    $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1353
-        'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1354
-        'geodir_post_icon' => __('Post icon', 'geodirectory'),
1355
-        'geodir_attachments' => __('Attachments', 'geodirectory'),
1356
-        'geodir_post_review' => __('Reviews', 'geodirectory'),
1357
-        'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1358
-        'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1359
-    );
1360
-
1361
-    // allow other addons to hook in and add their checks
1362
-
1363
-    /**
1364
-     * Filter the array of tables.
1365
-     *
1366
-     * 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.
1367
-     *
1368
-     * @since 1.0.0
1369
-     * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1370
-     */
1371
-    $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1372
-
1373
-    foreach ($table_arr as $table => $table_name) {
1374
-        // Diagnose table
1375
-        $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1376
-    }
1377
-
1378
-
1379
-    $output_str = $filter_arr['output_str'];
1380
-    $is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1381
-
1382
-
1383
-    if ($is_error_during_diagnose) {
1384
-        $info_div_class = "geodir_problem_info";
1385
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1386
-    } else {
1387
-        $info_div_class = "geodir_noproblem_info";
1388
-        $fix_button_txt = '';
1389
-    }
1390
-    echo "<ul class='$info_div_class'>";
1391
-    echo $output_str;
1392
-    echo $fix_button_txt;
1393
-    echo "</ul>";
1343
+	global $wpdb;
1344
+	$fix = isset($_POST['fix']) ? true : false;
1345
+	//if($fix){echo 'true';}else{echo 'false';}
1346
+	$is_error_during_diagnose = false;
1347
+	$output_str = '';
1348
+
1349
+	$filter_arr = array();
1350
+	$filter_arr['output_str'] = $output_str;
1351
+	$filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1352
+	$table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1353
+		'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1354
+		'geodir_post_icon' => __('Post icon', 'geodirectory'),
1355
+		'geodir_attachments' => __('Attachments', 'geodirectory'),
1356
+		'geodir_post_review' => __('Reviews', 'geodirectory'),
1357
+		'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1358
+		'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1359
+	);
1360
+
1361
+	// allow other addons to hook in and add their checks
1362
+
1363
+	/**
1364
+	 * Filter the array of tables.
1365
+	 *
1366
+	 * 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.
1367
+	 *
1368
+	 * @since 1.0.0
1369
+	 * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1370
+	 */
1371
+	$table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1372
+
1373
+	foreach ($table_arr as $table => $table_name) {
1374
+		// Diagnose table
1375
+		$filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1376
+	}
1377
+
1378
+
1379
+	$output_str = $filter_arr['output_str'];
1380
+	$is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1381
+
1382
+
1383
+	if ($is_error_during_diagnose) {
1384
+		$info_div_class = "geodir_problem_info";
1385
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1386
+	} else {
1387
+		$info_div_class = "geodir_noproblem_info";
1388
+		$fix_button_txt = '';
1389
+	}
1390
+	echo "<ul class='$info_div_class'>";
1391
+	echo $output_str;
1392
+	echo $fix_button_txt;
1393
+	echo "</ul>";
1394 1394
 }
1395 1395
 
1396 1396
 /**
@@ -1408,39 +1408,39 @@  discard block
 block discarded – undo
1408 1408
  */
1409 1409
 function geodir_fix_virtual_page($slug, $page_title, $old_id, $option)
1410 1410
 {
1411
-    global $wpdb, $current_user;
1412
-
1413
-    if (!empty($old_id)) {
1414
-        wp_delete_post($old_id, true);
1415
-    }//delete post if already there
1416
-    else {
1417
-        $page_found = $wpdb->get_var(
1418
-            $wpdb->prepare(
1419
-                "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1420
-                array($slug)
1421
-            )
1422
-        );
1423
-        wp_delete_post($page_found, true);
1424
-
1425
-    }
1426
-
1427
-    $page_data = array(
1428
-        'post_status' => 'publish',
1429
-        'post_type' => 'page',
1430
-        'post_author' => $current_user->ID,
1431
-        'post_name' => $slug,
1432
-        'post_title' => $page_title,
1433
-        'post_content' => '',
1434
-        'post_parent' => 0,
1435
-        'comment_status' => 'closed'
1436
-    );
1437
-    $page_id = wp_insert_post($page_data);
1438
-    update_option($option, $page_id);
1439
-    if ($page_id) {
1440
-        return true;
1441
-    } else {
1442
-        return false;
1443
-    }
1411
+	global $wpdb, $current_user;
1412
+
1413
+	if (!empty($old_id)) {
1414
+		wp_delete_post($old_id, true);
1415
+	}//delete post if already there
1416
+	else {
1417
+		$page_found = $wpdb->get_var(
1418
+			$wpdb->prepare(
1419
+				"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1420
+				array($slug)
1421
+			)
1422
+		);
1423
+		wp_delete_post($page_found, true);
1424
+
1425
+	}
1426
+
1427
+	$page_data = array(
1428
+		'post_status' => 'publish',
1429
+		'post_type' => 'page',
1430
+		'post_author' => $current_user->ID,
1431
+		'post_name' => $slug,
1432
+		'post_title' => $page_title,
1433
+		'post_content' => '',
1434
+		'post_parent' => 0,
1435
+		'comment_status' => 'closed'
1436
+	);
1437
+	$page_id = wp_insert_post($page_data);
1438
+	update_option($option, $page_id);
1439
+	if ($page_id) {
1440
+		return true;
1441
+	} else {
1442
+		return false;
1443
+	}
1444 1444
 }
1445 1445
 
1446 1446
 /**
@@ -1452,212 +1452,212 @@  discard block
 block discarded – undo
1452 1452
  */
1453 1453
 function geodir_diagnose_default_pages()
1454 1454
 {
1455
-    global $wpdb;
1456
-    $is_error_during_diagnose = false;
1457
-    $output_str = '';
1458
-    $fix = isset($_POST['fix']) ? true : false;
1459
-
1460
-    //////////////////////////////////
1461
-    /* Diagnose GD Home Page Starts */
1462
-    //////////////////////////////////
1463
-    $option_value = get_option('geodir_home_page');
1464
-    $page = get_post($option_value);
1465
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1466
-
1467
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1468
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1469
-    else {
1470
-        $is_error_during_diagnose = true;
1471
-        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1472
-        if ($fix) {
1473
-            if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1474
-                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1475
-            } else {
1476
-                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1477
-            }
1478
-        }
1479
-    }
1480
-
1481
-    ////////////////////////////////
1482
-    /* Diagnose GD Home Page Ends */
1483
-    ////////////////////////////////
1484
-
1485
-    //////////////////////////////////
1486
-    /* Diagnose Add Listing Page Starts */
1487
-    //////////////////////////////////
1488
-    $option_value = get_option('geodir_add_listing_page');
1489
-    $page = get_post($option_value);
1490
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1491
-
1492
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1493
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1494
-    else {
1495
-        $is_error_during_diagnose = true;
1496
-        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1497
-        if ($fix) {
1498
-            if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1499
-                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1500
-            } else {
1501
-                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1502
-            }
1503
-        }
1504
-    }
1505
-
1506
-    ////////////////////////////////
1507
-    /* Diagnose Add Listing Page Ends */
1508
-    ////////////////////////////////
1509
-
1510
-
1511
-    //////////////////////////////////
1512
-    /* Diagnose Listing Preview Page Starts */
1513
-    //////////////////////////////////
1514
-    $option_value = get_option('geodir_preview_page');
1515
-    $page = get_post($option_value);
1516
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1517
-
1518
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1519
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1520
-    else {
1521
-        $is_error_during_diagnose = true;
1522
-        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1523
-        if ($fix) {
1524
-            if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1525
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1526
-            } else {
1527
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1528
-            }
1529
-        }
1530
-    }
1531
-
1532
-    ////////////////////////////////
1533
-    /* Diagnose Listing Preview Page Ends */
1534
-    ////////////////////////////////
1535
-
1536
-    //////////////////////////////////
1537
-    /* Diagnose Listing Success Page Starts */
1538
-    //////////////////////////////////
1539
-    $option_value = get_option('geodir_success_page');
1540
-    $page = get_post($option_value);
1541
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1542
-
1543
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1544
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1545
-    else {
1546
-        $is_error_during_diagnose = true;
1547
-        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1548
-        if ($fix) {
1549
-            if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1550
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1551
-            } else {
1552
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1553
-            }
1554
-        }
1555
-    }
1556
-
1557
-    ////////////////////////////////
1558
-    /* Diagnose Listing Sucess Page Ends */
1559
-    ////////////////////////////////
1560
-
1561
-    //////////////////////////////////
1562
-    /* Diagnose Info Page Starts */
1563
-    //////////////////////////////////
1564
-    $option_value = get_option('geodir_info_page');
1565
-    $page = get_post($option_value);
1566
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1567
-
1568
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1569
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1570
-    else {
1571
-        $is_error_during_diagnose = true;
1572
-        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1573
-        if ($fix) {
1574
-            if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1575
-                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1576
-            } else {
1577
-                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1578
-            }
1579
-        }
1580
-    }
1581
-
1582
-    ////////////////////////////////
1583
-    /* Diagnose Info Page Ends */
1584
-    ////////////////////////////////
1585
-
1586
-    //////////////////////////////////
1587
-    /* Diagnose Login Page Starts */
1588
-    //////////////////////////////////
1589
-    $option_value = get_option('geodir_login_page');
1590
-    $page = get_post($option_value);
1591
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1592
-
1593
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1594
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1595
-    else {
1596
-        $is_error_during_diagnose = true;
1597
-        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1598
-        if ($fix) {
1599
-            if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1600
-                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1601
-            } else {
1602
-                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1603
-            }
1604
-        }
1605
-    }
1606
-
1607
-    ////////////////////////////////
1608
-    /* Diagnose Info Page Ends */
1609
-    ////////////////////////////////
1610
-
1611
-    //////////////////////////////////
1612
-    /* Diagnose Location Page Starts */
1613
-    //////////////////////////////////
1614
-    $option_value = get_option('geodir_location_page');
1615
-    $page = get_post($option_value);
1616
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1617
-
1618
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1619
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1620
-    else {
1621
-        $is_error_during_diagnose = true;
1622
-        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1623
-        if ($fix) {
1624
-            if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1625
-                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1626
-            } else {
1627
-                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1628
-            }
1629
-        }
1630
-    }
1631
-
1632
-    ////////////////////////////////
1633
-    /* Diagnose Location Page Ends */
1634
-    ////////////////////////////////
1635
-
1636
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1637
-    /**
1638
-     * This action is called at the end of the GD Tools page check function.
1639
-     *
1640
-     * @since 1.5.2
1641
-     */
1642
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1643
-
1644
-    $output_str = $page_chk_arr['output_str'];
1645
-    $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1646
-
1647
-    if ($is_error_during_diagnose) {
1648
-        if ($fix) {
1649
-            flush_rewrite_rules();
1650
-        }
1651
-        $info_div_class = "geodir_problem_info";
1652
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1653
-    } else {
1654
-        $info_div_class = "geodir_noproblem_info";
1655
-        $fix_button_txt = '';
1656
-    }
1657
-    echo "<ul class='$info_div_class'>";
1658
-    echo $output_str;
1659
-    echo $fix_button_txt;
1660
-    echo "</ul>";
1455
+	global $wpdb;
1456
+	$is_error_during_diagnose = false;
1457
+	$output_str = '';
1458
+	$fix = isset($_POST['fix']) ? true : false;
1459
+
1460
+	//////////////////////////////////
1461
+	/* Diagnose GD Home Page Starts */
1462
+	//////////////////////////////////
1463
+	$option_value = get_option('geodir_home_page');
1464
+	$page = get_post($option_value);
1465
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1466
+
1467
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1468
+		$output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1469
+	else {
1470
+		$is_error_during_diagnose = true;
1471
+		$output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1472
+		if ($fix) {
1473
+			if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1474
+				$output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1475
+			} else {
1476
+				$output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1477
+			}
1478
+		}
1479
+	}
1480
+
1481
+	////////////////////////////////
1482
+	/* Diagnose GD Home Page Ends */
1483
+	////////////////////////////////
1484
+
1485
+	//////////////////////////////////
1486
+	/* Diagnose Add Listing Page Starts */
1487
+	//////////////////////////////////
1488
+	$option_value = get_option('geodir_add_listing_page');
1489
+	$page = get_post($option_value);
1490
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1491
+
1492
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1493
+		$output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1494
+	else {
1495
+		$is_error_during_diagnose = true;
1496
+		$output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1497
+		if ($fix) {
1498
+			if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1499
+				$output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1500
+			} else {
1501
+				$output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1502
+			}
1503
+		}
1504
+	}
1505
+
1506
+	////////////////////////////////
1507
+	/* Diagnose Add Listing Page Ends */
1508
+	////////////////////////////////
1509
+
1510
+
1511
+	//////////////////////////////////
1512
+	/* Diagnose Listing Preview Page Starts */
1513
+	//////////////////////////////////
1514
+	$option_value = get_option('geodir_preview_page');
1515
+	$page = get_post($option_value);
1516
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1517
+
1518
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1519
+		$output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1520
+	else {
1521
+		$is_error_during_diagnose = true;
1522
+		$output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1523
+		if ($fix) {
1524
+			if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1525
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1526
+			} else {
1527
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1528
+			}
1529
+		}
1530
+	}
1531
+
1532
+	////////////////////////////////
1533
+	/* Diagnose Listing Preview Page Ends */
1534
+	////////////////////////////////
1535
+
1536
+	//////////////////////////////////
1537
+	/* Diagnose Listing Success Page Starts */
1538
+	//////////////////////////////////
1539
+	$option_value = get_option('geodir_success_page');
1540
+	$page = get_post($option_value);
1541
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1542
+
1543
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1544
+		$output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1545
+	else {
1546
+		$is_error_during_diagnose = true;
1547
+		$output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1548
+		if ($fix) {
1549
+			if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1550
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1551
+			} else {
1552
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1553
+			}
1554
+		}
1555
+	}
1556
+
1557
+	////////////////////////////////
1558
+	/* Diagnose Listing Sucess Page Ends */
1559
+	////////////////////////////////
1560
+
1561
+	//////////////////////////////////
1562
+	/* Diagnose Info Page Starts */
1563
+	//////////////////////////////////
1564
+	$option_value = get_option('geodir_info_page');
1565
+	$page = get_post($option_value);
1566
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1567
+
1568
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1569
+		$output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1570
+	else {
1571
+		$is_error_during_diagnose = true;
1572
+		$output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1573
+		if ($fix) {
1574
+			if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1575
+				$output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1576
+			} else {
1577
+				$output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1578
+			}
1579
+		}
1580
+	}
1581
+
1582
+	////////////////////////////////
1583
+	/* Diagnose Info Page Ends */
1584
+	////////////////////////////////
1585
+
1586
+	//////////////////////////////////
1587
+	/* Diagnose Login Page Starts */
1588
+	//////////////////////////////////
1589
+	$option_value = get_option('geodir_login_page');
1590
+	$page = get_post($option_value);
1591
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1592
+
1593
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1594
+		$output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1595
+	else {
1596
+		$is_error_during_diagnose = true;
1597
+		$output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1598
+		if ($fix) {
1599
+			if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1600
+				$output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1601
+			} else {
1602
+				$output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1603
+			}
1604
+		}
1605
+	}
1606
+
1607
+	////////////////////////////////
1608
+	/* Diagnose Info Page Ends */
1609
+	////////////////////////////////
1610
+
1611
+	//////////////////////////////////
1612
+	/* Diagnose Location Page Starts */
1613
+	//////////////////////////////////
1614
+	$option_value = get_option('geodir_location_page');
1615
+	$page = get_post($option_value);
1616
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1617
+
1618
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1619
+		$output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1620
+	else {
1621
+		$is_error_during_diagnose = true;
1622
+		$output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1623
+		if ($fix) {
1624
+			if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1625
+				$output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1626
+			} else {
1627
+				$output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1628
+			}
1629
+		}
1630
+	}
1631
+
1632
+	////////////////////////////////
1633
+	/* Diagnose Location Page Ends */
1634
+	////////////////////////////////
1635
+
1636
+	$page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1637
+	/**
1638
+	 * This action is called at the end of the GD Tools page check function.
1639
+	 *
1640
+	 * @since 1.5.2
1641
+	 */
1642
+	$page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1643
+
1644
+	$output_str = $page_chk_arr['output_str'];
1645
+	$is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1646
+
1647
+	if ($is_error_during_diagnose) {
1648
+		if ($fix) {
1649
+			flush_rewrite_rules();
1650
+		}
1651
+		$info_div_class = "geodir_problem_info";
1652
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1653
+	} else {
1654
+		$info_div_class = "geodir_noproblem_info";
1655
+		$fix_button_txt = '';
1656
+	}
1657
+	echo "<ul class='$info_div_class'>";
1658
+	echo $output_str;
1659
+	echo $fix_button_txt;
1660
+	echo "</ul>";
1661 1661
 
1662 1662
 }
1663 1663
 
@@ -1669,26 +1669,26 @@  discard block
 block discarded – undo
1669 1669
  * @global object $wpdb WordPress Database object.
1670 1670
  */
1671 1671
 function geodir_diagnose_load_db_language() {
1672
-    global $wpdb;
1672
+	global $wpdb;
1673 1673
 	
1674 1674
 	$is_error_during_diagnose = geodirectory_load_db_language();
1675 1675
 
1676
-    $output_str = '';
1677
-    $fix_button_txt = '';
1676
+	$output_str = '';
1677
+	$fix_button_txt = '';
1678 1678
 
1679
-    if ($is_error_during_diagnose) {
1680
-        $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>";
1679
+	if ($is_error_during_diagnose) {
1680
+		$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>";
1681 1681
 		$info_div_class = "geodir_problem_info";
1682
-    } else {
1683
-        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1682
+	} else {
1683
+		$output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1684 1684
 		$info_div_class = "geodir_noproblem_info";
1685
-        $fix_button_txt = '';
1686
-    }
1685
+		$fix_button_txt = '';
1686
+	}
1687 1687
     
1688 1688
 	echo "<ul class='$info_div_class'>";
1689
-    echo $output_str;
1690
-    echo $fix_button_txt;
1691
-    echo "</ul>";
1689
+	echo $output_str;
1690
+	echo $fix_button_txt;
1691
+	echo "</ul>";
1692 1692
 
1693 1693
 }
1694 1694
 
@@ -1719,23 +1719,23 @@  discard block
 block discarded – undo
1719 1719
  */
1720 1720
 function geodir_posts_clauses_request($clauses)
1721 1721
 {
1722
-    global $wpdb, $wp_query, $plugin_prefix;
1722
+	global $wpdb, $wp_query, $plugin_prefix;
1723 1723
 
1724
-    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'])) {
1725
-        $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1724
+	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'])) {
1725
+		$table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1726 1726
 
1727
-        $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1728
-        $clauses['join'] = $join;
1727
+		$join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1728
+		$clauses['join'] = $join;
1729 1729
 
1730
-        $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1731
-        $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';
1732
-        $clauses['fields'] = $fields;
1730
+		$fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1731
+		$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';
1732
+		$clauses['fields'] = $fields;
1733 1733
 
1734
-        $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1735
-        $orderby = 'gd_expire ' . $order;
1736
-        $clauses['orderby'] = $orderby;
1737
-    }
1738
-    return $clauses;
1734
+		$order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1735
+		$orderby = 'gd_expire ' . $order;
1736
+		$clauses['orderby'] = $orderby;
1737
+	}
1738
+	return $clauses;
1739 1739
 }
1740 1740
 
1741 1741
 
@@ -1756,7 +1756,7 @@  discard block
 block discarded – undo
1756 1756
  */
1757 1757
 function gd_theme_switch_compat_check()
1758 1758
 {
1759
-    gd_set_theme_compat();
1759
+	gd_set_theme_compat();
1760 1760
 }
1761 1761
 
1762 1762
 /**
@@ -1769,27 +1769,27 @@  discard block
 block discarded – undo
1769 1769
  */
1770 1770
 function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\")
1771 1771
 {
1772
-    if (function_exists('str_getcsv')) {
1773
-        $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1774
-    } else {
1775
-        global $current_user;
1776
-        $upload_dir = wp_upload_dir();
1777
-
1778
-        $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1779
-        $handle = fopen($file, 'w');
1780
-
1781
-        fwrite($handle, $input);
1782
-        fclose($handle);
1783
-
1784
-        $handle = fopen($file, 'rt');
1785
-        if (PHP_VERSION >= '5.3.0') {
1786
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1787
-        } else {
1788
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1789
-        }
1790
-        fclose($handle);
1791
-    }
1792
-    return $fgetcsv;
1772
+	if (function_exists('str_getcsv')) {
1773
+		$fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1774
+	} else {
1775
+		global $current_user;
1776
+		$upload_dir = wp_upload_dir();
1777
+
1778
+		$file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1779
+		$handle = fopen($file, 'w');
1780
+
1781
+		fwrite($handle, $input);
1782
+		fclose($handle);
1783
+
1784
+		$handle = fopen($file, 'rt');
1785
+		if (PHP_VERSION >= '5.3.0') {
1786
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1787
+		} else {
1788
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1789
+		}
1790
+		fclose($handle);
1791
+	}
1792
+	return $fgetcsv;
1793 1793
 }
1794 1794
 
1795 1795
 add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv');
@@ -1804,375 +1804,375 @@  discard block
 block discarded – undo
1804 1804
  */
1805 1805
 function geodir_ajax_import_csv()
1806 1806
 {
1807
-    error_reporting(0); // hide error to get clean json response
1807
+	error_reporting(0); // hide error to get clean json response
1808 1808
 
1809
-    global $wpdb, $plugin_prefix, $current_user;
1810
-    $uploads = wp_upload_dir();
1811
-    ini_set('auto_detect_line_endings', true);
1809
+	global $wpdb, $plugin_prefix, $current_user;
1810
+	$uploads = wp_upload_dir();
1811
+	ini_set('auto_detect_line_endings', true);
1812 1812
 	
1813 1813
 	$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
1814 1814
 
1815
-    $task = isset($_POST['task']) ? $_POST['task'] : '';
1816
-    $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1817
-    $filename = $uploadedFile;
1818
-
1819
-    $uploads = wp_upload_dir();
1820
-    $uploads_dir = $uploads['path'];
1821
-    $image_name_arr = explode('/', $filename);
1822
-    $filename = end($image_name_arr);
1823
-    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1824
-    $return = array();
1825
-    $return['file'] = $uploadedFile;
1826
-    $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1827
-
1828
-    if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1829
-        $wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1830
-
1831
-        if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1832
-            $return['error'] = NULL;
1833
-
1834
-            $return['rows'] = 0;
1835
-
1836
-
1837
-
1838
-                if (($handle = fopen($target_path, "r")) !== FALSE) {
1839
-                    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1840
-                        if(is_array($data) && !empty($data)) {
1841
-                            $file[] = '"' . implode('","', $data) . '"';
1842
-                        }
1843
-                    }
1844
-                    fclose($handle);
1845
-                    $file = $file;
1846
-                }
1847
-
1848
-
1849
-
1850
-                $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1851
-
1852
-
1853
-            if (!$return['rows'] > 0) {
1854
-                $return['error'] = __('No data found in csv file.', 'geodirectory');
1855
-            }
1856
-        }
1857
-    }
1858
-    if ($task == 'prepare' || !empty($return['error'])) {
1859
-        echo json_encode($return);
1860
-        exit;
1861
-    }
1862
-
1863
-    $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
1864
-    $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
1865
-    $count = $importlimit;
1866
-    $requested_limit = $importlimit;
1867
-    $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
1868
-
1869
-    if ($count < $totRecords) {
1870
-        $count = $tmpCnt + $count;
1871
-        if ($count > $totRecords) {
1872
-            $count = $totRecords;
1873
-        }
1874
-    } else {
1875
-        $count = $totRecords;
1876
-    }
1877
-
1878
-    $total_records = 0;
1879
-    $rowcount = 0;
1880
-    $address_invalid = 0;
1881
-    $blank_address = 0;
1882
-    $upload_files = 0;
1883
-    $invalid_post_type = 0;
1884
-    $invalid_title = 0;
1885
-    $customKeyarray = array();
1886
-    $gd_post_info = array();
1887
-    $post_location = array();
1888
-    $countpost = 0;
1889
-
1890
-    if (!empty($file)) {
1891
-        $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
1892
-        $customKeyarray = $columns;
1893
-
1894
-        if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
1895
-            $return['error'] = CSV_INVAILD_FILE;
1896
-            echo json_encode($return);
1897
-            exit;
1898
-        }
1899
-
1900
-        for ($i = 1; $i <= $importlimit; $i++) {
1901
-            $current_index = $tmpCnt + $i;
1902
-            if (isset($file[$current_index])) {
1903
-                $total_records++;
1904
-
1905
-                $buffer = geodir_str_getcsv($file[$current_index]);
1906
-                $post_title = addslashes($buffer[0]);
1907
-                $current_post_author = $buffer[1];
1908
-                $post_desc = addslashes($buffer[2]);
1909
-                $post_cat = array();
1910
-                $catids_arr = array();
1911
-                $post_cat = trim($buffer[3]); // comma seperated category name
1912
-
1913
-                if ($post_cat) {
1914
-                    $post_cat_arr = explode(',', $post_cat);
1915
-
1916
-                    for ($c = 0; $c < count($post_cat_arr); $c++) {
1917
-                        $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1918
-
1919
-                        if (!empty($buffer[5])) {
1920
-                            if (in_array($buffer[5], geodir_get_posttypes())) {
1921
-
1922
-                                $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
1923
-
1924
-                                if (get_term_by('name', $catid, $p_taxonomy[0])) {
1925
-                                    $cat = get_term_by('name', $catid, $p_taxonomy[0]);
1926
-                                    $catids_arr[] = $cat->slug;
1927
-                                } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
1928
-                                    $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1929
-                                    $catids_arr[] = $cat->slug;
1930
-                                } else {
1931
-                                    $ret = wp_insert_term($catid, $p_taxonomy[0]);
1932
-                                    if ($ret && !is_wp_error($ret)) {
1933
-                                        if (get_term_by('name', $catid, $p_taxonomy[0])) {
1934
-                                            $cat = get_term_by('name', $catid, $p_taxonomy[0]);
1935
-                                            $catids_arr[] = $cat->slug;
1936
-                                        } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
1937
-                                            $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1938
-                                            $catids_arr[] = $cat->slug;
1939
-                                        }
1940
-                                    }
1941
-                                }
1942
-                            }
1943
-                        }
1944
-                    }
1945
-                }
1946
-
1947
-                if (!$catids_arr) {
1948
-                    $catids_arr[] = 1;
1949
-                }
1950
-
1951
-                $post_tags = trim($buffer[4]); // comma seperated tags
1952
-
1953
-                $tag_arr = '';
1954
-                if ($post_tags) {
1955
-                    $tag_arr = explode(',', $post_tags);
1956
-                }
1957
-
1958
-                $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
1959
-
1960
-                $error = '';
1961
-                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
1962
-                    $invalid_post_type++;
1963
-                    continue;
1964
-                }
1965
-
1966
-                if ($post_title != '') {
1967
-                    $menu_order = 0;
1968
-                    $image_folder_name = 'uplaod/';
1969
-
1970
-                    $image_names = array();
1971
-
1972
-                    for ($c = 5; $c < count($customKeyarray); $c++) {
1973
-                        $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
1974
-
1975
-                        if ($customKeyarray[$c] == 'IMAGE') {
1976
-                            $buffer[$c] = trim($buffer[$c]);
1977
-
1978
-                            if (!empty($buffer[$c])) {
1979
-                                $image_names[] = $buffer[$c];
1980
-                            }
1981
-                        }
1982
-
1983
-                        if ($customKeyarray[$c] == 'alive_days') {
1984
-                            if ($buffer[$c] != '0' && $buffer[$c] != '') {
1985
-                                $submitdata = date('Y-m-d');
1986
-
1987
-                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
1988
-                            } else {
1989
-                                $gd_post_info['expire_date'] = 'Never';
1990
-                            }
1991
-                        }
1992
-
1993
-                        if ($customKeyarray[$c] == 'post_city') {
1994
-                            $post_city = addslashes($buffer[$c]);
1995
-                        }
1996
-
1997
-                        if ($customKeyarray[$c] == 'post_region') {
1998
-                            $post_region = addslashes($buffer[$c]);
1999
-                        }
2000
-
2001
-                        if ($customKeyarray[$c] == 'post_country') {
2002
-                            $post_country = addslashes($buffer[$c]);
2003
-                        }
2004
-
2005
-                        if ($customKeyarray[$c] == 'post_latitude') {
2006
-                            $post_latitude = addslashes($buffer[$c]);
2007
-                        }
2008
-
2009
-                        if ($customKeyarray[$c] == 'post_longitude') {
2010
-                            $post_longitude = addslashes($buffer[$c]);
2011
-                        }
1815
+	$task = isset($_POST['task']) ? $_POST['task'] : '';
1816
+	$uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1817
+	$filename = $uploadedFile;
1818
+
1819
+	$uploads = wp_upload_dir();
1820
+	$uploads_dir = $uploads['path'];
1821
+	$image_name_arr = explode('/', $filename);
1822
+	$filename = end($image_name_arr);
1823
+	$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1824
+	$return = array();
1825
+	$return['file'] = $uploadedFile;
1826
+	$return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1827
+
1828
+	if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1829
+		$wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1830
+
1831
+		if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1832
+			$return['error'] = NULL;
1833
+
1834
+			$return['rows'] = 0;
1835
+
1836
+
1837
+
1838
+				if (($handle = fopen($target_path, "r")) !== FALSE) {
1839
+					while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1840
+						if(is_array($data) && !empty($data)) {
1841
+							$file[] = '"' . implode('","', $data) . '"';
1842
+						}
1843
+					}
1844
+					fclose($handle);
1845
+					$file = $file;
1846
+				}
1847
+
1848
+
1849
+
1850
+				$return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1851
+
1852
+
1853
+			if (!$return['rows'] > 0) {
1854
+				$return['error'] = __('No data found in csv file.', 'geodirectory');
1855
+			}
1856
+		}
1857
+	}
1858
+	if ($task == 'prepare' || !empty($return['error'])) {
1859
+		echo json_encode($return);
1860
+		exit;
1861
+	}
1862
+
1863
+	$totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
1864
+	$importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
1865
+	$count = $importlimit;
1866
+	$requested_limit = $importlimit;
1867
+	$tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
1868
+
1869
+	if ($count < $totRecords) {
1870
+		$count = $tmpCnt + $count;
1871
+		if ($count > $totRecords) {
1872
+			$count = $totRecords;
1873
+		}
1874
+	} else {
1875
+		$count = $totRecords;
1876
+	}
1877
+
1878
+	$total_records = 0;
1879
+	$rowcount = 0;
1880
+	$address_invalid = 0;
1881
+	$blank_address = 0;
1882
+	$upload_files = 0;
1883
+	$invalid_post_type = 0;
1884
+	$invalid_title = 0;
1885
+	$customKeyarray = array();
1886
+	$gd_post_info = array();
1887
+	$post_location = array();
1888
+	$countpost = 0;
1889
+
1890
+	if (!empty($file)) {
1891
+		$columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
1892
+		$customKeyarray = $columns;
1893
+
1894
+		if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
1895
+			$return['error'] = CSV_INVAILD_FILE;
1896
+			echo json_encode($return);
1897
+			exit;
1898
+		}
1899
+
1900
+		for ($i = 1; $i <= $importlimit; $i++) {
1901
+			$current_index = $tmpCnt + $i;
1902
+			if (isset($file[$current_index])) {
1903
+				$total_records++;
1904
+
1905
+				$buffer = geodir_str_getcsv($file[$current_index]);
1906
+				$post_title = addslashes($buffer[0]);
1907
+				$current_post_author = $buffer[1];
1908
+				$post_desc = addslashes($buffer[2]);
1909
+				$post_cat = array();
1910
+				$catids_arr = array();
1911
+				$post_cat = trim($buffer[3]); // comma seperated category name
1912
+
1913
+				if ($post_cat) {
1914
+					$post_cat_arr = explode(',', $post_cat);
1915
+
1916
+					for ($c = 0; $c < count($post_cat_arr); $c++) {
1917
+						$catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1918
+
1919
+						if (!empty($buffer[5])) {
1920
+							if (in_array($buffer[5], geodir_get_posttypes())) {
1921
+
1922
+								$p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
1923
+
1924
+								if (get_term_by('name', $catid, $p_taxonomy[0])) {
1925
+									$cat = get_term_by('name', $catid, $p_taxonomy[0]);
1926
+									$catids_arr[] = $cat->slug;
1927
+								} else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
1928
+									$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1929
+									$catids_arr[] = $cat->slug;
1930
+								} else {
1931
+									$ret = wp_insert_term($catid, $p_taxonomy[0]);
1932
+									if ($ret && !is_wp_error($ret)) {
1933
+										if (get_term_by('name', $catid, $p_taxonomy[0])) {
1934
+											$cat = get_term_by('name', $catid, $p_taxonomy[0]);
1935
+											$catids_arr[] = $cat->slug;
1936
+										} elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
1937
+											$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1938
+											$catids_arr[] = $cat->slug;
1939
+										}
1940
+									}
1941
+								}
1942
+							}
1943
+						}
1944
+					}
1945
+				}
1946
+
1947
+				if (!$catids_arr) {
1948
+					$catids_arr[] = 1;
1949
+				}
1950
+
1951
+				$post_tags = trim($buffer[4]); // comma seperated tags
1952
+
1953
+				$tag_arr = '';
1954
+				if ($post_tags) {
1955
+					$tag_arr = explode(',', $post_tags);
1956
+				}
1957
+
1958
+				$table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
1959
+
1960
+				$error = '';
1961
+				if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
1962
+					$invalid_post_type++;
1963
+					continue;
1964
+				}
1965
+
1966
+				if ($post_title != '') {
1967
+					$menu_order = 0;
1968
+					$image_folder_name = 'uplaod/';
1969
+
1970
+					$image_names = array();
1971
+
1972
+					for ($c = 5; $c < count($customKeyarray); $c++) {
1973
+						$gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
1974
+
1975
+						if ($customKeyarray[$c] == 'IMAGE') {
1976
+							$buffer[$c] = trim($buffer[$c]);
1977
+
1978
+							if (!empty($buffer[$c])) {
1979
+								$image_names[] = $buffer[$c];
1980
+							}
1981
+						}
1982
+
1983
+						if ($customKeyarray[$c] == 'alive_days') {
1984
+							if ($buffer[$c] != '0' && $buffer[$c] != '') {
1985
+								$submitdata = date('Y-m-d');
1986
+
1987
+								$gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
1988
+							} else {
1989
+								$gd_post_info['expire_date'] = 'Never';
1990
+							}
1991
+						}
1992
+
1993
+						if ($customKeyarray[$c] == 'post_city') {
1994
+							$post_city = addslashes($buffer[$c]);
1995
+						}
1996
+
1997
+						if ($customKeyarray[$c] == 'post_region') {
1998
+							$post_region = addslashes($buffer[$c]);
1999
+						}
2000
+
2001
+						if ($customKeyarray[$c] == 'post_country') {
2002
+							$post_country = addslashes($buffer[$c]);
2003
+						}
2004
+
2005
+						if ($customKeyarray[$c] == 'post_latitude') {
2006
+							$post_latitude = addslashes($buffer[$c]);
2007
+						}
2008
+
2009
+						if ($customKeyarray[$c] == 'post_longitude') {
2010
+							$post_longitude = addslashes($buffer[$c]);
2011
+						}
2012 2012
 						
2013 2013
 						// Post status
2014 2014
 						if ($customKeyarray[$c] == 'post_status') {
2015
-                            $post_status = sanitize_key( $buffer[$c] );
2016
-                        }
2017
-                    }
2018
-
2019
-                    /* ================ before array create ============== */
2020
-                    $location_result = geodir_get_default_location();
2021
-                    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'] == '')) {
2022
-                        $blank_address++;
2023
-                        continue;
2024
-                    } else if ($location_result->location_id == 0) {
2025
-                        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))) {
2026
-                            $address_invalid++;
2027
-                            continue;
2028
-                        }
2029
-                    }
2015
+							$post_status = sanitize_key( $buffer[$c] );
2016
+						}
2017
+					}
2018
+
2019
+					/* ================ before array create ============== */
2020
+					$location_result = geodir_get_default_location();
2021
+					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'] == '')) {
2022
+						$blank_address++;
2023
+						continue;
2024
+					} else if ($location_result->location_id == 0) {
2025
+						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))) {
2026
+							$address_invalid++;
2027
+							continue;
2028
+						}
2029
+					}
2030 2030
 					
2031 2031
 					// Default post status
2032 2032
 					$default_status = 'publish';
2033 2033
 					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
2034 2034
 					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
2035 2035
 
2036
-                    $my_post['post_title'] = $post_title;
2037
-                    $my_post['post_content'] = $post_desc;
2038
-                    $my_post['post_type'] = addslashes($buffer[5]);
2039
-                    $my_post['post_author'] = $current_post_author;
2040
-                    $my_post['post_status'] = $post_status;
2041
-                    $my_post['post_category'] = $catids_arr;
2042
-                    $my_post['post_tags'] = $tag_arr;
2043
-
2044
-                    $gd_post_info['post_tags'] = $tag_arr;
2045
-                    $gd_post_info['post_title'] = $post_title;
2046
-                    $gd_post_info['post_status'] = $post_status;
2047
-                    $gd_post_info['submit_time'] = time();
2048
-                    $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
2049
-
2050
-                    $last_postid = wp_insert_post($my_post);
2051
-                    $countpost++;
2052
-
2053
-                    // Check if we need to save post location as new location
2054
-                    if ($location_result->location_id > 0) {
2055
-                        if (isset($post_city) && isset($post_region)) {
2056
-                            $request_info['post_location'] = array(
2057
-                                'city' => $post_city,
2058
-                                'region' => $post_region,
2059
-                                'country' => $post_country,
2060
-                                'geo_lat' => $post_latitude,
2061
-                                'geo_lng' => $post_longitude
2062
-                            );
2063
-
2064
-                            $post_location_info = $request_info['post_location'];
2065
-                            if ($location_id = geodir_add_new_location($post_location_info))
2066
-                                $post_location_id = $location_id;
2067
-                        } else {
2068
-                            $post_location_id = 0;
2069
-                        }
2070
-                    } else {
2071
-                        $post_location_id = 0;
2072
-                    }
2073
-
2074
-                    /* ------- get default package info ----- */
2075
-                    $payment_info = array();
2076
-                    $package_info = array();
2077
-
2078
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2079
-                    $package_id = '';
2080
-                    if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2081
-                        $package_id = $gd_post_info['package_id'];
2082
-                    }
2083
-
2084
-                    if (!empty($package_info)) {
2085
-                        $payment_info['package_id'] = $package_info['pid'];
2086
-
2087
-                        if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2088
-                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2089
-                        } else {
2090
-                            $payment_info['expire_date'] = 'Never';
2091
-                        }
2092
-
2093
-                        $gd_post_info = array_merge($gd_post_info, $payment_info);
2094
-                    }
2095
-
2096
-                    $gd_post_info['post_location_id'] = $post_location_id;
2097
-
2098
-                    $post_type = get_post_type($last_postid);
2099
-
2100
-                    $table = $plugin_prefix . $post_type . '_detail';
2101
-
2102
-                    geodir_save_post_info($last_postid, $gd_post_info);
2103
-
2104
-                    if (!empty($image_names)) {
2105
-                        $upload_files++;
2106
-                        $menu_order = 1;
2107
-
2108
-                        foreach ($image_names as $image_name) {
2109
-                            $img_name_arr = explode('.', $image_name);
2110
-
2111
-                            $uploads = wp_upload_dir();
2112
-                            $sub_dir = $uploads['subdir'];
2113
-
2114
-                            $arr_file_type = wp_check_filetype($image_name);
2115
-                            $uploaded_file_type = $arr_file_type['type'];
2116
-
2117
-                            $attachment = array();
2118
-                            $attachment['post_id'] = $last_postid;
2119
-                            $attachment['title'] = $img_name_arr[0];
2120
-                            $attachment['content'] = '';
2121
-                            $attachment['file'] = $sub_dir . '/' . $image_name;
2122
-                            $attachment['mime_type'] = $uploaded_file_type;
2123
-                            $attachment['menu_order'] = $menu_order;
2124
-                            $attachment['is_featured'] = 0;
2125
-
2126
-                            $attachment_set = '';
2127
-
2128
-                            foreach ($attachment as $key => $val) {
2129
-                                if ($val != '')
2130
-                                    $attachment_set .= $key . " = '" . $val . "', ";
2131
-                            }
2132
-                            $attachment_set = trim($attachment_set, ", ");
2133
-
2134
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2135
-
2136
-                            if ($menu_order == 1) {
2137
-                                $post_type = get_post_type($last_postid);
2138
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2139
-                            }
2140
-                            $menu_order++;
2141
-                        }
2142
-                    }
2143
-
2144
-                    $gd_post_info['package_id'] = $package_id;
2145
-
2146
-                    /** This action is documented in geodirectory-functions/post-functions.php */
2147
-                    do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
2148
-
2149
-                    if (!empty($buffer[5])) {
2150
-                        if (in_array($buffer[5], geodir_get_posttypes())) {
2151
-                            $taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2152
-                            wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2153
-                            wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2154
-
2155
-                            $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2156
-                            $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2157
-                            geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2158
-                        }
2159
-                    }
2160
-                } else {
2161
-                    $invalid_title++;
2162
-                }
2163
-            }
2164
-        }
2165
-    }
2166
-    $return['rowcount'] = $countpost;
2167
-    $return['invalidcount'] = $address_invalid;
2168
-    $return['blank_address'] = $blank_address;
2169
-    $return['upload_files'] = $upload_files;
2170
-    $return['invalid_post_type'] = $invalid_post_type;
2171
-    $return['invalid_title'] = $invalid_title;
2172
-    $return['total_records'] = $total_records;
2173
-
2174
-    echo json_encode($return);
2175
-    exit;
2036
+					$my_post['post_title'] = $post_title;
2037
+					$my_post['post_content'] = $post_desc;
2038
+					$my_post['post_type'] = addslashes($buffer[5]);
2039
+					$my_post['post_author'] = $current_post_author;
2040
+					$my_post['post_status'] = $post_status;
2041
+					$my_post['post_category'] = $catids_arr;
2042
+					$my_post['post_tags'] = $tag_arr;
2043
+
2044
+					$gd_post_info['post_tags'] = $tag_arr;
2045
+					$gd_post_info['post_title'] = $post_title;
2046
+					$gd_post_info['post_status'] = $post_status;
2047
+					$gd_post_info['submit_time'] = time();
2048
+					$gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
2049
+
2050
+					$last_postid = wp_insert_post($my_post);
2051
+					$countpost++;
2052
+
2053
+					// Check if we need to save post location as new location
2054
+					if ($location_result->location_id > 0) {
2055
+						if (isset($post_city) && isset($post_region)) {
2056
+							$request_info['post_location'] = array(
2057
+								'city' => $post_city,
2058
+								'region' => $post_region,
2059
+								'country' => $post_country,
2060
+								'geo_lat' => $post_latitude,
2061
+								'geo_lng' => $post_longitude
2062
+							);
2063
+
2064
+							$post_location_info = $request_info['post_location'];
2065
+							if ($location_id = geodir_add_new_location($post_location_info))
2066
+								$post_location_id = $location_id;
2067
+						} else {
2068
+							$post_location_id = 0;
2069
+						}
2070
+					} else {
2071
+						$post_location_id = 0;
2072
+					}
2073
+
2074
+					/* ------- get default package info ----- */
2075
+					$payment_info = array();
2076
+					$package_info = array();
2077
+
2078
+					$package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2079
+					$package_id = '';
2080
+					if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2081
+						$package_id = $gd_post_info['package_id'];
2082
+					}
2083
+
2084
+					if (!empty($package_info)) {
2085
+						$payment_info['package_id'] = $package_info['pid'];
2086
+
2087
+						if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2088
+							$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2089
+						} else {
2090
+							$payment_info['expire_date'] = 'Never';
2091
+						}
2092
+
2093
+						$gd_post_info = array_merge($gd_post_info, $payment_info);
2094
+					}
2095
+
2096
+					$gd_post_info['post_location_id'] = $post_location_id;
2097
+
2098
+					$post_type = get_post_type($last_postid);
2099
+
2100
+					$table = $plugin_prefix . $post_type . '_detail';
2101
+
2102
+					geodir_save_post_info($last_postid, $gd_post_info);
2103
+
2104
+					if (!empty($image_names)) {
2105
+						$upload_files++;
2106
+						$menu_order = 1;
2107
+
2108
+						foreach ($image_names as $image_name) {
2109
+							$img_name_arr = explode('.', $image_name);
2110
+
2111
+							$uploads = wp_upload_dir();
2112
+							$sub_dir = $uploads['subdir'];
2113
+
2114
+							$arr_file_type = wp_check_filetype($image_name);
2115
+							$uploaded_file_type = $arr_file_type['type'];
2116
+
2117
+							$attachment = array();
2118
+							$attachment['post_id'] = $last_postid;
2119
+							$attachment['title'] = $img_name_arr[0];
2120
+							$attachment['content'] = '';
2121
+							$attachment['file'] = $sub_dir . '/' . $image_name;
2122
+							$attachment['mime_type'] = $uploaded_file_type;
2123
+							$attachment['menu_order'] = $menu_order;
2124
+							$attachment['is_featured'] = 0;
2125
+
2126
+							$attachment_set = '';
2127
+
2128
+							foreach ($attachment as $key => $val) {
2129
+								if ($val != '')
2130
+									$attachment_set .= $key . " = '" . $val . "', ";
2131
+							}
2132
+							$attachment_set = trim($attachment_set, ", ");
2133
+
2134
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2135
+
2136
+							if ($menu_order == 1) {
2137
+								$post_type = get_post_type($last_postid);
2138
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2139
+							}
2140
+							$menu_order++;
2141
+						}
2142
+					}
2143
+
2144
+					$gd_post_info['package_id'] = $package_id;
2145
+
2146
+					/** This action is documented in geodirectory-functions/post-functions.php */
2147
+					do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
2148
+
2149
+					if (!empty($buffer[5])) {
2150
+						if (in_array($buffer[5], geodir_get_posttypes())) {
2151
+							$taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2152
+							wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2153
+							wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2154
+
2155
+							$post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2156
+							$post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2157
+							geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2158
+						}
2159
+					}
2160
+				} else {
2161
+					$invalid_title++;
2162
+				}
2163
+			}
2164
+		}
2165
+	}
2166
+	$return['rowcount'] = $countpost;
2167
+	$return['invalidcount'] = $address_invalid;
2168
+	$return['blank_address'] = $blank_address;
2169
+	$return['upload_files'] = $upload_files;
2170
+	$return['invalid_post_type'] = $invalid_post_type;
2171
+	$return['invalid_title'] = $invalid_title;
2172
+	$return['total_records'] = $total_records;
2173
+
2174
+	echo json_encode($return);
2175
+	exit;
2176 2176
 }
2177 2177
 
2178 2178
 // Add the tab in left sidebar menu fro import & export page.
@@ -2192,9 +2192,9 @@  discard block
 block discarded – undo
2192 2192
  * @param $post object $post The post object of the post being saved.
2193 2193
  */
2194 2194
 function geodir_update_location_prefix($post_id,$post){
2195
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2196
-        update_option('geodir_location_prefix',$post->post_name);
2197
-    }
2195
+	if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2196
+		update_option('geodir_location_prefix',$post->post_name);
2197
+	}
2198 2198
 
2199 2199
 }
2200 2200
 
@@ -2205,50 +2205,50 @@  discard block
 block discarded – undo
2205 2205
 function geodir_ga_callback(){
2206 2206
 
2207 2207
 if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2208
-    $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2209
-    $code = "code=".$_REQUEST['code'];
2210
-    $grant_type = "&grant_type=authorization_code";
2211
-    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2212
-    $client_id = "&client_id=".get_option('geodir_ga_client_id');
2213
-    $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2208
+	$oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2209
+	$code = "code=".$_REQUEST['code'];
2210
+	$grant_type = "&grant_type=authorization_code";
2211
+	$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2212
+	$client_id = "&client_id=".get_option('geodir_ga_client_id');
2213
+	$client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2214 2214
 
2215
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2215
+	$auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2216 2216
 
2217
-    $response = wp_remote_post($auth_url, array('timeout' => 15));
2217
+	$response = wp_remote_post($auth_url, array('timeout' => 15));
2218 2218
 
2219
-    //print_r($response);
2219
+	//print_r($response);
2220 2220
 
2221
-    $error_msg =  __('Something went wrong','geodirectory');
2222
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2221
+	$error_msg =  __('Something went wrong','geodirectory');
2222
+	if(!empty($response['response']['code']) && $response['response']['code']==200){
2223 2223
 
2224
-        $parts = json_decode($response['body']);
2225
-        //print_r($parts);
2226
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2227
-        else{
2224
+		$parts = json_decode($response['body']);
2225
+		//print_r($parts);
2226
+		if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2227
+		else{
2228 2228
 
2229
-            update_option('gd_ga_access_token', $parts->access_token);
2230
-            update_option('gd_ga_refresh_token', $parts->refresh_token);
2231
-            ?><script>window.close();</script><?php
2232
-        }
2229
+			update_option('gd_ga_access_token', $parts->access_token);
2230
+			update_option('gd_ga_refresh_token', $parts->refresh_token);
2231
+			?><script>window.close();</script><?php
2232
+		}
2233 2233
 
2234 2234
 
2235
-    }
2236
-    elseif(!empty($response['response']['code'])) {
2237
-        $parts = json_decode($response['body']);
2235
+	}
2236
+	elseif(!empty($response['response']['code'])) {
2237
+		$parts = json_decode($response['body']);
2238 2238
 
2239
-        if(isset($parts->error)){
2240
-            echo $parts->error.": ".$parts->error_description;exit;
2241
-        }else{
2242
-            echo $error_msg." - #2";exit;
2243
-        }
2239
+		if(isset($parts->error)){
2240
+			echo $parts->error.": ".$parts->error_description;exit;
2241
+		}else{
2242
+			echo $error_msg." - #2";exit;
2243
+		}
2244 2244
 
2245
-    }else{
2245
+	}else{
2246 2246
 
2247
-        echo $error_msg." - #3";exit;
2247
+		echo $error_msg." - #3";exit;
2248 2248
 
2249
-    }
2249
+	}
2250 2250
 }
2251
-    exit;
2251
+	exit;
2252 2252
 }
2253 2253
 
2254 2254
 add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 );
Please login to merge, or discard this patch.